42.3 AWS Budgets: Alerts When Costs or Usage Exceed Thresholds
Right, let’s talk about AWS Budgets. This is the feature that stops you from getting that heart-stopping email from your CFO that just says “???” with a screenshot of your AWS bill attached. It’s your automated, hyper-vigilant financial watchdog. You tell it the rules—“bark if we spend more than X dollars”—and it does, loudly and repeatedly, until you fix it.
The core concept is beautifully simple: you create a budget, set a threshold (like $100 a month), and define who to alert when you cross it. But as with most AWS services, the devil is in the details, and they’ve given this devil a surprising number of knobs to turn.
The Anatomy of a Budget (It’s Not Just Cost)
Most folks think budgets are only for actual dollars. They’re not. You can also budget based on usage (like “alert if we use more than 50,000 S3 PUT requests”) and even savings plans coverage. This is crucial. A usage budget can warn you about a misconfigured asset long before its financial impact shows up on your cost budget. If a dev instance gets stuck in a loop and starts hammering the API, you’ll know within hours, not at the end of the month.
Here’s how you create a basic cost budget using the AWS CLI. Notice I’m setting --TimeUnit MONTHLY and a --TimePeriod that starts and ends. Pro tip: just set the start date and make the end date years in the future. AWS will handle it correctly, and you won’t have a budget that just… stops.
aws budgets create-budget \
--account-id 123456789012 \
--budget '{
"BudgetName": "my-monthly-budget",
"BudgetLimit": {
"Amount": "100",
"Unit": "USD"
},
"CostFilters": {
"TagKeyValue": ["Environment$Production"]
},
"TimeUnit": "MONTHLY",
"TimePeriod": {
"Start": "2024-01-01",
"End": "2027-12-31"
},
"BudgetType": "COST",
"CostTypes": {
"IncludeTax": true,
"IncludeSubscription": true
}
}' \
--notifications-with-subscribers '[
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 90.0,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [
{
"SubscriptionType": "EMAIL",
"Address": "you-and-your-cfo@yourcompany.com"
}
]
}
]'
Thresholds: Absolute vs. Percentage, and Why It Matters
See that ThresholdType? This is a classic “seems trivial, is actually critical” setting. ABSOLUTE_VALUE means “alert me when we hit exactly $90.” PERCENTAGE means “alert me when we hit 90% of our budget.” You almost always want PERCENTAGE. An absolute threshold of $90 on a $100 budget is useless if you have a spike to $500; you’d get one alert at $90.01 and then silence while you burn another $410. A percentage threshold at 90% will alert you at $90, and then—this is the key part—it will alert you again at 100%, 150%, and 200%. It will nag you every time you cross another multiple of your threshold until you mute it or fix the problem.
The Notification Black Hole (and How to Avoid It)
The single biggest pitfall with AWS Budgets is the notification system. It is, frankly, a bit of a mess. You define subscribers (email, SNS) within the budget creation call itself. There’s no separate “manage subscribers” page in the console. If you want to add an email address later, you must update the entire budget definition and include all the subscribers again. It’s incredibly easy to accidentally wipe your list of subscribers. My best practice: define your alerts in Terraform or CloudFormation. Code is your source of truth, not a finicky web form.
// This is the part you must not mess up.
"Subscribers": [
{
"SubscriptionType": "EMAIL",
"Address": "you-and-your-cfo@yourcompany.com"
},
{
"SubscriptionType": "SNS",
"Address": "arn:aws:sns:us-east-1:123456789012:BudgetAlerts"
}
]
Beyond the Basics: Filters and Cost Types
The real power, and complexity, comes from CostFilters and CostTypes. Want a budget just for your Production environment tagged with Environment=Production? That’s a CostFilter. Want to include your RI upfront payments in the budget calculation? That’s in CostTypes (IncludeUpfront). Want to exclude refunds? That’s IncludeRefund. These settings are powerful but opaque; you’re telling AWS how to calculate the number it’s going to compare to your threshold. Get it wrong, and your alerts will be based on a fictional version of your spend. Test them thoroughly.
The bottom line: AWS Budgets is a non-negotiable part of your cost ops stack. It’s not a prevention tool (it can’t stop spending), but it is the earliest possible warning system. Set it up on day one, wire it to a dedicated Slack channel or SNS topic your team actually monitors, and thank yourself later when it catches that accidentally left-on GPU instance. Your CFO will too.