Keeping your Google Cloud Platform Bill to a Minimum with Billing Alerts
Tags: cloud, gcp, googlecloud, 100daysofcloud
Published: 2020-07-14 18:50:46

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 😬. 

{% twitter 1279406322837082114%}

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](https://dev-to-uploads.s3.amazonaws.com/i/a7gubirc86xbg066zku7.png)

### Navigate to Budgets and Alerts

![GCP Billing Console left menu with Budgets and Alerts selection outlined](https://dev-to-uploads.s3.amazonaws.com/i/pfo7d8d8t1jggefc3t35.png)

### Create a Budget 

![GCP Budget and Alerts with Create Budget button outlined](https://dev-to-uploads.s3.amazonaws.com/i/3nn94d69z3ll81inkltb.png)

![GCP Create Budget Scope with fields for the budget name and what projects/services the alert will apply to](https://dev-to-uploads.s3.amazonaws.com/i/ic5hlbt2flm24sgicq9s.png)

![GCP Create Budget Amount with fields for the budget type and the budget amount](https://dev-to-uploads.s3.amazonaws.com/i/md25ln0wg7kf3260ntb7.png)

![GCP Create Budget Actions with fields for what thresholds you want the alert to fire based on the budget amount](https://dev-to-uploads.s3.amazonaws.com/i/rus973poe86zs0u42l7q.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/kgolsnnn4tn8adqnqp4d.png)

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

{% twitter 1280415946201534464%}

All cloud providers should have something like this. 

# Additional Resources

[Google Cloud Cost Management Docs](https://cloud.google.com/blog/products/gcp/best-practices-for-optimizing-your-cloud-costs)

[Google Cloud Cost Calculator]
(https://rominirani.com/google-cloud-platform-factors-to-control-your-costs-5a256ed207f1)

[Azure Cost Management Docs](https://docs.microsoft.com/en-us/azure/cost-management-billing/)

[Amazon Web Services Cost Management Docs](https://aws.amazon.com/aws-cost-management/)

[Amazon Web Services Cost Management Egghead Lesson]
(https://egghead.io/playlists/use-aws-billing-cost-management-dashboard-to-keep-your-aws-bill-to-minimum-ff0f)

[Podcast discussing AWS Bill Stories](https://www.lastweekinaws.com/podcast/aws-morning-brief/whiteboard-confessional-the-curious-case-of-the-9000-aws-bill-increase/)