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

data.google_storage_bucket.project return the wrong value #13034

Open
martinOrigin8Cares opened this issue Nov 14, 2022 · 5 comments
Open

data.google_storage_bucket.project return the wrong value #13034

martinOrigin8Cares opened this issue Nov 14, 2022 · 5 comments
Labels
forward/linked persistent-bug Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work service/storage size/s
Milestone

Comments

@martinOrigin8Cares
Copy link

martinOrigin8Cares commented Nov 14, 2022

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

Terraform Version

Terraform v1.3.4
on linux_amd64

Affected Resource(s)

data.google_storage_bucket

registry.terraform.io/hashicorp/google v4.43.0

Terraform Configuration Files

You will need two GCP project to reproduce this.

  • project1 (any project will do)
  • project2 (create a bucket "my-bucket-name" )
provider "google" {
  project     = "project1"
  credentials = "/some/path/to/key.json"
}

data "google_storage_bucket" "example" {
  name    = "my-bucket-name"
}

output "project_of_bucket" {
  value = data.google_storage_bucket.example.project
}

Debug Output

Panic Output

Expected Behavior

Changes to Outputs:

  • project_of_bucket = "proejct2"

Actual Behavior

Changes to Outputs:

  • project_of_bucket = "project1"

Steps to Reproduce

  1. terraform plan

Important Factoids

When the argument project of the provider is set, it override the value coming from the API.
Also the google API doesn't returnthe projectID but the projectNumber see

References

b/275607440

@edwardmedia edwardmedia self-assigned this Nov 14, 2022
@edwardmedia
Copy link
Contributor

@martinOrigin8Cares I think below is by design. Why do you think it should not?

When the argument project of the provider is set, it override the value coming from the API.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#project

@csimard01
Copy link

@martinOrigin8Cares I think below is by design. Why do you think it should not?

When the argument project of the provider is set, it override the value coming from the API.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#project

That will make the bucket data the only reousource data returning the project provider instead of the project where the bucket is. It make no sense.

@martinOrigin8Cares
Copy link
Author

I was sure the concept behind the "data.resrouce" was to represent the "real" object (and all it's arguments/attributes) that exist in GCP. PLeaselet me know if I didn,t undetstand correctly.

@slevenick
Copy link
Collaborator

Do you have the HTTP request/responses from using Terraform to fetch this resource? I wonder how we are using the project in the request

@edwardmedia edwardmedia added the persistent-bug Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work label Nov 25, 2022
@edwardmedia edwardmedia removed their assignment Nov 25, 2022
@rileykarson rileykarson removed the bug label Mar 6, 2023
@rileykarson rileykarson added this to the Goals milestone Mar 20, 2023
@devodev
Copy link

devodev commented Nov 8, 2023

@martinOrigin8Cares I think below is by design. Why do you think it should not?

When the argument project of the provider is set, it override the value coming from the API.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#project

I've just hit that today and this is definitely a bug.
Using version 4.84 BTW, might be fixed upstream in 5+, haven't checked yet.

For example, I have a use-case where I want to find the project of a bucket using this datasource.
The bucket might be in the current project, but it could also be a different one.
If I comment-out the project_id set on the provider, I get the correct value, otherwise I get my current project.

To me, this makes no sense. the project attribute on a bucket resource should match the bucket real project attribute from upstream, not the project from the current Terraform provider value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forward/linked persistent-bug Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work service/storage size/s
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants