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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bucket custom placement config values not normalised causing replacement on every apply #18035

Open
VenelinMartinov opened this issue May 7, 2024 · 2 comments

Comments

@VenelinMartinov
Copy link

VenelinMartinov commented May 7, 2024

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.8.2
on darwin_arm64

  • provider registry.terraform.io/hashicorp/google-beta v5.28.0

Affected Resource(s)

google_storage_bucket

Terraform Configuration

provider "google" {
  region = "us-central1"
}

terraform {
  required_providers {
    google = {
      source  = "hashicorp/google-beta"
      version = "5.28.0"
    }
  }
}

resource "google_storage_bucket" "example" {
  name          = "example-dual-region-bucket-au"
  location      = "AU"
  custom_placement_config {
    data_locations = [ "australia-southeast1", "australia-southeast2" ]
  }
}

Debug Output

https://gist.github.com/VenelinMartinov/9ac1801364ef4e5c494b377e708dd714

Expected Behavior

The bucket gets replaced each time.

Note that upper-casing the locations fixes this - seems like they need to be normalised before diffing.

Actual Behavior

Should not get replaced

Steps to reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

No response

References

No response

b/340346616

@ggtisc
Copy link
Collaborator

ggtisc commented May 13, 2024

Confirmed issue:

As user reports after bucket creation when it exists with the provided code and configuration, when a terraform plan is executed it recognizes as a change to destroy and then create replacement but if the locations of the attribute data_locations is set in uppercase [ "AUSTRALIA-SOUTHEAST1", "AUSTRALIA-SOUTHEAST2" ] instead of lowercase [ "australia-southeast1", "australia-southeast2" ] it returns a message saying: No changes. Your infrastructure matches the configuration

@ggtisc ggtisc removed the forward/review In review; remove label to forward label May 13, 2024
@kautikdk
Copy link

It appears that the StatFunc inside the TypeSet elements won't work because of this known issue:hashicorp/terraform-plugin-sdk#160. That may be the reason why there is no StatFunc for custom_placement_config because it is TypeSet and It won't work.
location field is having StatFunc https://github.com/GoogleCloudPlatform/magic-modules/blob/main/mmv1/third_party/terraform/services/storage/resource_storage_bucket.go.erb#L124 and it is working as expected because it is not nested attribute.
I don't see any clear solution to this issue and maybe the only thing that can be done here is to clearly specify and document that Input values should be in the uppercase.

@BBBmau BBBmau assigned BBBmau and unassigned ggtisc May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants