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

Add project_number field to google_storage_bucket resource and datasource, enable providing project argument to data source #7164

Conversation

modular-magician
Copy link
Collaborator

Closes hashicorp/terraform-provider-google#17166

This PR aims to address an edge case where users do not want to give the identity/service account used by Terraform permissions on the Compute API and want to provision GCS buckets. Previously if a project name was not supplied to the data source via provider defaults then the data source would:

  • retrieve information about the bucket from the Storage API, including the project number it's linked to
  • call the Compute API to get a human-readable project id for that project number, and use that to populate the project field

By letting users set the project field on the data source they can avoid that call to the Compute API. There is a chance that the project id they supply doesn't match the project number linked to the GCS bucket. This isn't ideal, but was OK'd during triage as it matches the existing behaviour on import.

This PR also adds a new field, project_number, to surface the information returned from the Storage API which is guaranteed to be accurate. This enables users to perform any checks etc to verify the project id and number are a correct pairing.

Release Note Template for Downstream PRs (will be copied)

storage: added `project_number` attribute to `google_storage_bucket` resource and data source
storage: added ability to provide `project` argument to `google_storage_bucket` data source. This will not impact reading the resource's data, instead this helps users avoid calls to the Compute API within the data source.

Derived from GoogleCloudPlatform/magic-modules#10312

…source, enable providing `project` argument to data source (#10312)

[upstream:b256de44e796f196e7376ce545c01a765458204d]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit 391c9d5 into hashicorp:main Mar 28, 2024
4 checks passed
@modular-magician modular-magician deleted the downstream-pr-b256de44e796f196e7376ce545c01a765458204d branch November 16, 2024 03:57
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

Successfully merging this pull request may close these issues.

Add opt-in behaviour to allow google_storage_bucket to be used without requiring Compute API permissions
1 participant