Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy errors out on read-only resources #531

Closed
inge4pres opened this issue Nov 2, 2019 · 4 comments
Closed

Destroy errors out on read-only resources #531

inge4pres opened this issue Nov 2, 2019 · 4 comments

Comments

@inge4pres
Copy link

inge4pres commented Nov 2, 2019

Hello,

this is a report of an error occurred during the destroy phase for a zone.
We're testing migration to v2 provider by creating/destroying a test zone.

Terraform Version

terraform 0.11.14
terraform-provider-cloudflare 2.0.1

Affected Resource(s)

Please list the resources as a list, for example:

  • cloudflare_zone
  • cloudflare_zone_settings_override

Terraform Configuration Files

## previously managed by mjolnir
resource "cloudflare_zone" "zone" {
  type = "partial"
  plan = "enterprise"
  zone = "${var.zone}"
}

resource "cloudflare_zone_settings_override" "zone-setting" {
  zone_id = "${cloudflare_zone.zone.id}"

  settings {
    tls_1_3 = "on"
    min_tls_version = "1.1"
    ssl = "${var.ssl_mode}"
    // => readonly in Free, have it Enterprise
    http2 = "${var.enable_http2}"
    opportunistic_encryption = "off"
    brotli = "on"
    automatic_https_rewrites = "${var.automatic_https_rewrites}"
    security_level = "medium"
    waf = "on"
    polish = "lossless"
    mirage = "off"
    rocket_loader = "off"
    minify {
      css = "on"
      js = "on"
      html = "on"
    }
  }
}

Expected Behavior

No error in destroying the resources

Actual Behavior

This error shows up:

Error: Error applying plan:

1 error occurred:
        * module.zone-name.cloudflare_zone_settings_override.zone-setting (destroy): 1 error occurred:
        * cloudflare_zone_settings_override.zone-setting: invalid zone setting "image_resizing" (value: ) found - cannot be set as it is read only

Looks like the destroy cycle tries to set an attribute to the zone before destroying...

Steps to Reproduce

  1. Create a zone and its custom configs, running terraform apply
  2. Destroy the zone terraform destroy
@jacobbednarz
Copy link
Member

What I suspect is happening here is that the zone is created but it hasn't been converted to an Enterprise zone when the resource is destroyed, it still doesn't have access to it. I don't think we can do anything in the provider at this stage to cleanly account for this.

If the above is indeed what is happening, the advice I have been giving to people is to do it in two steps. Create the zone and get it setup as an Enterprise zone in your account and then try to applying changes to it. Also, if you're not using those settings, just omit them to leave them as the defaults.

@jacobbednarz
Copy link
Member

#599 is mentioned to have addressed this. @inge4pres would you mind checking out master and confirming this is the case for you?

@jacobbednarz
Copy link
Member

Closing this off as #599 mentions a potential fix. Can reopen if we needed to explore further.

@simonpainter
Copy link

Not convinced this has been fixed.

Following error when trying to destroy customer settings.
"Error: invalid zone setting "image_resizing" (value: ) found - cannot be set as it is read only"

terraform-provider-cloudflare_v2.7.0_x4
Terraform v0.12.26

boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this issue Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants