Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to enable billing from google cloud cli?

I am trying to automate some Google Cloud Functions deployment and after creating a project using the cli with the command:

gcloud projects create testing-project-creation-b0d5 --name=testing-project-creation --organization=ORG_ID --billing-project=BILLING_PROJECT_NAME --enable-cloud-apis --quiet

The billing is not enabled, so I am trying to run this other command:

gcloud alpha billing projects link testing-project-creation-b0d5 --billing-account BILLING_ACCOUNT_ID --quiet

But I am getting the error:

ERROR: (gcloud.alpha.billing.projects.link) User [SERVICE_ACCOUNT@PROJECT.iam.gserviceaccount.com] does not have permission to access projects instance [testing-project-creation-b0d5] (or it may not exist): Cloud Billing API has not been used in project PROJECT_ID before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudbilling.googleapis.com/overview?project=PROJECT_... then retry.

I am pretty sure that the service account I am using has the correct permissions both at the organization level, billing account and project.

0 1 4,341
1 REPLY 1

Hi Iam Abdullah  i tell you how to enable Google Cloud CLI

To enable billing from Google Cloud CLI, follow these steps:

Open the Cloud Console Billing page.

Select the project that you want to enable billing for.

If you haven't already created a billing account, create one by clicking on the "Create Billing Account" button and following the prompts.

Once you have a billing account, navigate back to the project you want to enable billing for.

Open the Cloud Console.

Click the Activate Cloud Shell button in the top right corner to open a terminal window.

In the terminal window, enter the following command:

gcloud alpha billing projects link [PROJECT_ID] --billing-account=[BILLING_ACCOUNT_ID]

Replace [PROJECT_ID] with the project ID you want to enable billing for, and replace [BILLING_ACCOUNT_ID] with the ID of the billing account you created in step 3.

Press Enter to execute the command.

You should now see the message "billingAccountName" set to your billing account ID.

That's it! Billing is now enabled for your project in Google Cloud CLI.

I also Offers tools

SEO Tools Group Buy

Ahrefs Group Buy