Skip to content
Visual explainer 2h 30m to learn 5 steps

Set up a Google Cloud lab project with budgets and labels

Create a lab project with billing, a budget alert, enabled APIs, labels and known quotas, and delete it in one step.

By Invicly Tech, , in Google Cloud Engineering and Services. About 11 minutes to read.

Topic 2 of 32

In short

A safe lab project is small, labelled, linked to billing, watched by a budget alert and easy to delete in one command. You turn on only the APIs you need and check the quotas that matter before you build. A budget alert only warns you; it does not stop spending, so deleting the project is your real off switch.

Think of it like this: A lab project is like a rented storage unit with a meter: you label it, set a reminder when the bill reaches a threshold, and hand back the key when you are done.

Explained simply

Before you build anything, set up a place to build it safely. In Google Cloud that place is a project. Give it a clear ID such as orders-lab-4821, add labels such as env=lab and owner=ana, and link it to a billing account so paid services can run.

Next, add a budget. A budget is a spend target with alerts. By default Google suggests emails at 50, 90 and 100 percent of the amount. The important catch: a normal budget only warns you. It does not stop your services or your charges.

Then switch on only the services the lab needs. Each Google Cloud service has an API, such as run.googleapis.com for Cloud Run, and it must be enabled in the project before you can use it. Keeping the list short makes the project easier to understand and safer.

Every project has quotas, which are limits on things like CPUs per region or requests per minute. Check them before a lab so you are not surprised halfway through. Some can be raised by request.

When the lab ends, delete the whole project. That one command shuts down every resource inside it and stops their charges. You have about 30 days to change your mind and restore it.

Press Play on a diagram to walk through it one step at a time.

FlowLab project lifecycle
  1. 1
    Create project

    Unique ID, labels, under a folder if you have one

  2. 2
    Link billing

    Attach a billing account or free trial

  3. 3
    Add budget

    Alerts at 50, 90 and 100 percent

  4. 4
    Enable APIs

    Only the services the lab uses

  5. 5
    Build and test

    Check quotas first

  6. 6
    Delete project

    Shut down everything in one step

LayersLayers of cost protection, weakest to strongest
  1. 1
    Budget email

    Tells you; changes nothing

  2. 2
    Pub/Sub budget notification

    Lets code react, such as scaling down

  3. 3
    Spend cap on an eligible service

    Pauses new usage of one service in one project

  4. 4
    Deleting the project

    Stops all resources and charges

In depth

Billing accounts, the free trial and the free tier

A billing account pays for projects. One billing account can pay for many projects, but a project links to only one billing account at a time. Linking needs the Billing Account User role on the account and permission on the project.

New customers are usually offered a free trial with credit for a limited time, and some products have an always-free usage tier with monthly limits. Check the current terms on the Google Cloud free programme page, because amounts and eligible products change. Free-tier limits are per billing account, not per project, and usage beyond them is charged.

If you cannot add a payment method, you can still learn most of this module through the console tour, the docs and local tools such as the Pub/Sub emulator and the gcloud CLI help pages, and write your commands as a design-only plan.

  • One project links to one billing account
  • Linking needs Billing Account User on the account
  • Free-tier limits apply per billing account
  • No billing: use emulators and design-only plans

Budgets: what they do and what they do not do

A budget lives on the billing account and can be scoped to projects, services or labels. Threshold rules fire on actual spend or forecasted spend. By default, emails go to billing administrators and users of the billing account. You can also send alerts to Cloud Monitoring notification channels or a Pub/Sub topic.

An alerts-only budget never stops usage. Billing data can also lag by hours, so a runaway workload can pass the threshold before you hear about it. For real protection, combine three habits: small budgets per lab, the Pub/Sub notification wired to an automated response if you need one, and deleting projects promptly. Google also offers spend cap budgets, which pause new usage of one eligible service, such as Cloud Run or the Gemini API, in one project when estimated costs pass the target. They still do not stop persistent resources such as disks and VMs, so read the current eligible list before relying on them.

SequenceHow a budget alert reaches you
Project usage
Cloud Billing
Budget
You
  1. 1Usage is metered and costed
    Project usage to Cloud Billing: Usage is metered and costed
  2. 2Spend compared with thresholds
    Cloud Billing to Budget: Spend compared with thresholds
  3. 3Email at 50 percent
    Budget to You: Email at 50 percent
  4. 4Email at 90 and 100 percent
    Budget to You: Email at 90 and 100 percent
  5. 5You scale down or delete the project
    You to Project usage: You scale down or delete the project

APIs, labels and quotas

Enabling an API turns on a service for one project. Use gcloud services enable with the service name and check with gcloud services list --enabled. Disabling an API later may fail or need extra flags if resources still depend on it, which is one more reason to delete the whole lab project instead.

Labels are key=value pairs. Keys and values use lowercase letters, digits, underscores and dashes, each up to 63 characters, with up to 64 labels per resource. Labels on resources are exported with billing data, so env=lab or app=orders lets you split costs later. Labels cannot drive IAM conditions; tags are the separate feature for that.

Quotas cap usage per project, region or minute. View them on the Quotas and system limits page in the console, or with gcloud beta quotas info list for a given service. Read the limit and current usage before a lab that needs many CPUs or IP addresses.

  • gcloud services enable run.googleapis.com
  • gcloud services list --enabled
  • Label format: lowercase, 63 characters max, 64 per resource
  • Labels for cost reports; tags for policy conditions

Cleanup scope: shut down versus delete one resource

Deleting a project with gcloud projects delete marks it for deletion and shuts it down. Billing for its resources stops, its APIs stop answering and its resources become unreachable. For about 30 days you can restore it with gcloud projects undelete; after that it is removed for good, and its project ID can never be reused.

Deleting single resources is finer-grained but easy to get wrong. A forgotten static IP address, disk snapshot or BigQuery table keeps charging. If you must keep the project, list resources by label after cleanup, or search with Cloud Asset Inventory, to prove nothing is left. Soft-deleted projects count towards your project quota until they are fully removed, so create fewer, longer-named lab projects rather than dozens of throwaway ones.

Learn it in 5 short steps

About 30m each. Track them with a timer in your plan.

  1. 1
    Create and link a project to billing~30m
  2. 2
    Set a budget with alert thresholds~30m
  3. 3
    Enable only the APIs you need~30m
  4. 4
    Label resources consistently~30m
  5. 5
    Check quotas and shut down the project~30m

Key points

  • A project ID is 6 to 30 characters, lowercase letters, digits and hyphens, and can never be changed or reused.
  • Alerts-only budgets send emails at thresholds; they do not cap usage or shut anything down.
  • Enable APIs one by one with gcloud services enable so you know exactly what the project can do.
  • Labels such as env=lab and owner=ana flow into billing data so you can filter costs by them.
  • gcloud projects delete shuts the project down; it can be restored for about 30 days, then it is gone for good.

Key terms

Tap a card to flip it. 0/5 known

Examples

bash
PROJECT=orders-lab-4821
gcloud projects create $PROJECT --labels=env=lab,owner=ana
gcloud billing projects link $PROJECT --billing-account=000000-AAAAAA-BBBBBB
gcloud billing budgets create --billing-account=000000-AAAAAA-BBBBBB \
  --display-name="orders-lab cap" --budget-amount=10USD \
  --filter-projects=projects/$PROJECT \
  --threshold-rule=percent=0.5 --threshold-rule=percent=0.9 --threshold-rule=percent=1.0
gcloud services enable run.googleapis.com storage.googleapis.com --project=$PROJECT
# when finished
gcloud projects delete $PROJECT

Create, fund, watch and later delete a lab project (placeholder billing account ID).

Set up the orders lab project from Cloud Shell

Prerequisites: a billing account ID and permission to create projects. Step 1: create the project with labels. Step 2: link billing. Step 3: add a 10 USD budget scoped to this project. Step 4: enable two APIs. Expected evidence: gcloud billing projects describe shows billingEnabled: true, and the enabled list shows run and storage. Cleanup is one delete command.

bash
P=orders-lab-4821; B=000000-AAAAAA-BBBBBB
gcloud projects create $P --labels=env=lab,owner=ana,app=orders
gcloud billing projects link $P --billing-account=$B
gcloud billing budgets create --billing-account=$B \
  --display-name="$P budget" --budget-amount=10USD \
  --filter-projects=projects/$P --threshold-rule=percent=0.5 \
  --threshold-rule=percent=0.9 --threshold-rule=percent=1.0
gcloud services enable run.googleapis.com storage.googleapis.com --project=$P
gcloud billing projects describe $P
gcloud services list --enabled --project=$P

Check a quota before a lab

A lab will start a managed instance group with eight small VMs in europe-west2. Step 1: list the regional CPU quota and current usage. Step 2: compare the limit with eight times the CPUs per VM. Step 3: if the limit is lower, use fewer VMs or request an increase and wait for approval. Expected evidence: the CPUS line shows a limit above what you need.

bash
gcloud compute regions describe europe-west2 \
  --project=orders-lab-4821 \
  --format="table(quotas.metric,quotas.limit,quotas.usage)" \
  --flatten=quotas | grep -E "CPUS|IN_USE_ADDRESSES"

Quick reference

  • gcloud projects create ID --labels=env=lab,owner=NAME
  • gcloud billing projects link ID --billing-account=XXXXXX-XXXXXX-XXXXXX
  • Budgets alert at thresholds; alerts-only budgets never stop spending
  • gcloud services enable SERVICE.googleapis.com; check with services list --enabled
  • Project ID: 6 to 30 chars, lowercase, digits, hyphens; permanent and never reused
  • gcloud projects delete ID, then about 30 days to undelete
  • Labels show up in billing data; use the same keys everywhere

Common mistakes

  • Believing a budget stops charges. Alerts-only budgets only notify; delete the project or act on the alert.
  • Running labs in a long-lived shared project, so cleanup means hunting resources one by one.
  • Enabling every API up front, which widens what a leaked credential could do.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1Your lab budget of 10 USD reaches 100 percent. What happens to your Compute Engine VM?

Question 2

2What is the fastest way to stop every charge from a finished lab?

Question 3

3Which label is valid?

Question 4

4You deleted a project by mistake 10 days ago. What can you do?

Question 5

5Why enable only the APIs a lab needs?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Write the command that creates a project called shop-lab-1234 with labels env=lab and owner=sam.

  2. Exercise 2medium

    Create a 5 USD budget for one project that alerts at 50 percent actual and 100 percent forecasted spend.

  3. Exercise 3hard

    Write a teardown checklist that proves the lab is gone and nothing else is still charging.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Can I set a hard spending limit on my whole account?
Not across all services. Alerts-only budgets just notify, and spend cap budgets cover only some services in one project. Deleting the project, or acting on a Pub/Sub budget notification, is the dependable stop.
Does enabling an API cost money?
No. You pay for usage of the service, not for turning it on.
Why can't I reuse my project ID after deleting it?
Project IDs are unique forever, including deleted ones. Add a short random suffix to lab IDs.

Go deeper

ShareXLinkedInWhatsApp