terraform-provider-google icon indicating copy to clipboard operation
terraform-provider-google copied to clipboard

Terraform support to deploy GCS using custom dual-region

Open vnachimu opened this issue 3 years ago • 1 comments

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 the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Current Terraform provider is NOT supporting to create a custom dual-region GCS bucket using location field. It works just fine with Google's predefined dual-regions - NAM4, ASIA1, EUR4. When you create a custom-dual region with a location field as US-CENTRAL1+US-EAST1, the terraform state stores the location as US. When we make an update to the bucket next time, there is a mismatch between code and state file, which forces the deployment to be recreated like force replacement.

However, both console and gcloud work fine without any issues. Google handles dual-regions something like this in gcloud-gsutil.

gsutil mb -l MULTI-REGION --placement REGION_1,REGION_2 gs://BUCKET_NAME/

There is an option / switch called "placement" where you can specify the dual-region info. Once the bucket has created, the backend data has been stored as below.

gs://my-bucket/ : Storage class: STANDARD Location type: dual-region Location constraint: US Placement locations: [US-CENTRAL1, US-WEST1]

GCS Terraform is not offering this switch "placement" to specify 2 regions to create a bucket. Therefore, we pass dual-region info like this,

location = US-CENTRAL1+US-EAST1

New or Affected Resource(s)

Google Cloud Storage (GCS) storage.googleapis.com

Potential Terraform Configuration

When we create a bucket, there should be an option to say the placement locations info in terraform resource. Something like below.

resource "google_storage_bucket" "auto-expire" {
name = "auto-expiring-bucket"
location = "US"
placement = [US-CENTRAL1, US-WEST1]
}

References

https://github.com/hashicorp/terraform-provider-google/issues/1229 https://github.com/terraform-google-modules/terraform-google-cloud-storage/issues/182

  • #0000

vnachimu avatar Aug 10 '22 15:08 vnachimu

This is possible via the customPlacementConfig field.

c2thorn avatar Sep 14 '22 16:09 c2thorn

b/249089097

melinath avatar Sep 26 '22 15:09 melinath

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Nov 05 '22 02:11 github-actions[bot]