-
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
Unable to link Project with Billing Account #5733
Comments
@streetmapp Can you please try making that svc account user as "Billing Account User" & "Project Creator" at the Org level (only at the Org level) and run your config. The service account will come as just owner for the project after it gets created. sample config
I am able to create a project and assign the billing account. Please let me know if it helped |
So I just tried this out, using your sample config, and I got the same error as I mentioned on my initial report. Can confirm that my service account in use at the Org level ONLY has "Billing Account User" & "Project Creator" set. |
I also tried the gcloud SDK method of linking a billing account, and this failed due to permissions as well. |
I am attaching the plan and apply output and also screen shot of my svc account access privileges of both Org and Project level. Please cross verify it again with my settings with yours. Also can you verify that by changing the org level permission to
|
Using |
It has to do with the roles you setup for your service account. As you get the same error from gcloud as well, i don't see any issues with terraform/provider. Once you get the gcloud working (project creation with billing account) the above given config can be used with terraform. Please ping us back if it fails in terraform and works fine in gcloud. |
I followed from the GCP/Slack channel to here. I have a similar error. I have Terraform config file to provision a new project with gcp services. I have Terraform admin service account at an Org. level role Billing Account User and Project Creator. At project level I have custom roles, owner, and storage admin. When I have TerraForm apply, I get this error Double-Checking: the service account that need the permissions of roles is the TerraForm admin service account and not the service account within the project? right or does the service account within the new provision project need to that the org/project roles and permissions? |
I have testing this will be variations, At organization level projects creator and billing account user needs to be assigned to custom service account. I'm in the process of cloud build provisions tf config files. However, cloudbuild doesn't allow permissions to be granted at project level for project creator. Cloud build doesn't allow using external service account either. |
I did a final test. I was creating automation for the TerraForm provisioning GCP project and services. I found upon my research that for now, we will need to have a cloud build default service account (at org_level) that must have billing account user and project creator for cloud build to execute TerraForm config file to provision GCP projects from Terraform admin project. Thus, you could supplement the service account in cloudbuild.yaml with using secret but then this opens up, a new risk of vulnerabilities on top of having a cloud build service account already having organizational permission. I could supplement my writing on GitHub or stack flow to subdue the outcome of my research. |
I was having a similar issue, where I couldn't create projects. I was nearly about to give up, and I came across a Terraform module (https://github.com/terraform-google-modules/terraform-google-project-factory) that had slightly different permissions. I removed everything that I had previously added using the above mentioned guide (including the .terraform folder) and added the permissions recommended there. Admittedly, I'm just getting started with GCP, so I'm not entirely sure all of those are needed, but something there did the trick :) Hope that helps! |
As is this looks like a problem with getting permissions correct and not necessarily a bug with the provider. Please let me know if I'm missing something. In terms of getting the permissions set correctly you will need to give the service account that is being used by Terraform permission to modify the billing account in question. The IAM permissions for the billing account are configured in a different part of the UI than the project and organization level IAM permissions. Instead of being under the IAM part of the sidebar they are configured under the Billing section. https://support.google.com/cloud/answer/7283646?hl=en has a bit more detail. Also the IAM docs have a pretty good article on understanding roles: https://cloud.google.com/iam/docs/understanding-roles#billing-roles |
If you think the tutorial could be improved you are welcome to open a PR that improves it. The source for the tutorial is at https://github.com/GoogleCloudPlatform/community/tree/master/tutorials/managing-gcp-projects-with-terraform. Or feel free to open up an issue against that repo and see if the author will update. |
I had this same issue and it turned out that it was a project quota limit - it seems you are limited to 5 projects that can be linked to a billing account by default. You only get told this if you try to link the project to a billing account in the console. It would be great if you could update the provider to give the correct error information too. |
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
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 tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v0.12.20
Affected Resource(s)
Terraform Configuration Files
Debug Output
https://gist.github.com/streetmapp/8999b6e941fe26f965ee1ff88e7d4bef
Panic Output
No Panic
Expected Behavior
I would have expected that my terraform would have created the project and associated it with my organization and set the billing account for the project.
Actual Behavior
The project is created, associated with my organization, but it fails to apply the billing account.
Error received:
Steps to Reproduce
I have been following this guide for the purpose of having a central GCP project from which I can manage terraform from.
https://cloud.google.com/community/tutorials/managing-gcp-projects-with-terraform
My service account for this has
Project Billing Manager
andBilling Account User
roles at the Org level andProject Billing Manager
at the newly created project level. Both of which I would think would be sufficient for the task at hand.References
The text was updated successfully, but these errors were encountered: