# The GCP budget notification sent to the wrong topic

This lab creates a real Compute Engine VM, boot disk, two Pub/Sub topics, a
subscription and a project-scoped Cloud Billing budget. Review pricing and
quotas first: these resources and operations can incur charges. Use a
dedicated, billing-enabled **non-production** project. The VM has no external
IP or service account. Stopping it does not delete its disk or stop all costs.
A budget is not a spending cap, and cost data and notifications can be delayed.

Install Bash, Python 3 and the Google Cloud CLI. Sign in with `gcloud auth
login`. Your identity must be able to manage Compute Engine and Pub/Sub
resources in the project and budgets on its billing account. Compute Engine,
Pub/Sub and Cloud Billing Budget APIs must already be enabled, and a default
VPC and subnet must exist in the chosen zone. Check pricing and permissions.

```sh
export GOOGLE_CLOUD_PROJECT="your-dedicated-project-id"
export GOOGLE_CLOUD_BILLING_ACCOUNT="your-billing-account-id"
./setup.sh "$GOOGLE_CLOUD_PROJECT" "$GOOGLE_CLOUD_BILLING_ACCOUNT" us-central1-a --accept-costs
./lab.sh inspect
```

Inspect the live budget, topics and subscription. Repair the lab budget's
route using Google Cloud tools while keeping its project filter, amount and
other notification settings unchanged. Do not edit other budgets.
If the installed `gcloud billing budgets update` crashes, use the Cloud Billing
console or Billing Budget API instead.

```sh
./verify.sh
./teardown.sh
```

Verification publishes a **synthetic** over-budget message to the budget's
configured topic, pulls it from the lab subscription, and stops only the
identified lab VM. It does not test real billing data, Google-generated
notifications or a deployed automatic responder. The lab does not disable
project billing. Never use this local demonstration as a production spending
guard. The related opsbreakfix.com article covers Azure, not GCP.

Setup records unique resource identities in a private `.lab-state` directory.
Keep this state after a failure so teardown can recover. Teardown only removes
the recorded lab resources and never deletes a project or billing account.
Inspect Google Cloud for residual resources and charges after cleanup; remove
local state only after confirming the resources are gone.
