In this article, you will learn how to control costs on the Amazon Web Services (AWS) platform. I will show you the two most important ways to control AWS costs / expenses. The first will allow you to set a notification, an alarm when you exceed the amount you set. The second will show you how to get payment details so you know what you are paying for.
Before we start dealing with finances, it’s a good idea to get you to see them as an IAM user, not just as a root user. There are two things you need to do to do this:
- Log in as root user and select “My Account” from the top right corner. Then find “IAM User and Role Access to Billing Information“, click edit and activate IAM access.
- Grant the appropriate permissions to IAM users. Admin can do everything, but we can reduce the rights to, for example, only viewing costs:
For more information on IAM’s cost management permissions, see the AWS documentation.
At the beginning, you need to determine the amount you want to spend in AWS. Once you know how much you want to spend, all you need to do is set a budget and receive notifications before you exceed it.
In my opinion, it is good to define 2 budget lines. Daily and monthly budget. The monthly budget will allow you to perfectly control the money spent on a monthly basis. The daily budget will alert you faster when something bad starts to happen, e.g. if you accidentally buy a machine that is too expensive, or if someone decides to buy several bitcoin miners on your account 😉.
After exceeding the limit, you will receive an immediate notification using the method you have chosen.
The budget is set very simply, just log in to your account, search for “AWS Budgets” and click “Create budget”.
In the wizard that will open, select the “Cost budget” type, enter a name and specify whether it should be daily, monthly or quarterly. If you spend the same amount every month, leave the type “Fixed” and in the “Budgeted amount” field enter the maximum amount you would like to spend in AWS (next to the field you have a small hint about how much you spent in the previous month). You can also select “Monthly Budget Planning” and set a different amount for each month. The rest of the settings are optional, but if you’re planning to go into detail about it, it’s worth taking a look at them.
In the third step, we set the value above which we want to receive the notification. I have set the value to 85% of current costs. This means that if my monthly AWS expenses exceed 85% of my budget, I will receive an alert.
Enter the email address to which you will receive the notification in the box below. You can also choose to be notified using the SNS service and receive a notification e.g. on Slack or MS Teams.
You can read about how to receive notifications on Slack and MS Team in the article Notifications from AWS on MS Teams.
If you want to get another notification about exceeding the next threshold by the same or a different method, click on “New threshold” and repeat what you did at this point. You can set, for example, that the administrator receives the first notification, and the financial director receives the next notification at a higher threshold.
Once you are done, all you have to do is confirm your budget and go to the last card.
If all the information is correct and you don’t want to fix anything, click create.
Cost Explorer is a very powerful tool when properly configured. People starting work with AWS can tell you what’s so special about it, it is only general information about costs. As I wrote, Cost Explorer can be a really powerful and useful tool. You just need to configure it properly.
In Cost Explorer, you can get information about the cost of individual resources. How to do it? It is enough to give them the appropriate TAGS. Let me remind you that the name of the resource 🙂 is also a tag.
So most of the work is done, most of the resources have a name, and if not, you can always give it and track costs that way. Tags can have a different name and purpose. I often set several tags for each resource, this way it is easier to control them and implement automation.
But… but that’s not enough. When you run AWS Cost Explorer. Then you will see that you can choose to display the resource after TAGs. Only it won’t work. First you have to tell our cloud to watch certain tags.
You’ll find out how to do it in a moment.
So click in the top right corner on your username and select “My Billing Dashboard”.
In the new window, select “Cost allocation tags” from the list on the left.
A window will open where you will have all the Tags you used in AWS. Select the tags from the list that you want Cost Explorer to track. Select them and click “Active“. Then the description next to them will change from red Inactive to green “Active”. If you don’t see your newly added tags on the list, don’t stress. It may take a while for them to appear on the list.
From now on by selecting Tag grouping in Cost Exploter, you will be able to see the tags you have selected under “Cost allocation tags”.
A small note here, AWS takes 24 hours to start distinguishing resources by the tags you provide. And if you activate the tags in “Cost allocation tags” today, you will see detailed data only from today, that is only from the date on which you activate tagging. All previous data will be displayed as “No Tagkey”.
That’s all for this cost article, I hope it will make your work with AWS a little easier and help you avoid unnecessary expenses. If you liked the article and you think that it may still be useful to someone, then do not let them lie idle, please share it 🙂 .
Let’s not spend money unnecessarily, let’s control expenses in the cloud.
You can find more of my articles related to the AWS cloud in the AWS category.