Incorrect project
attribute value on google_storage_bucket
data source when bucket belongs to a different project than provider default
#17165
Labels
Community Note
to expedite investigation and resolution of this issue.
Terraform Version
Terraform v1.5.7
on darwin_arm64
Affected Resource(s)
data.google_storage_bucket
Terraform Configuration
Debug Output
Here's the output in the CLI would be after applying the config:
Expected Behavior
The resource and data source are both connected to the same bucket in GCP and should have the same value for project, matching the project the bucket is linked to.
Actual Behavior
The two outputs are different. This is because the data source reflects the provider default project instead of the actual project the bucket is linked to.
Steps to reproduce
terraform apply
Important Factoids
Internally the google_storage_bucket resource and datasources share some code that takes in the result of a GET request to read a bucket's data, manipulates that data a bit, and saves it in state.
One of the manipulations is that the Storage API returns the project NUMBER linked to the bucket, not the project ID. When no project value is supplied via the config (i.e. when the data source is using that reused code, as the data source doesn't require a project argument) the code receives the project number and uses the Compute API to translate it into the correct project ID.
However if a provider default project is present, then the data source will use this value to set
project
in state and will ignore the project number returned from the Storage API. This means the project attribute on the data source may be incorrect, depending on the config.References
No response
b/323650332
The text was updated successfully, but these errors were encountered: