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 https://www.youtube.com/watch?v=KiTg8RPpGG4 together with GitHub repo here: https://github.com/aioverlords/Google-Cloud-Platform-Killswitch

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(res);
console.log("Billing Disabled");
return `Billing disabled: ${JSON.stringify(res.data)}`;
};

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *