-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 attributes for gcs backend to specify an existing bucket in another project #6117
Comments
Hi We do this at work alot where the state bucket is in a separate project to the provider project but the 403 happens because you don't have the correct roles on the state bucket. Terraform executes in Go the following:
Remember 403 is an issue with permissions where as 404 refers to not found. You will need to have Object Admin on the state bucket. https://cloud.google.com/storage/docs/json_api/v1/status-codes |
I think @upodroid is right here. In addition, the gcs backend is actually part of the https://github.com/hashicorp/terraform repo, not the provider one. I'm going to go ahead and close this out- if the comments around checking permissions don't work, I'd recommend trying to file an issue there. |
No, the 403 is not related to the bucket. Project B is not spun up yet. When I spin it up without specifying any terraform backend everything is ok state is stored locally, project B gets up with setting specified in provider. However, as soon as I add a gcs backend:
So the project itself specified in provider which does not exist yet, not an existing bucket send me 403. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Description
Fairly simple scenario. I have tf configuration which I am going to use to create a project B from scratch. However, I want to store the state of that new project and all config in a gcs bucket in project A which have existed beforehand.
It seems like once upon the time backend config for gcs could include project and region. It seems to no longer be the case.
The project data seems to be fetched from provider block that looks like so:
Now this is a problem, because all of my terraform resources use this config to create things in B including B itself. However for some reason provider also decides it's a good idea to store state there. But that bucket doesn't even exist in B at this point yet. Therefore, terraform errors out with a 403.
What are my options here? I've read through terraform docs and there is not a hint from what I've seen on how to force a specific provider configuration onto my backend.
New or Affected Resource(s)
Potential Terraform Configuration
Given above
References
The text was updated successfully, but these errors were encountered: