How to set up an AWS budget alert before a big bill surprises you
Updated · 4 min read
AWS has no spending cap you can switch on: it bills for whatever runs. What it does have is AWS Budgets, which emails you when spending passes an amount you choose, or when AWS forecasts that it will. Watching a budget and getting its emails is free. (AWS charges only for budget actions beyond the first two, and for scheduled budget reports.)
In the AWS console
- Open Billing and Cost Management → Budgets and click Create budget.
- Under Budget setup, choose Use a template (simplified), then a template:
- Zero spend budget emails you once your spending goes past what the Free Tier covers. The right one for a learning or test account that should cost nothing.
- Monthly cost budget emails you when you've spent more than the amount you enter, or AWS forecasts you will by the end of the month.
- Enter the email addresses that should hear about it (and, for the monthly budget, the amount), and click Create budget.
- Confirm each email address. AWS Budgets sends a verification email from an
@aws.comaddress, and it only sends budget notifications to addresses that have been confirmed. The person has to click the link and sign in to this AWS account, and the link expires after 12 hours. Check spam if it doesn't arrive; the budget's page shows each address as Pending until it's done, with a Resend verification button.
For different thresholds (say 50%, 80% and 100%), a budget for one service or one tag, or notifications to an SNS topic or Slack, choose Customize (advanced) in step 2 instead. It lets you add several alert thresholds, each on actual or forecasted spend, as a dollar amount or a percentage of the budget.
If Budgets says you don't have access, billing access is probably switched off for IAM users and roles. The root user can turn on IAM user and role access to Billing information on the Account page.
With the AWS CLI
Write the budget to budget.json:
{
"BudgetName": "monthly-total",
"BudgetLimit": { "Amount": "50", "Unit": "USD" },
"BudgetType": "COST",
"TimeUnit": "MONTHLY"
}and who hears about it, and when, to notifications.json. This emails at 80% of actual spend ($40 here) and when AWS forecasts you'll pass 100%:
[
{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 80,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "you@example.com" }]
},
{
"Notification": {
"NotificationType": "FORECASTED",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 100,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "you@example.com" }]
}
]Then create it:
aws budgets create-budget \
--account-id $(aws sts get-caller-identity --query Account --output text) \
--budget file://budget.json \
--notifications-with-subscribers file://notifications.jsonIt prints nothing when it works. The verification email from step 4 still applies. To see your budgets and what they've counted so far:
aws budgets describe-budgets --account-id 111122223333 \
--query 'Budgets[].[BudgetName, BudgetLimit.Amount, CalculatedSpend.ActualSpend.Amount]' --output textWhat a budget won't do
- It doesn't stop anything. It sends an email. Budget actions can go further when a threshold is crossed: apply an IAM policy or a service control policy that blocks creating more resources, or stop particular EC2 or RDS instances, either automatically or after you approve.
- It isn't instant. Budgets update up to three times a day, typically 8 to 12 hours apart, and billing data itself lags behind usage. Something expensive can run for most of a day before the email arrives, so set the amount lower than the number that would actually hurt.
- In an AWS Organization, the management account can budget for a member account, and member accounts can create their own.
Two more safety nets
- Free Tier usage alerts. AWS emails the account's root email address when you pass 85% of a Free Tier limit. It's on by default for standalone accounts, though not for an organization's management account. Change the address, or switch it on, under Billing preferences → Alert preferences.
- Cost Anomaly Detection (in Billing and Cost Management) learns your usual spending and emails you about unusual jumps, broken down by service, account, region and usage type. It runs about three times a day, on Cost Explorer data that can be up to 24 hours behind.
Or in Cloud GUI
Cloud GUI's Costs page shows this month so far, AWS's forecast for the whole month and last month's total, with what each service costs, from Cost Explorer. When a budget email arrives, it's a quick way to see whether it's a blip or a trend, and which service is behind it. Cloud GUI doesn't email you about spending, so keep the budget above as your early warning. Its free checkup looks for the usual leaks in every region: disks not attached to any server, Elastic IPs not in use and stopped databases still paying for storage. For tracking down a jump, see how to find out what's costing money.