DEV Community

jsrios
jsrios

Posted on

Keeping your Google Cloud Platform Bill to a Minimum with Billing Alerts

When experimenting with cloud providers, it's important to keep in mind how to manage costs, because it can be very easy to wake up the next morning with a $2700 bill 😬.

Even when there might be free tiers or cloud credit, you don't want to accidentally leave an instance of something running and finding out it's all gone and went to your credit card.

I'll be walking through how to manage costs by setting up Billing Alerts in Google Cloud Platform as well as providing further resources for some of the other providers.

Note: This will probably cover most of your cost alerting needs for experimentation, but for larger projects or side projects where you expect decent traffic, you will probably want to take a look at the services being used and optimize the resources needed to run those services alongside setting up alerts.

Setting up Billing Alerts

Navigate to the GCP Billing Console

GCP Project Console left menu with Billing selection outlined

Navigate to Budgets and Alerts

GCP Billing Console left menu with Budgets and Alerts selection outlined

Create a Budget

GCP Budget and Alerts with Create Budget button outlined

GCP Create Budget Scope with fields for the budget name and what projects/services the alert will apply to

GCP Create Budget Amount with fields for the budget type and the budget amount

GCP Create Budget Actions with fields for what thresholds you want the alert to fire based on the budget amount

50% and 90% threshold for alerts work fine for this walkthrough but Google Cloud Platform allows you to add and remove as many as you want (no duplicates) so choose whatever works for you. For example, you could set up alerts at every 10% threshold like below if you want:

GCP Create Budget Actions with increasing thresholds of 10% until 100% for the alerts

For this walkthrough, there is no need to set up Cloud Pub/Sub or a Monitoring workspace so the two options under Manage notifications can remain unchecked.

And that's it!

You will now be properly alerted for your Google Cloud Platform usage so you won't need to worry about any surprise bills.

As you can see, you can't tell GCP (and other cloud providers) to just stop once you have used $20. Since your service is up and running it can get any amount of traffic at any point in time, so it wouldn't be the easiest thing for cloud providers to manage. So most providers will allow you to set up alerts or alarms so that you can be more aware of how much your project is costing and if it ever reaches a bad point you will be alerted.

The Ideal Solution

All cloud providers should have something like this.

Additional Resources

Google Cloud Cost Management Docs

Google Cloud Cost Calculator

Azure Cost Management Docs

Amazon Web Services Cost Management Docs

Amazon Web Services Cost Management Egghead Lesson

Podcast discussing AWS Bill Stories

Top comments (0)