google-cloud-platformterraformterraform-provider-gcp

missing permission on "billingAccounts/XXXXXXXXXXXXXXXXXXXXXXXX": billing.resourceAssociations.create Terraform (GCP)


I tried to automate the Shared VPC creation on GCP by using Terraform. I have enabled all the access to my service account (Org Admin, XpnAdmin, Storage Admin, Compute admin, Billing Admin)

But when i executed terraform apply it's throwing me following error:

missing permission on "billingAccounts/CXXXXXXXXXXXXXXXXXX": billing.resourceAssociations.create

I'm referring the Google provider Github code for this demo.


Solution

  • It's quite likely you have the billing admin, but you also need the ability to create billing assignments, or "Billing Project Manager".

    https://cloud.google.com/billing/v1/how-tos/access-control

    billing.resourceAssociations.create AND resourcemanager.projects.createBillingAssignment on the Cloud Billing account.

    There's some handy code to bootstrap a service account - Google Project Factory - You might want to have a look at that. Once that SA is created you shouldn't have permissions issues