AWS Budgets & Cost Alerts
Monitor and control your AWS spending
💵 Cost: AWS Budgets is free for the first 2 budgets. Additional budgets cost $0.02/day each. Budget Actions (auto-remediation) cost $0.10/action. See aws.amazon.com/aws-cost-management/aws-budgets/pricing.
Why Set Up Budgets?
AWS bills can surprise you. Without alerts, you might not notice a runaway cost until your credit card is charged. Budgets help you:
- Get notified before costs exceed your expectations
- Track spending by service, account, or tag
- Automatically stop resources when budgets are exceeded
- Forecast future costs based on usage patterns
Set This Up First
Before deploying any AWS resources, set up a budget with email alerts. A single misconfiguration can result in hundreds or thousands of dollars in unexpected charges.
- Go to AWS Billing Console → Budgets
- Click Create budget
- Choose Cost budget - Recommended
- Set budget name:
Monthly-Total-Budget - Set budget amount:
$100(or your target) - Choose Monthly budget period
- Add alert thresholds:
- Alert 1: 80% actual - Early warning
- Alert 2: 100% actual - At budget
- Alert 3: 100% forecasted - Predicted to exceed
- Add email addresses for notifications
- Click Create budget
Multiple Budgets
Create separate budgets for different purposes:
- Total monthly budget - Overall spending limit
- Per-service budget - EC2, RDS, etc. individually
- Per-project budget - Using cost allocation tags
AWS CLI
Terminal
$aws budgets create-budget --account-id $(aws sts get-caller-identity --query Account --output text) --budget file://budget.json --notifications-with-subscribers file://notifications.json
Budget created successfully
budget.json:
JSON
{
"BudgetName": "Monthly-Total-Budget",
"BudgetType": "COST",
"BudgetLimit": {
"Amount": "100",
"Unit": "USD"
},
"TimeUnit": "MONTHLY",
"CostFilters": {},
"CostTypes": {
"IncludeTax": true,
"IncludeSubscription": true,
"UseBlended": false,
"IncludeRefund": false,
"IncludeCredit": false
}
}notifications.json:
JSON
[
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 80,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{
"SubscriptionType": "EMAIL",
"Address": "your-email@example.com"
}
]
},
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 100,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{
"SubscriptionType": "EMAIL",
"Address": "your-email@example.com"
}
]
}
]Terraform
HCL
resource "aws_budgets_budget" "monthly" {
name = "monthly-total-budget"
budget_type = "COST"
limit_amount = "100"
limit_unit = "USD"
time_unit = "MONTHLY"
time_period_start = "2024-01-01_00:00"
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["your-email@example.com"]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["your-email@example.com"]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
notification_type = "FORECASTED"
subscriber_email_addresses = ["your-email@example.com"]
}
}
# Per-service budget (example: ECS/Fargate)
resource "aws_budgets_budget" "ecs" {
name = "ecs-fargate-budget"
budget_type = "COST"
limit_amount = "50"
limit_unit = "USD"
time_unit = "MONTHLY"
time_period_start = "2024-01-01_00:00"
cost_filter {
name = "Service"
values = ["Amazon Elastic Container Service"]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["your-email@example.com"]
}
}Recommended Budget Setup
| Budget | Amount | Alerts |
|---|---|---|
| Total Monthly | Your max monthly spend | 50%, 80%, 100% actual + 100% forecast |
| Compute (ECS/EC2) | 50-60% of total | 80%, 100% actual |
| Database (RDS) | 20-30% of total | 80%, 100% actual |
| Networking (NAT/ALB) | 10-20% of total | 100% actual |
Using Cost Explorer
AWS Cost Explorer provides detailed cost analysis:
- Daily/Monthly views - Track spending over time
- Service breakdown - See which services cost the most
- Forecasting - Predict end-of-month costs
- Reserved Instance recommendations - Save money on committed usage
Terminal
$aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31 --granularity MONTHLY --metrics BlendedCost --group-by Type=DIMENSION,Key=SERVICE
{
"ResultsByTime": [{
"Groups": [
{"Keys": ["Amazon Elastic Container Service"], "Metrics": {"BlendedCost": {"Amount": "45.23"}}},
{"Keys": ["Amazon Relational Database Service"], "Metrics": {"BlendedCost": {"Amount": "32.50"}}},
{"Keys": ["Amazon Simple Storage Service"], "Metrics": {"BlendedCost": {"Amount": "5.12"}}}
]
}]
}Check Costs Weekly
Review Cost Explorer weekly to catch unexpected spending early. Set a calendar reminder to check every Monday morning.