GCP Budget API Beta Released
Google Cloud introduced the Billing Budget API, making it possible to manage cost guardrails programmatically instead of through the console.
Terraform Example
Terraform gained beta support alongside the API release:
data "google_billing_account" "account" {
provider = google-beta
billing_account = "000000-0000000-0000000-000000"
}
resource "google_billing_budget" "budget" {
provider = google-beta
billing_account = data.google_billing_account.account.id
display_name = "Example Billing Budget"
amount {
specified_amount {
currency_code = "USD"
units = "100000"
}
}
threshold_rules {
threshold_percent = 0.5
}
}
Why It Matters
- Enforce budgets as code across environments.
- Trigger automated notifications or shutdown workflows when thresholds are breached.
- Eliminate manual console steps during project onboarding.
Next Steps
- Combine the API with Pub/Sub budget alerts for automated remediation.
- Version-control budget definitions and review them like any other infrastructure change.
- Monitor GA announcements; beta APIs may change and require updates to Terraform providers.