Skip to content

Setting billing cap on Google Cloud Platform

You can setup pricing alerts on GCP in the Budgets & alerts but there seems to be no way to set hard billing cap. Meaning, if your spending reaches x amount the service(s) just stops.

Fortunately Youtuber called Data Slayer has created nice YouTube tutorial here together with GitHub repo here:

You can combine budget pub/sub alerts with a cloud function that can disable billing on your entire account if a threshold is met.

In shot

const _disableBillingForProject = async projectName => {
const res = await billing.updateBillingInfo({
    name: projectName,
    resource: {
        billingAccountName: ''
    }, // Disable billing
console.log("Billing Disabled");
return `Billing disabled: ${JSON.stringify(}`;

Published inUncategorized