how to sleep well
while running gcp services
or how to stop runaway GCP costs


Update (09.06.2024):


the correct way to do this is to set up Budgets / API limits. This is quite hidden and requires you to submit a request form. When I tested it, it was granted immediately. I'd guess this happens when requesting lower limits instead of higher than default limitations.


Update (23.10.2023):


I've had this check in place and it didn't work lol


At least the bill was only 30€ but it changed my perspective.


The issue was that the pubsub topic wasn't triggered. I don't know why, in testing it worked. It might have to do with the way the resource calculated the cost but I don't care any more. I've come to the conclusion that the only way to keep costs in check is to know wtf you are doing when setting up resources. This is a shitty way but as long as google doesn't implement an off-switch for billing this is the best/only way. I hate it but i'll live with it.


Run a cloud function that stops all billing when costs exceed the budget.

how can this be done?

  1. setting up a budget alert
  2. which triggers a pub/sub
  3. which runs a cloud function
  4. which removes the billing
sleep-well-at-night
But how you ask? I followed this tutorial.