integrations / integrations/terraform-provider-github
[BUG]: 422 error on repository deletion with `archive_on_destroy = true` and security configuration enforced on all repos
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 8
Description
### Expected Behavior
Repository should be archived and removed from terraform state
### Actual Behavior
Repository is archived but i get 422 An enforced security configuration prevented modifying advanced security enablement. Contact your organization owner for details in terrform run
### Terraform Version
Terraform 1.14.9
github = {
source = "integrations/github"
version = "6.13.0"
}
### GitHub Installation Type
- [ ] GitHub.com (Free, Pro, or Team)
- [ ] GitHub Enterprise Server (on-premises)
- [x] GitHub Enterprise Cloud with Personal Accounts (github.com)
- [ ] GitHub Enterprise Cloud with Managed Users/EMU (github.com)
- [ ] GitHub Enterprise Cloud with Data Residency (*.ghe.com)
- [ ] I don't know
### Affected Resource(s)
github_repository
### Terraform Configuration Files
```hcl
resource "github_repository" "this" {
for_each = var.github_repositories
name = each.key
visibility = "private"
allow_merge_commit = false
allow_rebase_merge = false
archive_on_destroy = true
allow_update_branch = true
template {
owner = "test-org"
repository = "template-repository"
include_all_branches = false
}
lifecycle {
ignore_changes = [
visibility,
allow_merge_commit,
allow_rebase_merge,
allow_update_branch,
security_and_analysis,
template
]
}
}
```
### Steps to Reproduce
enforce dependbot on all repositories
create a repository with `archive_on_destroy = true` and delete it from configuration
### Debug Output
```shell
github_repository.this["test-repo"]: Destroying... [id=test-repo]
Error: PATCH https://api.github.com/repos/test-org/test-repo: 422 An enforced security configuration prevented modifying advanced security enablement. Contact your organization owner for details. []
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start at the github_repository resource's destroy path and reproduce the configuration using archive_on_destroy with organization-wide enforced security settings. Trace the PATCH request shown in the debug output and identify the expected successful end state: the repository is archived and removed from Terraform state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, go, terraform
- Domain
- infrastructure, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100