Soru

Zorluk: Çok zorCreating Billing Budgets, Alerts, and BigQuery Exports

A site reliability engineering team needs to enforce automated cost controls that disable billing or stop project resources when a project exceeds $10,000 in monthly spending. What is the correct sequence of steps required to configure programmatic budget notifications using Google Cloud services?

  1. 1Create a Cloud Pub/Sub topic in the administration project to act as the message channel for budget notifications.
  2. 2Deploy a Cloud Function configured with an Eventarc or Pub/Sub trigger attached to the created topic to execute automated resource shutdown logic.
  3. 3Navigate to Cloud Billing > Budgets & Alerts and create a new budget scoped to the target project with a $10,000 target amount.
  4. 4Under the budget's actions settings, enable 'Connect a Pub/Sub topic to this budget' and select the created topic.

Cevap

The correct sequence is: first create the Cloud Pub/Sub topic, second deploy the Cloud Function subscribed to that Pub/Sub topic, third create the Cloud Billing budget scoped to the project, and fourth connect the Pub/Sub topic under the budget's programmatic notification settings.
To build an automated budget capping system, the messaging endpoint (Cloud Pub/Sub topic) must be created first. Next, the serverless handler (Cloud Function) is deployed and configured to trigger on messages from that Pub/Sub topic. Then, the Cloud Billing budget is created with the desired spending limits. Finally, the Pub/Sub topic is linked to the budget under the manage notification actions, establishing the workflow where budget threshold events trigger automated code execution.

Adım Adım Çözüm

1
Provision Pub/Sub infrastructure
A Cloud Pub/Sub topic exists to capture budget alert events.
Pub/Sub acts as the decoupled messaging bus between Cloud Billing and automated remediation logic.
2
Deploy programmatic consumer service
A Cloud Function with Cloud IAM permissions to manage project billing or stop instances is deployed and listening to the Pub/Sub topic.
The handler code must be active and bound to the topic before alert messages start publishing.
3
Define budget rule in Cloud Billing
A budget rule with specific monetary amounts ($10,000) and threshold percentages is established.
Establishes the financial boundary and triggers that send alert notifications.
4
Attach Pub/Sub notification action to budget
Cloud Billing streams JSON notification payloads to the topic when spending thresholds are breached.
Connects the financial threshold monitoring to the automated programmatic handler.

Anahtar Kavram

Cloud Billing Budgets do not automatically cap spending by default; automated enforcement requires linking a Cloud Billing budget to a Cloud Pub/Sub topic, which triggers serverless logic (such as a Cloud Function or Cloud Run service) to cap resources programmatically.
Bu soruyu puanla