Question

Difficulty: MediumCreating Billing Budgets, Alerts, and BigQuery Exports

A DevOps engineer needs to prevent unexpected cost overruns in a development environment. The engineering lead requests that when monthly spend reaches $5,000, all non-essential Compute Engine instances in the project must immediately stop. The engineer plans to configure a Cloud Billing budget threshold at 100%. Which configuration approach will achieve this automated outcome?

  1. Connect the Cloud Billing budget to a Cloud Pub/Sub topic and deploy a Cloud Function that processes the budget notification to programmatically stop the VM instances.Answer
  2. B
    Enable the 'Auto-Cap Billing' checkbox within the Cloud Billing budget threshold settings to automatically stop Compute Engine instances when spend hits 100%.
  3. C
    Assign the Project Owner IAM role on the target project to the Cloud Billing account to enable automatic resource shutdown when the budget is breached.
  4. D
    Enable the Cloud Billing API inside the consumer workload project to activate default automatic Compute Engine VM termination rules.

Answer

Connect the Cloud Billing budget to a Cloud Pub/Sub topic and deploy a Cloud Function that processes the budget notification to programmatically stop the VM instances.
Cloud Billing budgets provide visibility into spending by sending threshold notification emails and publishing messages to Cloud Pub/Sub topics. Because budgets do not automatically shut down GCP services or stop billing, achieving automated resource shutdown requires linking the budget to a Cloud Pub/Sub topic and implementing a Cloud Function (or Cloud Run service) to programmatically stop Compute Engine VM instances upon receiving an over-budget message payload.

Step-by-Step Solution

1
Understand Cloud Billing budget capabilities
Recognize that Cloud Billing budgets are alerting mechanisms that generate emails or Pub/Sub messages, but do not natively restrict or shut down GCP resources.
Google Cloud prevents unexpected workload termination by keeping budget alerts informational by default.
2
Design automated remediation architecture
Link the billing budget to a Cloud Pub/Sub topic so JSON notifications are published asynchronously when threshold percentages are breached.
Pub/Sub acts as the event bus for budget status payload messages.
3
Implement programmatic shutdown logic
Subscribe a Cloud Function or Cloud Run service to the Pub/Sub topic to parse the cost payload and call the Compute Engine API to stop target VM instances when spend reaches 100%.
Custom code execution is required to perform operational actions like stopping instances or disabling billing.

Key Concept

Cloud Billing budgets do not automatically shut down resources or disable billing; automated enforcement requires connecting budget alerts to Cloud Pub/Sub and triggering serverless code (Cloud Functions/Cloud Run) to modify infrastructure state.
Rate this question