Cost management for AWS
AWS is such a powerful tool to get things done quickly, and often cheaply. But it’s still a lurking worry for many that costs could quickly spiral out of control. Since I’m hosting my website here I’d like to know if costs change considerably, so I can act fast to save my credit card if I need to!
This is by no means meant as a comprehensive guide on how to do this, I’m pretty certain that your AWS account manager can help with reading material for that! But it’s more a reminder of how I set things up in this case.
Since this AWS account has only been open a few months, I’m still eligible for AWS free tier, which should mean that costs will be almost zero for the first 12 months. At that point I’ll have a good idea whether S3, CloudFront and co. allow me the right features at the right price point. Of course, I have other options (see my website wrapup blogpost), but in this case I wanted to learn more about CloudFront, and what better way to do it than getting your hands dirty.
Tag - you’re IT
At the moment the only things going on in my AWS account are related to this
website (which makes cost tracking easier), but later in the year I’m planning
to test some other new services. When creating the S3 bucket, add tags e.g.
website: dns-name. That will make it easier to identify what is costing
what. It’s not possible to tag all resources/costs, e.g. I’m pretty sure I
couldn’t tag my domain name registration, or the DNS Zone monthly fee. However,
those costs are (at least in this simple account), easy to keep track of.
In my previous role I setup AWS Organizations to help with granting access to AWS functionalities, as well as to monitor costs. That’s overkill for me with just one website, and one (real) user - me. But it’s a really good way to keep larger projects together, and avoid the above mentioned issue with tagging.
Budgets (and alerts)
Since I have a rough idea how much I expect it to cost for my website to run over the course of a month I can set a couple of budgets. One for my best guess at the average monthly cost, and a second ‘Emergency’ budget, set at the point which will make my credit card start to get scared. With budgets I can then set triggers to notify me (e.g. via email), if it’s projected that I’ll exceed the budget, or if the budget is actually exceeded. At that point I’ll probably want to login to the console and think about pulling access to the website.
IAM access to the billing console
Hopefully with your AWS account you’ve setup IAM access, and aren’t logging, in as the root user almost any tasks. If you’ve not done that, you should. If you have, you’ll need to grant your IAM user access to the billing console.
Setting up the alerts
In the example I randomly chose the figure of 100 USD, since at the moment I have no idea how popular this website will be. I chose an annual budget since with an expected low readership, the costs could fluctuate quite a lot on a month to month basis. See the screenshot.
On the next page I can decide whether I want to have an alert sent based on crossing a percentage threshold of the actual or forecasted costs. Actually I want to send one in both cases, since it would be great to catch a bad configuration that is costing me money before the costs get too high.
One stupid thing that wasted 5 minutes of my time was that I didn’t realise that the example ‘80’ in the percentage threshold box was just a placeholder, which meant that the ‘Set Alerts’ button was permanently greyed out, until I entered in the value ‘80’ myself…
Maybe you also want to trigger some action with a Lambda, or get a text alert in addition to the email. In that case you’ll need to setup an SNS Topic, and be sure to add permissions for AWS Budgets to publish to the topic. See this nice Stack Overflow post. Once you’ve setup the topic, make sure to go into the subscriptions and subscribe your mobile number to the topic.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License .