cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
789 stars 610 forks source link

Unable to update a managed request header from `true` to `false` on `cloudflare_managed_headers` #2806

Open nialdaly opened 1 year ago

nialdaly commented 1 year ago

Confirmation

Terraform and Cloudflare provider version

Terraform v1.5.7 on darwin_arm64

Affected resource(s)

Terraform configuration files

resource "cloudflare_managed_headers" "managed_headers" {
  zone_id = data.cloudflare_zone.zone.id

  managed_request_headers {
    id      = "add_client_certificate_headers"
    enabled = false
  }
}

Link to debug output

https://gist.github.com/nialdaly/a3f6924e3812791a0e6bdf4d23157ca1

Panic output

No response

Expected output

Actual output

Steps to reproduce

Additional factoids

No response

References

No response

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 1 year ago

this is unfortunately a known issue with swapping between zero values in Terraform SDKv2. we can mitigate it by migrating to the plugin framework however i do not have an ETA on when that will happen. in the meantime, to swap the value you will need to remove it from your state file, and reapply it with the false value set.

nialdaly commented 1 year ago

Hi @jacobbednarz! Thanks for the prompt response, makes sense. Cheers!

glensc commented 1 month ago

in the meantime, to swap the value you will need to remove it from your state file, and reapply it with the false value set.

that appears to change flag in the web, but tf plan always says it needs to make modifications:


resource "cloudflare_managed_headers" "managed_headers" {
  zone_id = cloudflare_zone.zone.id

  managed_request_headers {
    enabled = false
    id      = "add_client_certificate_headers"
  }
  managed_request_headers {
    enabled = false
    id      = "add_visitor_location_headers"
  }
  managed_request_headers {
    enabled = false
    id      = "remove_visitor_ip_headers"
  }
  managed_response_headers {
    enabled = false
    id      = "add_security_headers"
  }
}
cloudflare_managed_headers.managed_headers will be updated in-place
  ~ resource "cloudflare_managed_headers" "managed_headers" {
        id      = "94b23da3bb6dabefcb39c7f845a7d681"
        # (1 unchanged attribute hidden)

      + managed_request_headers {
          + enabled = false
          + id      = "add_client_certificate_headers"
        }
      + managed_request_headers {
          + enabled = false
          + id      = "add_visitor_location_headers"
        }
      + managed_request_headers {
          + enabled = false
          + id      = "remove_visitor_ip_headers"
        }

      - managed_response_headers {
          - enabled = true -> null
          - id      = "remove_x-powered-by_header" -> null
        }
      + managed_response_headers {
          + enabled = false
          + id      = "add_security_headers"
        }
    }