This content originally appeared on DEV Community and was authored by Erik Lundevall Zara
Have you experimented with some new and interesting AWS service and their features, learned a few interesting pieces, and then continued with your regular work - only to find an unwelcome surprise on the AWS bill at the end of the month?
Or perhaps someone in your organization asked you about a cost increase on one of the AWS accounts?
This is something that probably most cloud workers have experienced - aw, I forgot to shut off that thing...
There is a feature/service that AWS provides that can at least reduce the risk of that painful surprise - AWS Budgets. This article will show you some info on setting that up via the AWS Management Console. For a scripted approach, see the link at the end of the article.
AWS Budgets are located under the Billing Dashboard in AWS Management Console, which you can get to from the account menu in the upper right - assuming you have the privileges to access the Billing Dashboard.
Once in the Billing Dashboard, there is an entry in the left pane that leads you to the Budgets section.
There are fundamentally four types of budgets that you can create - cost budget, usage, reservation, and savings plan budget. The cost budget is a budget that monitors the amount of $$$ you spend or is forecasted to spend. The usage budget concerns capacity metrics and how much you consume there - for example, GB storage. Reservation and Savings plan budgets are ways to monitor utilization or coverage of your reserved instance allocation or savings plan.
Since we deal with unexpected costs and bills in this article, we focus on cost budgets. You can click on Create Budget on the right side to create a new budget.
There are a few steps to go through to create a cost budget:
Enter a name for the budget
Select a budget period. This is the type of period that the budget is valid for. For a regular cost budget, this can be daily, monthly, quarterly, or annually - but there are restrictions on the daily option. You do want a monthly budget if you are going to catch unexpected costs, most likely.
The type of period, which can be recurring or expiring. An expiring budget is a one-off kind of budget and it will go away after it expires. So an expiring budget might be what you prefer for a temporary project or setup if you want to track costs for that particular project only.
The start and end month, if you have an expiring monthly budget.
Select if the budget limit is fixed for each month, or different for each month.
The budget limit for the period. It is a single value with a fixed budget. This is the cost limit (in USD) that you set for the period.
By default, the budget is valid for the whole AWS account and all regions. You apply various filters to reduce it to the resources that are relevant to you. See more below.
- There are also options for cost aggregation and what types of costs should be included in the budget. I have so far kept the defaults here.
You can then set up notification thresholds for the budget. This can be for the actual incurred cost or a forecasted cost for the current period. The threshold can be a percentage of the budget limit or an actual value.
Notifications can be delivered as email, via SNS, or integration via AWS Chatbot.
It is also possible to set up actions that trigger when a threshold is reached. I will not go in further into this part here, but this may be interesting for a more elaborate budget setup.
Once you have gone through all options, you can look at the summary and confirm your choices.
There is a multitude of options to set and we have not covered all the cases here! Additional filtering options can pick specific regions and specific resources, for example via tags.
A caveat with the tags is that the tags you use must have been activated as cost allocation tags. This can also be done via the Billing Dashboard. Any tag that has been used can be activated as a cost allocation tag.
Are you going to set up a new budget when you have a new project, going through these steps? In practice, I seldom do this in the AWS Management Console.
To try to make this process a bit smoother I made a script to create/update budgets. It takes an opinionated and simplified approach, but only a single command is needed, for example:
./Set-SimpleBudget.ps1 -BudgetName MyBudget -Amount 100 -NotificationEmail alert@example.com
This is the minimal approach with all the defaults, which will set up an expiring cost budget (100 USD monthly) for the current month, with two thresholds - >80% of actual cost and >100% of the forecasted cost. This is for all resources in the account and all regions. You can also filter on tags and regions.
If this is interesting, check out the description for that script in my other budget post - How to avoid unexpected AWS costs.
This content originally appeared on DEV Community and was authored by Erik Lundevall Zara
Erik Lundevall Zara | Sciencx (2021-04-20T21:16:13+00:00) How to avoid unexpected AWS costs. Retrieved from https://www.scien.cx/2021/04/20/how-to-avoid-unexpected-aws-costs/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.