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

Storage Bucket with unspecified location may fail #4422

Assignees
Milestone

Comments

@theomessin
Copy link

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

When creating a new bucket with an unspecified location, the storage_class along with the provider config values (default region and default zone) should be used to determine the correct location. Currently, for example, creating a bucket with storage_class = "REGIONAL" and no location specified will fail with the following error:

Error: googleapi: Error 400: The combination of locationConstraint and storageClass you provided is not supported for your project, invalid

The storage_class can be used to infer proper default values for the location.

New or Affected Resource(s)

  • google_storage_bucket

Potential Terraform Configuration

provider "google" {
  project     = "my-london-project"
  region      = "europe-west2"
  zone        = "europe-west2-b"
}

resource "google_storage_bucket" "primary" {
  name     = "my-very-cool-bucket"
  storage_class = "REGIONAL"
  bucket_policy_only = true
}

The above code will currently fail. The location of the bucket could easily be inferred to be europe-west2 which is the default provider region.

@ghost ghost added the enhancement label Sep 8, 2019
@paddycarver paddycarver added this to the 4.0.0 milestone Dec 6, 2019
@paddycarver
Copy link
Contributor

I think the ideal solution here is for the location field to just be required, as the provider locations and the storage locations differ and so inferring them is hard. Unfortunately, making the field required is a breaking change, and so we need to wait for 4.0.0 to be able to do that.

@toadjaune
Copy link

Actually, I'd propose the following inference logic if location is not explicitly defined :

  • if storage_class = "MULTI-REGIONAL", infer location (EU, US or ASIA) from provider region (if defined, fail otherwise)
  • if storage_class has any other value (STANDARD, REGIONAL, NEARLINE, COLDLINE), use provider region (if defined, fail otherwise)

I'm not sure that would be a breaking change ; if I'm not mistaken, it would not break anything currently working, only add extra working cases.

@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2021
@github-actions github-actions bot added service/storage forward/review In review; remove label to forward labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.