Description
I believe I've found a bug in the provider registry.terraform.io/integrations/github.
I'm able to create repos successfully with the following code:
resource "github_repository" "code_store" {
name = var.repository_name
description = var.repository_description
auto_init = true
allow_squash_merge = true
allow_merge_commit = false
allow_rebase_merge = false
delete_branch_on_merge = true
}
But then when I try to update them in any way I get the following error:
Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric1a: 422 Secret Scanning is always enabled for public repos []
So I tried including the following security_and_analysis segment:
resource "github_repository" "code_store" {
name = var.repository_name
description = var.repository_description
auto_init = true
allow_squash_merge = true
allow_merge_commit = false
allow_rebase_merge = false
delete_branch_on_merge = true
security_and_analysis {
advanced_security {
status = "enabled"
}
secret_scanning {
status = "enabled"
}
secret_scanning_push_protection {
status = "enabled"
}
}
}
But this results in the following error:
Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric3a: 422 Enabling advanced security is restricted by a policy []
So I attempted to force-disable the extra security settings:
resource "github_repository" "code_store" {
name = var.repository_name
description = var.repository_description
auto_init = true
allow_squash_merge = true
allow_merge_commit = false
allow_rebase_merge = false
delete_branch_on_merge = true
security_and_analysis {
advanced_security {
status = "disabled"
}
secret_scanning {
status = "disabled"
}
secret_scanning_push_protection {
status = "disabled"
}
}
}
But this again gives the following error:
Error: PATCH https://github.office.COMPANY_NAME.com/api/v3/repos/OWNER_NAME/repo-test-eric1a: 422 Secret Scanning is always enabled for public repos []
All of these attempts were done fresh with a destroy cleaning up everything before attempting the create again and this is when creating a public repo.
I'm using Terraform v1.3.7 and provider registry.terraform.io/integrations/github v5.14.0 though I was getting the same errors on earlier versions of both terraform and the github provider.
Any suggestions would be greatly appreciated.