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

image_resizing for cloudflare_zone_settings_override doesn't make changes #961

Closed ChristophShyper closed 3 years ago

ChristophShyper commented 3 years ago

Terraform version

Terraform v0.14.5

Affected resource(s)

cloudflare_zone_settings_override

Terraform configuration files

resource "cloudflare_zone_settings_override" "config_override" {
  zone_id = cloudflare_zone.this.id

  settings {
   (...)
   image_resizing  = "on"
   (...)
  }
}

Debug output

Error: invalid zone setting "image_resizing" (value: ) found - cannot be set as it is read only

Expected behavior

Image resizing option should be enabled.

Actual behavior

Image resizing is still off.

Steps to reproduce

  1. Create zone with image resizing turned off
  2. Add cloudflare_zone_settings_override to your terraform with current values
  3. terraform apply works
  4. Change image_resizing to off

We have Enterprise plan, so it's possible to set it. Setting it manually in Cloudflare solves the error, but we want to control it from code.

References

Community note

olenm commented 3 years ago

On a new hosted-zone and on attempting to enable the "override" settings for the first time - I have image_resizing off in TF (and it is certainly off in the web-ui) and I too, get the read-only error.

alxsbn commented 3 years ago

I have the same behavior with webp and http2

Cloudflare_zone_settings_override.settings: Creating...

Error: invalid zone setting "http2" (value: off) found - cannot be set as it is read only

TF try to destroy then create a new zone settings override but some parameters seems blocked as they're flagged as 'read only'. I also have the same error with webp.

vital4ik commented 3 years ago

I get this too, works on some zones but not others with different values

jacobbednarz commented 3 years ago

i've found an internal reference stating this has been addressed. @alxsbn can you please confirm if you're still seeing the issue?

kawikao commented 3 years ago

I have this problem too. I'm on the Cloudflare free plan and I notice some of the read-only settings that error are only available on the Cloudflare enterprise plan or for a service I don't have enabled.

This is a fatal error because when trying to delete the resource, it tries to update settings at Cloudflare marked as read-only which causes the delete to fail. So, I can't update a read-only setting with the existing value or null and I can't delete the resource. It's essentially a zombie resource that will never update or go away.

My suggestion is to skip trying to update read-only settings.

kawikao commented 3 years ago

I upgraded my Cloudflare zone to Enterprise and a whole slew of read-only settings went away except paid services like Image Resizing, DDOS and AST.

The provider should not be trying to update a Cloudflare service that the zone is not subscribed too. The request will be blocked. Need a workaround or a fix. Thanks.

jacobbednarz commented 3 years ago

No @kawikao, yours is not a bug. The resource is intended as an override to the defaults and if you do not have entitlements, the resource is not aware of it. It is not a resource intended to manage all resources irrespective of the entitlements.

kawikao commented 3 years ago

From the docs.

Note that after destroying this resource Zone Settings will be reset to their initial values.

I took it to mean, the provider tries to reset the initial values at Cloudflare. Since, many settings are read-only, it doesn't appear to even try to reset the values and aborts destroying the resource. It's a catch-22. I just terraform rm and won't use the resource until this issue is resolved.