Nov 20, 20265 min read

How to Set Up AWS Billing Alerts and Budgets

The three ways AWS can warn you about spend, AWS Budgets, the EstimatedCharges CloudWatch alarm and Cost Anomaly Detection, how to set each one up from the CLI, and how cost allocation tags turn one account bill into per-environment budgets.

Illustration for How to Set Up AWS Billing Alerts and Budgets

A new AWS account has no spending limit and no alert, so the first sign of a NAT gateway left running or a runaway log group is usually the invoice at the start of the month.

AWS has three separate tools that warn you earlier, and they differ in how fast they react and how precisely they filter. This guide sets up all three from the CLI.

The three tools

ToolWatchesGranularityGood for
AWS BudgetsActual and forecasted cost or usageAccount, service, tag, linked accountMonthly limits per team or environment
EstimatedCharges alarmMonth-to-date estimated chargesAccount or per serviceA simple hard ceiling
Cost Anomaly DetectionSpend compared with learned patternsService, account, cost category, tagSpikes that stay under the monthly limit

Budgets is the one to start with, and the other two cover its gaps: a billing alarm is a quick backstop, and anomaly detection catches a daily cost that doubled while the monthly total is still under budget.

Creating a monthly budget

The AWS Budgets guide covers the console flow, and from the CLI a budget and its notifications are two JSON documents:

ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) cat > budget.json <<'JSON' { "BudgetName": "monthly-total", "BudgetLimit": { "Amount": "500", "Unit": "USD" }, "TimeUnit": "MONTHLY", "BudgetType": "COST" } JSON cat > notifications.json <<'JSON' [ { "Notification": { "NotificationType": "ACTUAL", "ComparisonOperator": "GREATER_THAN", "Threshold": 80, "ThresholdType": "PERCENTAGE" }, "Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "billing@example.com" }] }, { "Notification": { "NotificationType": "FORECASTED", "ComparisonOperator": "GREATER_THAN", "Threshold": 100, "ThresholdType": "PERCENTAGE" }, "Subscribers": [{ "SubscriptionType": "EMAIL", "Address": "billing@example.com" }] } ] JSON aws budgets create-budget --account-id "$ACCOUNT_ID" \ --budget file://budget.json \ --notifications-with-subscribers file://notifications.json

The forecasted notification is the useful one, since it fires mid-month when the current trend would exceed the limit, while the actual notification only confirms what already happened. Budget data updates several times a day rather than in real time, so a sudden spike can run for hours before an email arrives.

A billing alarm as a backstop

The EstimatedCharges metric lives in the AWS/Billing namespace in us-east-1 only, and it appears after you turn on billing alerts in the Billing preferences, as the billing alarm docs explain:

aws cloudwatch put-metric-alarm --region us-east-1 \ --alarm-name billing-over-600 \ --namespace AWS/Billing --metric-name EstimatedCharges \ --dimensions Name=Currency,Value=USD \ --statistic Maximum --period 21600 --evaluation-periods 1 \ --threshold 600 --comparison-operator GreaterThanThreshold \ --alarm-actions arn:aws:sns:us-east-1:123456789012:billing-alerts

The SNS topic has to be in us-east-1 as well. Set the threshold above the budget so it acts as the last line rather than a duplicate.

Cost Anomaly Detection

Anomaly detection learns the normal daily spend per service and alerts on deviations. Create a monitor for AWS services and a subscription with an absolute or percentage impact threshold, following the Cost Anomaly Detection guide. It is good at the case budgets miss: a misconfigured job that adds 40 dollars a day starts in the middle of the month, and the budget only notices weeks later.

Per-environment budgets with tags

One account usually holds production, staging and test environments, and a single budget cannot tell which one grew. Cost allocation tags fix that: once a tag key is activated in the Billing console, Cost Explorer and Budgets can filter by its values. Activation is not retroactive, and new tags can take up to 24 hours to appear for activation, so do it early. A budget scoped to one tag value adds a filter to the budget JSON:

{ "BudgetName": "staging-monthly", "BudgetLimit": { "Amount": "80", "Unit": "USD" }, "TimeUnit": "MONTHLY", "BudgetType": "COST", "CostFilters": { "TagKeyValue": ["user:encore-env$staging"] } }

Best fit: a forecast budget for the account, a billing alarm above it, anomaly detection for spikes, and tag-filtered budgets once more than one environment shares the account.

Cost visibility with Encore

Encore

Encore brings infrastructure from code, so the resources that cost money are declared in the application, and a new bucket or topic shows up in the pull request that adds it rather than appearing in the bill a month later. On deploy, Encore provisions them in your own AWS account and applies encore-app, encore-env and encore-id tags to the supported resources, as listed in the resource tagging docs. Activating encore-env as a cost allocation tag is what makes the per-environment budget above work without tagging anything by hand.

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

package exports import ( "encore.dev/pubsub" "encore.dev/storage/objects" "encore.dev/storage/sqldb" ) // Each declaration becomes a tagged resource in the environment's AWS account: // an S3 bucket, an SNS topic with SQS subscriptions, and a database on RDS. var Files = objects.NewBucket("export-files", objects.BucketConfig{}) type ExportRequested struct { ExportID string `json:"export_id"` } var Requested = pubsub.NewTopic[*ExportRequested]("export-requested", pubsub.TopicConfig{ DeliveryGuarantee: pubsub.AtLeastOnce, }) var db = sqldb.NewDatabase("exports", sqldb.DatabaseConfig{Migrations: "./migrations"})

Locally, encore run starts the same database, topic and bucket on your machine, so trying a feature costs nothing in AWS until it is deployed. The object storage, Pub/Sub and AWS infrastructure docs describe what each declaration maps to.

When an AI coding agent adds infrastructure, it does so as a line of code in the diff, which gives the reviewer a natural place to ask what the new resource will cost before it exists.

Best fit: teams running several environments in one AWS account who want spend broken down by environment and infrastructure changes visible in review.

How to approach it

Create the forecast budget first, then the billing alarm in us-east-1, then an anomaly monitor for AWS services. Activate your environment tag as a cost allocation tag on day one, because it only applies to costs from activation onwards, and add a budget per environment once there is more than one.

Frequently asked questions

How do I get an email when my AWS bill goes over a limit?

Create a monthly cost budget in AWS Budgets with an amount and notifications at, for example, 80% actual and 100% forecasted spend, and add your email as a subscriber. AWS checks budgets several times a day and emails when a threshold is crossed.

What is the difference between AWS Budgets and a billing alarm?

A billing alarm is a CloudWatch alarm on the EstimatedCharges metric, which only exists in us-east-1 and only covers the whole account or one service. AWS Budgets supports forecasts, filters by tag, account or service, and notifications for both actual and forecasted spend.

Can AWS stop resources when a budget is exceeded?

Yes, partly. Budget actions can apply an IAM or service control policy or stop specific EC2 and RDS instances when a threshold is reached, but nothing stops all spend automatically, so alerts plus a response plan remain the main protection.

How do I see AWS costs per Encore environment?

Activate the encore-env tag as a cost allocation tag in the Billing console. Encore applies it to the supported resources it provisions, so Cost Explorer and AWS Budgets can then filter spend by environment name.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders