cloudflare / terraform-provider-cloudflare

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

Issue changing location from ENAM to WEUR in a r2 bucket #3311

Open marccortinas opened 3 months ago

marccortinas commented 3 months ago

Confirmation

Terraform and Cloudflare provider version

Terraform version: 1.5.2
v4.30.0

Affected resource(s)

Terraform configuration files

resource "cloudflare_r2_bucket" "static" {
  account_id       = local.cloudflare_account_id
  name       = "static"
  location   = "WEUR"
}

Link to debug output

https://gist.github.com/marccortinas/d96bdfc0573929acf2ba7fbfcfaefd4c

Panic output

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to cloudflare_r2_bucket.statics, provider "provider[\"registry.terraform.io/cloudflare/cloudflare\"]"
│ produced an unexpected new value: .location: was cty.StringVal("WEUR"), but now cty.StringVal("ENAM").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Expected output

Terraform will perform the following actions:

  # cloudflare_r2_bucket.statics is tainted, so must be replaced
-/+ resource "cloudflare_r2_bucket" "statics" {
      ~ id         = "statics" -> (known after apply)
      ~ location   = "ENAM" -> "WEUR"
        name       = "statics"
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Actual output


│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to cloudflare_r2_bucket.statics, provider "provider[\"registry.terraform.io/cloudflare/cloudflare\"]"
│ produced an unexpected new value: .location: was cty.StringVal("WEUR"), but now cty.StringVal("ENAM").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

Steps to reproduce

  1. R2 bucket created in ENAM region
  2. The same R2 bucket change the location to WEUR

Additional factoids

Finally i modified the name of the bucket. The first bucket was called statics and the current one is called static and it's working fine

References

https://developers.cloudflare.com/r2/reference/data-location/ https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/r2_bucket

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

jacobbednarz commented 3 months ago

once a bucket is created, you cannot change the location of the bucket. we should probably do a ForceNew: true here to prevent this scenario.

Cyb3r-Jak3 commented 3 months ago

Following up, per the docs

Location Hints are only honored the first time a bucket with a given name is created. If you delete and recreate a bucket with the same name, the original bucket’s location will be used.

A solution might be to check is the location hint has changed without the bucket name changing and throw an error.