Monitor your AWS Bill before it goes high

Chetan Bothra
2 min readJun 24, 2020

--

AWS cost tracking in an organization has become such an important thing and its true that we get surprised seeing the bill end of the month.

Few such examples are, Not associating an EIP and leaving a Load Balancer running for test use.

This use case is so common because it we easily forget resource we created after a specific time and then we forget to bring it down when we were done.

The whole idea of this to set AWS Budgets to create per service level billing alarms. In this article i will explain how we can achieve this manually and automate this via terraform.

Plan your budget

The key this on this is to understand how much is your expense could be.
For Example :

Elastic Compute Cloud (EC2) — 19.99
Relational Database Service (RDS) — 35.04
Simple Storage Service (S3) — 1.50
So overall I am expecting my budget to be around $60 mark

How to set billing alarm (Manually)

Step 1 : Navigate to AWS Billing dashboard

Step 2 : On Left side, You will see budget, click on that and there “Create A budget”

Step 3 : The next step would be selecting the appropriate budget , I want to monitor my bill so i selected “Cost budget” but you can select according to your usecase

Step 4 : Enter Details
A : Name : MyProdAccount
B : Period: Monthly
C : Budget effective dates : Recurring Budget
D : Start Month : Enter the current month
E : Budget amount : Fixed
F : Budgeted amount : $60 ( This we got from our budget planning)
G: Send alert based on: Actual Cost
H: Alert threshold : Set to 50% ot 80% depending and when you want to be notified
I : Email contacts : Add email you want notification to be sent
and then confirm budget and then create !

and we are all done !

How Do i automate this ?

resource "aws_budgets_budget" "budget" {
name = "${var.name}"
budget_type = "COST"
limit_amount = "${var.limitamount}"
limit_unit = "USD"
cost_types{
include_recurring = true
}
time_period_start = "2020-01-01_00:00"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = "${var.threshold}"
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["${var.email}"]
}
}

Here is the link to explore more :
https://github.com/chetanbothra/Terraform_AWS_Billing_Alert

If this article has helped you, Please share your feedback via DM or comment with me on https://www.linkedin.com/in/chetanbothra

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Chetan Bothra
Chetan Bothra

Written by Chetan Bothra

AWS Certified | GCP | DevOps | SRE | Docker | DevSecOps | Kubernetes | Automation | Terraform | Serverless | Blockchain

No responses yet

Write a response