Question

Difficulty: Very hardCreating Billing Budgets, Alerts, and BigQuery Exports

An organization wants to automatically stop running Compute Engine instances in a specific Google Cloud project whenever project spending exceeds 100% of its designated monthly budget limit. You need to design an automated cost-control workflow while accounting for GCP billing budget capabilities and limitations. Which implementation strategy should you choose?

  1. Configure the Cloud Billing budget to publish alert notifications to a Cloud Pub/Sub topic, subscribe a Cloud Function that executes Compute Engine stop API calls upon receiving budget messages, and account for eventual consistency since billing data processing includes an inherent reporting latency.Answer
  2. B
    Enable the direct resource termination toggle under the Cloud Billing Budget threshold rules configuration tab, specifying the compute project ID and selecting automatic instance termination upon hitting the 100% threshold.
  3. C
    Grant the Project Editor role to the Billing Account administrator, enable automatic spending caps on the Billing Account settings page, and configure budget alert emails to trigger automatic instance caps via Google Cloud Support.
  4. D
    Configure standard BigQuery billing export in the target compute project, enable the Cloud Billing API in that same project, and set up a BigQuery event trigger to directly stop Compute Engine instances in real time when cumulative cost rows exceed the threshold.

Answer

Publish Cloud Billing budget alert notifications to a Cloud Pub/Sub topic, subscribe a Cloud Function to execute Compute Engine stop API calls upon notification, and account for reporting latency.
The correct strategy requires recognizing that Google Cloud billing budgets do not natively stop resources or cap costs. To achieve automated cost control, budget alerts must publish messages to a Cloud Pub/Sub topic, which triggers a serverless function (such as Cloud Functions) to invoke Compute Engine APIs to halt running instances. Additionally, billing data processing involves inherent latency, so automated remediation is asynchronously executed rather than instantaneous.

Step-by-Step Solution

1
Identify billing budget notification limits
Recognize that GCP billing budgets only generate notifications and do not automatically stop running resources or cap spending.
GCP Cloud Billing budgets are informational alerting tools rather than automated resource governors.
2
Connect programmatic alerting mechanisms
Attach a Cloud Pub/Sub topic to the Cloud Billing budget to receive JSON notification payloads when spending threshold percentages are crossed.
Pub/Sub serves as the event bus between billing threshold events and downstream programmatic remediation scripts.
3
Implement programmatic resource management
Deploy a Cloud Function or Cloud Run service triggered by the Pub/Sub topic to call Compute Engine APIs and stop instance workloads.
Custom code is required to translate the notification event into active GCP infrastructure modifications.
4
Factor in billing telemetry latency
Acknowledge that billing metrics and cost processing incur a delay (typically a few hours), meaning automated actions mitigate overruns rather than providing hard real-time caps.
Billing data processing is asynchronously batch-aggregated across Google Cloud infrastructure.

Key Concept

Automated Budget Notification Handling via Pub/Sub and Cloud Functions
Rate this question