Question

Difficulty: MediumCreating Billing Budgets, Alerts, and BigQuery Exports

A financial startup wants to enforce programmatic cost control for a non-critical development project. If the monthly project expenses cross $5,000, running Compute Engine virtual machine instances in that project must be automatically shut down to prevent unexpected charges. Which Google Cloud solution correctly satisfies this operational requirement?

  1. Configure a Cloud Billing budget threshold rule, publish programmatic notifications to a Cloud Pub/Sub topic, and deploy a Cloud Function subscribed to that topic that calls the Compute Engine API to stop running instances.Answer
  2. B
    Configure a Cloud Billing budget with a $5,000 threshold and select the default automatic resource termination checkbox within the Billing budget settings console.
  3. C
    Configure a Cloud Billing budget connected to Pub/Sub, and grant the Billing Account Viewer role to the project service account so it can execute compute.instances.stop across all projects.
  4. D
    Enable the Cloud Billing API in the organization host project, set up budget alert notifications, and configure API quota limits to automatically revoke Compute Engine API access when budget limits are met.

Answer

Configure a Cloud Billing budget threshold rule, publish programmatic notifications to a Cloud Pub/Sub topic, and deploy a Cloud Function subscribed to that topic that calls the Compute Engine API to stop running instances.
Google Cloud Billing budget alerts do not restrict or stop resource usage by default. To enforce automated actions (such as stopping Compute Engine VM instances when cost thresholds are breached), you must configure the budget to send programmatic notifications to a Cloud Pub/Sub topic and use a serverless component (like Cloud Functions or Cloud Run) to parse the notification and invoke the Compute Engine API to stop instances.

Step-by-Step Solution

1
Create a budget and define threshold rules in Cloud Billing.
A budget alert is generated whenever project expenditures reach the specified percentage or fixed amount ($5,000).
Budgets track current spending against defined cost ceilings.
2
Link the budget to a Cloud Pub/Sub topic under programmatic notification settings.
Billing notification payloads are published to the specified Pub/Sub topic upon reaching threshold events.
Pub/Sub allows downstream serverless components to receive billing alert events automatically.
3
Create a Cloud Function triggered by the Pub/Sub topic to execute the Compute Engine API instance stopping code.
Running instances in the target project are programmatically stopped when the budget threshold message is processed.
Billing alerts are purely informative and require custom code/serverless functions to enforce automated resource capping.

Key Concept

Cloud Billing Budgets and Automated Remediation via Pub/Sub
Rate this question