Monitor your cloud spend with AWS Accountant

TLDR — aws-accountant is a dead simple, free tool that helps you monitor your AWS charges.

Ravenna Kev
5 min readJan 29, 2022
Photo by Josh Appel on Unsplash

Surprise cloud bills were a topic of discussion on Hacker News earlier this week.

On Monday, Troy Hunt posted a blog titled “How I Got Pwned by My Cloud Costs”. In the post, Troy describes how his Azure bill surprisingly skyrocketed due to a size limit setting in his CloudFlare account. The CloudFlare limit led to excessive egress cost for data being downloaded from his Azure account, which in turn, led to an $8k+ bill. Not fun.

Then on Tuesday, Fleet posted a blog titled “Saving over 100x on egress switching from AWS to Hetzner.” In the post, Zach Wasserman discussed how Fleet’s CloudFront bill spiked to $2,457 in October 2021 from $370 in September due to egress charges. That’s a solid 564% jump right there. Again, not fun.

We’ve all been there

I myself have been the unfortunate victim of large, surprise cloud bills on multiple occasions. Cloud services make it trivial to spin up expensive resources, but by default, they do a poor job of reminding you when those expensive resources are still running when you forget about them.

Back in my Mesh Studio days, a client once asked us to execute a POC that would demonstrate how to run Docker on a SUSE Linux instance in AWS. We were trying to win their business at the time, so this POC was free of charge (I know we were dumb consultants.)

Fortunately for us, we found a SUSE AMI in the marketplace and deployed it without much thought to cost. We installed Docker on the instance, deployed an image, and shot the potential client a link to the POC. Job complete.

Unfortunately for us, we didn’t look at the cost of the SUSE AMI. We also didn’t think to shut the instance down at the end of the day, as we didn’t know when the client would have a chance to review our work. Fast forward to the end of the month and the SUSE instance still running. We were unpleasantly surprised to find a ~$1500k bill for our SUSE usage. Not fun.

A more unfortunate example was when Amazon Kendra was released. At the time, I had been toying around with an idea to build a “universal search engine for your cloud documents”. Kendra looked like it could be an enabling technology so I went to the new console and deployed an instance.

I played with the service for about 10 minutes and then forgot about it. About a month later, I was shocked to find a $2k+ bill for the same Kendra instance that I had literally been sitting idle for a month. Not fun.

To be clear — these bills were my fault. The cloud providers are very transparent with pricing, and they only bill you for what you “use”. They key here is that “usage”, includes the time that a resource is provisioned in your account, even if you aren’t actually “using” it.

Additionally, AWS support is great, and is quite responsive with billing inquiries, even if you are a small company that doesn’t pay for enterprise support. For instance, I submitted a support ticket when I got the Kendra bill and explained the situation. Without much effort, AWS refunded the bill which was awesome.

Each time I was hit with a surprise AWS bill however, I would think to myself, “I should really build a tool that will automate the creation of alerts that will notify me when my bill is going over a certain amount”…say $200/mo.

AWS offers tools that allow you to configure these type of alerts, but it is up to the user to “turn on” these alerts. They are not enabled by default. The tool I envisioned would simply automate the process of “turning on” the alerts and setting certain thresholds.

Unfortunately, I never got around to building this tool…until now. Troy and Fleet’s posts earlier this week, and the fact that I have been knee deep in Terraform for the past several months, spurred me to action.

AWS Accountant

Today, I’m happy to release aws-accountant, a terribly simple tool that allows you to easily provision CloudWatch billing alarms.

https://github.com/kcoleman731/aws-accountant

These Alarms will send you both Emails and SMS notifications when either:

  1. Your AWS bill goes above thresholds that you specify.
  2. Your Egress bandwidth for EC2 instances goes above certain thresholds you specify.

The tool is available today as an open source repo on Github. A bit of sample code below demonstrating how you can use the tool below.

module "aws-accountant" {
source = "git@github.com:kcoleman731/aws-accountant.git"
email = "cloud@accountant.com"
phone_number = "+4445556666"
egress_threshold = 300
charge_thresholds = [
{
name = "Ten"
threshold = "10"
},
{
name = "Twenty"
threshold = "20"
}
]
}

How it works

In Troy’s post, he discussed the alerts he configured in his Azure account to prevent his bill from sky rocketing again.

First, he configured an alert that would notify him if his Egress data went above 50GB for any 24 hour period. Next, he configured an alert that would notify him if his overall bill went above $500 and $1000 for for the month. aws-accountant covers both use cases.

For Egress cost alerts, aws-accountant provisions a CloudWatch alarm which monitors the NetworkOut metric for your EC2 instances. aws-accountant will query for instances that are tagged with MonitorEgree:true configure alerts for each instance.

For billing alerts, aws-accountant provisions CloudWatch alarms which monitor the EstimatedCharges metric for your account. You are able to specify multiple thresholds and get alerts each time one is reached.

And thats it. A free, dead simple tool that you can use today to effortlessly monitor you AWS cost.

Closing thoughts

I would bet that the vast majority of cloud engineers have had the pleasure of a surprise cloud bill. With minimal effort, alarms can be configured to ensure this doesn’t happen going forward.

Hope you enjoy, and as always, I appreciate your feedback.

--

--

Ravenna Kev

Software Developer. Currently work in Business Development at AWS. Previously founded Mesh Studio, a cloud consultancy in Seattle.