DevOps Peach

GCP Basics · Foundations – Regions, Resource Hierarchy, gcloud and Billing · Lesson 4 of 5

Billing Accounts, Budgets and Labels

Projects are paid through a Cloud Billing account; budgets send alerts (they do not cap spending), labels split costs, and the BigQuery billing export gives you detailed data.

Practice interactively →

A Cloud Billing account pays for one or more projects. A project without an active billing account cannot use paid services.

flowchart LR
  BA["Cloud Billing account"] --> P1["Project dl-shop-prod"]
  BA --> P2["Project dl-shop-dev"]
  BA --> B["Budget 500 USD / month"]
  B --> N["Alert email and Pub/Sub at 50 / 90 / 100%"]
  BA --> X["Billing export to BigQuery"]
  X --> D["Cost report by label env, team"]
  %% step BA: A Cloud Billing account holds the payment method and is linked to projects.
  %% step P1: Each project is linked to exactly one billing account at a time.
  %% step B: A budget watches actual or forecast spend for the account, projects or labels.
  %% step N: Thresholds send emails and optional Pub/Sub messages; a budget never stops resources by itself.
  %% step X: The export streams detailed usage and cost rows into a BigQuery dataset.
  %% step D: Labels such as env and team let you group the exported costs in reports.

Billing roles

Role Can
Billing Account Administrator Manage the account, payment, link/unlink projects
Billing Account User Link projects to this account (with Project Billing Manager or Owner on the project)
Billing Account Viewer Read costs and invoices
Project Billing Manager Link/unlink one project, without seeing the account’s money

To link a project you need rights on both sides: the billing account and the project.

Budgets and alerts

Labels vs tags

Labels Tags
Format key=value on a resource Tag key/value resources defined at org/project level
Purpose Cost breakdown, filtering, automation Conditional IAM and firewall policies
Inherited? No Yes, down the hierarchy

Use a small, enforced label set, for example env, team, app, cost-center. Labels appear in the billing export, so SELECT labels ... SUM(cost) gives cost per team.

Saving money

Command Meaning
gcloud billing accounts list Billing accounts you can see
gcloud billing projects link dl-lab-dev --billing-account=01A2B3-C4D5E6-F7A8B9 Link a project
gcloud billing budgets create --billing-account=… --display-name=… --budget-amount=500USD Create a budget

Traps: a budget does not cap costs; labels are not inherited by child resources; unlinking billing stops paid resources and can lead to data deletion.

Practice interactively →