-
Notifications
You must be signed in to change notification settings - Fork 883
Description
Expected Behavior
If the 'security_and_analysis' block is either unset, unchanged, or ignored by Terraform by using the ignore_changes list in the lifecycle block of a github_repository, then terraform apply should not send that block to the GitHub API.
Actual Behavior
The block above is sent to the GitHub API, which causes an issue even if it isn't a change.
This becomes an issue if/when the repository has an enterprise policy that prevents modifying the advanced security enablement:
│ Error: PATCH https://api.github.com/repos/$ORG_REDACTED/$REPO_REDACTED: 422 An enterprise policy prevented modifying advanced security enablement. Contact your enterprise owner for details. [] │ │ with github_repository.all['$REPO_REDACTED'], │ on main.tf line 1, in resource "github_repository" "all": │ 1: resource "github_repository" "all" {
Terraform Version
Terraform v1.8.2
on darwin_arm64
- provider registry.terraform.io/hashicorp/aws v5.48.0
- provider registry.terraform.io/integrations/github v6.2.1
Affected Resource(s)
github_repository
Terraform Configuration Files
resource "github_repository" "all" {
for_each = var.REPOSITORIES
name = each.key
description = each.value.description
lifecycle {
ignore_changes = [
# Cannot control these: "An enterprise policy prevented modifying advanced security enablement."
security_and_analysis
]
}Steps to Reproduce
No response
Debug Output
2024-05-03T16:11:08.912-0700 [ERROR] provider.terraform-provider-github_v6.2.1: Response contains error diagnostic: @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 tf_req_id=b55abc6e-0f96-7365-adb8-1979a52d852e tf_rpc=ApplyResourceChange tf_resource_type=github_repository @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="PATCH https://api.github.com/repos/$ORG_REDACTED/$REPO_REDACTED: 422 An enterprise policy prevented modifying advanced security enablement. Contact your enterprise owner for details. []" tf_proto_version=5.4 tf_provider_addr=provider timestamp=2024-05-03T16:11:08.912-0700Panic Output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct