Google Cloud Kill Switch Gen 2

December 3, 2024

A simple Cloud Run Gen 2 function, triggered by a Pub/Sub message, disables billing for a project.

This is helpful for tight budgets to prevent exceeding them. Note that budget alerts are not immediate, so there may be a delay between billing and alert delivery.

GitHub Repository

Set up

  • Git, node and npm installed. (Already available on cloud shell terminal)
  • Cloud Billing API enabled. API
  • A Budget alert connected to a Pub/Sub topic. DOCS
  • default service account for Compute Engine with role Billing Account Administrator.
    • Or create your own service account for the function.