Skip to Content
Cloud Engineering Academy
0. Orientation & a Safe Learning Environment

Cost guardrails: budgets, alarms and the usual traps

Set up a zero-spend budget, a small monthly budget, a billing alarm, Cost Anomaly Detection and Free Tier alerts, and learn which resources quietly cost money.

beginnerโฑ 1 h ๐ŸŸข FreeCLF-C02SAA-C03

Assumes: .NET 10 LTS ยท AWS SDK for .NET v4 ยท AWS CLI v2 ยท Region us-east-1 ยท Terraform AWS provider 6.73. Verified against official sources on 2026-11-17.

Learning objectives

By the end of this lesson you can:

  • Create a zero-spend budget and a monthly cost budget with actual and forecasted alerts.
  • Create a CloudWatch billing alarm on the EstimatedCharges metric in us-east-1.
  • Tune Cost Anomaly Detection so it alerts on a learner-sized spike, not the default USD 100.
  • Opt the management account in to Free Tier usage alerts.
  • Name the common cost traps (NAT Gateway, idle load balancers, RDS, public IPv4, KMS keys, Secrets Manager, log retention, EBS volumes and snapshots, forgotten Regions) and their approximate monthly cost.

Prerequisites

  • Secure your AWS account โ€” you need the management account and the BillingViewer / ManagementAdmin permission sets.
  • IAM access to billing activated (done by root in the previous lesson).
  • Tools: browser; optionally AWS CLI v2 with a learn-management profile (Tooling setup).

Why this matters in banking

Banks are cost-conscious in a very specific way: unexpected spend is an operational risk signal. A sudden cost jump may mean a runaway batch job, a misconfigured auto-scaling group, or an attacker mining cryptocurrency with stolen credentials. FinOps and security teams watch the same dashboards. If you learn to treat a budget alert as an incident trigger โ€” "something is running that I did not expect" โ€” you are already thinking like a bank's cloud engineer.

The idea in plain language

AWS charges for what you use, mostly by the hour or by the gigabyte, and the bill arrives at the end of the month. Nothing stops spending automatically. So you install alarms that tell you early:

  • AWS Budgets compares actual (and forecasted) spend against an amount you choose and emails you.
  • The billing alarm is a CloudWatch alarm on the estimated monthly charges โ€” a second, independent alarm.
  • Cost Anomaly Detection uses machine learning to spot spend that is unusual for you, even if it is below your budget.
  • Free Tier usage alerts warn you when a service passes 85% of its free allowance.

Analogy: Budgets are the monthly spending limit you set on a debit card app. The billing alarm is the bank texting you when your balance crosses a line. Anomaly detection is the fraud team noticing a payment that does not look like you. None of them freezes the card โ€” you still have to act.

What problem these tools solve

ToolWhat it doesCostLimitations
AWS BudgetsAlerts on actual or forecasted cost/usageFree for alert-only budgets. First two action-enabled budgets free, then USD 0.10 per day each; budget reports USD 0.01 eachData updates up to three times a day; alerts can arrive hours after the spend
CloudWatch billing alarmAlarm on AWS/Billing โ†’ EstimatedChargesWithin the CloudWatch free tier of 10 standard alarm metricsMetric exists only in us-east-1; must enable "Receive CloudWatch billing alerts"; cannot be disabled once enabled
Cost Anomaly DetectionML-based spike detection with daily/weekly summaries or individual alertsNo charge โš  VERIFY on the pricing page (not stated on the pages checked)Needs some spend history; default subscription threshold is high (USD 100 and 40%)
Free Tier usage alertsEmail at 85% of a service's free allowanceFreeOn by default for standalone accounts, off for a management account until you opt in
Cost ExplorerCharts and filters of your costsConsole use is free; API calls USD 0.01 eachData available about 24 hours after you first open it

The honest limitation: every one of these is an alert, not a brake. Billing data lags real usage by hours. A NAT Gateway left running overnight will cost money before any email reaches you. Your real protection is the teardown habit; alerts are the safety net.

Microsoft / Azure comparison

You know (Azure)AWS equivalentWhat's different
Cost Management + Billing โ†’ BudgetsAWS BudgetsAWS Budgets also supports usage, RI and Savings Plans budgets; budget actions can apply an IAM policy or SCP automatically
Azure cost alerts / anomaly alertsCost Anomaly DetectionCreated automatically when you enable Cost Explorer, with a high default threshold you should lower
Azure Monitor alert on a cost metricCloudWatch billing alarmThe billing metric lives only in us-east-1 and is in USD
Azure free account (12 months + credits)Free plan / Paid plan with credits + always-free offersFree plan accounts close after 6 months; Paid plan accounts never close and bill beyond credits
Spending limit on Azure free/credit subscriptionsNo hard spending limit on the Paid planOnly the Free plan caps spend (by closing/limiting); otherwise you rely on alerts and actions

Architecture

All guardrails live in the management account because it receives the consolidated bill for every member account. A forgotten resource in the sandbox still triggers them.

Step-by-step implementation

Sign in to the access portal and open the management account with ManagementAdmin.

Create the zero-spend budget

Billing and Cost Management โ†’ Budgets โ†’ Create budget โ†’ Use a template (simplified) โ†’ Zero spend budget. Name it cea-zero-spend, add your email, create. It alerts as soon as spend goes above the free allowances. On the Paid plan, credits may cover early charges, so this alert tells you that credits are being consumed โ€” exactly what you want to know.

This also completes the "set up a cost budget" activity that earns USD 20 of credits for new customers.

Create a small monthly budget

Create budget โ†’ Use a template โ†’ Monthly cost budget. Name cea-monthly-5usd, amount 5.00 USD, your email. The template notifies you when you exceed, or are forecasted to exceed, the amount. Then edit the budget (or choose Custom under template settings) and add an alert at 50% of actual spend so you hear about problems earlier.

Enable billing alerts and create the billing alarm

  1. Billing and Cost Management โ†’ Billing preferences โ†’ Alert preferences โ†’ Edit: tick Receive CloudWatch billing alerts and Receive AWS Free Tier alerts, add your email, save. Wait about 15 minutes for the metric to appear.
  2. Switch the console Region to US East (N. Virginia).
  3. CloudWatch โ†’ Alarms โ†’ All alarms โ†’ Create alarm โ†’ Select metric โ†’ Billing โ†’ Total Estimated Charge โ†’ EstimatedCharges (USD).
  4. Statistic Maximum, period 6 hours, condition Greater than 10.
  5. Notification: create a new SNS topic cea-billing-alerts with your email; confirm the subscription email.
  6. Name the alarm cea-billing-over-10usd and create it.

Tune Cost Anomaly Detection

Open Cost Explorer once (this enables it and, at the same time, creates a default AWS services monitor with a daily summary alert for anomalies over USD 100 and 40%). Then Cost Anomaly Detection โ†’ Alert subscriptions โ†’ edit the default subscription: set the threshold to absolute impact at least USD 5, keep Daily summaries, and make sure your email is a recipient. If no monitor exists yet, create one: Cost monitors โ†’ Create monitor โ†’ Managed by AWS โ†’ AWS services.

Test that alerts reach you

Check your inbox for the SNS subscription confirmation and the budget creation notices. In CloudWatch the alarm should show OK (or Insufficient data for the first hours). If you want to see an email arrive, temporarily lower the alarm threshold to 0, wait for the next data point, then set it back to 10.

AWS Console instructions

Navigation used (checked 2026-11-17):

  • Billing and Cost Management โ†’ Budgets โ†’ Create budget โ†’ Use a template (simplified)
  • Billing and Cost Management โ†’ Billing preferences โ†’ Alert preferences โ†’ Edit
  • CloudWatch (us-east-1) โ†’ Alarms โ†’ All alarms โ†’ Create alarm โ†’ Billing โ†’ Total Estimated Charge
  • Billing and Cost Management โ†’ Cost Explorer (first visit enables it) and โ†’ Cost Anomaly Detection โ†’ Cost monitors / Alert subscriptions

AWS CLI

Run with the learn-management profile. JSON goes in files because PowerShell quoting of inline JSON is error-prone.

budget-monthly.json
{
  "BudgetName": "cea-monthly-5usd",
  "BudgetLimit": { "Amount": "5", "Unit": "USD" },
  "TimeUnit": "MONTHLY",
  "BudgetType": "COST"
}
budget-notifications.json
[
  {
    "Notification": { "NotificationType": "ACTUAL", "ComparisonOperator": "GREATER_THAN", "Threshold": 50, "ThresholdType": "PERCENTAGE" },
    "Subscribers": [ { "SubscriptionType": "EMAIL", "Address": "alex+aws-billing@example.com" } ]
  },
  {
    "Notification": { "NotificationType": "FORECASTED", "ComparisonOperator": "GREATER_THAN", "Threshold": 100, "ThresholdType": "PERCENTAGE" },
    "Subscribers": [ { "SubscriptionType": "EMAIL", "Address": "alex+aws-billing@example.com" } ]
  }
]
# Your management account ID (budgets are created per account).
$acct = aws sts get-caller-identity --query Account --output text --profile learn-management

# Create the monthly budget with two notifications.
aws budgets create-budget --account-id $acct --budget file://budget-monthly.json --notifications-with-subscribers file://budget-notifications.json --profile learn-management

# List budgets to confirm.
aws budgets describe-budgets --account-id $acct --query "Budgets[].BudgetName" --profile learn-management

# SNS topic + email subscription for the billing alarm (must be us-east-1).
$topic = aws sns create-topic --name cea-billing-alerts --region us-east-1 --query TopicArn --output text --profile learn-management
aws sns subscribe --topic-arn $topic --protocol email --notification-endpoint alex+aws-billing@example.com --region us-east-1 --profile learn-management

# Billing alarm: Maximum of EstimatedCharges over 6 hours greater than 10 USD.
aws cloudwatch put-metric-alarm --region us-east-1 --profile learn-management `
  --alarm-name cea-billing-over-10usd --namespace AWS/Billing --metric-name EstimatedCharges `
  --dimensions Name=Currency,Value=USD --statistic Maximum --period 21600 --evaluation-periods 1 `
  --threshold 10 --comparison-operator GreaterThanThreshold --treat-missing-data missing `
  --alarm-actions $topic

# Cost Anomaly Detection: see existing monitors and subscriptions (one may have been created for you).
aws ce get-anomaly-monitors --profile learn-management
aws ce get-anomaly-subscriptions --profile learn-management
anomaly-threshold.json
{
  "Dimensions": {
    "Key": "ANOMALY_TOTAL_IMPACT_ABSOLUTE",
    "Values": ["5"],
    "MatchOptions": ["GREATER_THAN_OR_EQUAL"]
  }
}
# Lower the default subscription's threshold to an absolute USD 5 impact.
aws ce update-anomaly-subscription --subscription-arn arn:aws:ce::444455556666:anomalysubscription/00000000-0000-0000-0000-000000000000 --threshold-expression file://anomaly-threshold.json --profile learn-management

Infrastructure as Code

guardrails.tf
variable "alert_email" {
  type        = string
  description = "Where budget and billing alerts are sent"
}

provider "aws" {
  region  = "us-east-1" # the billing metric only exists here
  profile = "learn-management"
}

resource "aws_budgets_budget" "monthly" {
  name         = "cea-monthly-5usd"
  budget_type  = "COST"
  limit_amount = "5"
  limit_unit   = "USD"
  time_unit    = "MONTHLY"

  notification {
    comparison_operator        = "GREATER_THAN"
    threshold                  = 50
    threshold_type             = "PERCENTAGE"
    notification_type          = "ACTUAL"
    subscriber_email_addresses = [var.alert_email]
  }

  notification {
    comparison_operator        = "GREATER_THAN"
    threshold                  = 100
    threshold_type             = "PERCENTAGE"
    notification_type          = "FORECASTED"
    subscriber_email_addresses = [var.alert_email]
  }
}

resource "aws_sns_topic" "billing" {
  name = "cea-billing-alerts"
}

resource "aws_sns_topic_subscription" "email" {
  topic_arn = aws_sns_topic.billing.arn
  protocol  = "email"
  endpoint  = var.alert_email # you must click the confirmation link in the email
}

resource "aws_cloudwatch_metric_alarm" "billing" {
  alarm_name          = "cea-billing-over-10usd"
  namespace           = "AWS/Billing"
  metric_name         = "EstimatedCharges"
  dimensions          = { Currency = "USD" }
  statistic           = "Maximum"
  period              = 21600
  evaluation_periods  = 1
  threshold           = 10
  comparison_operator = "GreaterThanThreshold"
  treat_missing_data  = "missing"
  alarm_actions       = [aws_sns_topic.billing.arn]
}

Complete code

The budget JSON, CLI script and IaC above are complete and runnable. There is no C# application in this lesson; the module's C# code is the verify-setup lab.

Code explained line by line

Budget JSON and notifications:

  1. "BudgetType": "COST" โ€” track money (not usage hours or RI coverage).
  2. "BudgetLimit": { "Amount": "5", "Unit": "USD" } โ€” the monthly amount. Note the amount is a string in the CLI JSON.
  3. "TimeUnit": "MONTHLY" โ€” resets on the first of each month.
  4. "NotificationType": "ACTUAL" with Threshold: 50 and PERCENTAGE โ€” email when real spend passes USD 2.50.
  5. "NotificationType": "FORECASTED" with Threshold: 100 โ€” email when AWS predicts you will exceed USD 5 this month. Forecasts need some history, so this alert is quiet in a brand-new account.

Billing alarm:

  1. --namespace AWS/Billing --metric-name EstimatedCharges --dimensions Name=Currency,Value=USD โ€” the month-to-date estimated total for the whole account (or organisation, in the payer account).
  2. --statistic Maximum --period 21600 โ€” the highest value in each 6-hour window; the metric only updates a few times a day, so shorter periods add nothing.
  3. --treat-missing-data missing โ€” gaps between data points neither trigger nor clear the alarm.
  4. --alarm-actions $topic โ€” publish to SNS, which emails you.

Security considerations

  • Send alerts to an inbox you actually read, and add a second recipient if possible (a partner, or a work-unrelated second address).
  • Billing data reveals what you run; keep BillingViewer separate from admin roles so you can check costs without admin power.
  • An unexpected cost spike can be a security event (leaked credentials used for crypto-mining). If you cannot explain a spike within minutes, rotate access by signing out all sessions and check for unknown resources in every Region.

โš  Learning shortcut โ€” not for production

The SNS topic here is not encrypted with a KMS key. Its messages contain only alarm metadata, and encrypting it properly needs a customer managed KMS key (USD 1 per month) whose key policy lets CloudWatch publish โ€” the AWS managed alias/aws/sns key does not allow that โš  VERIFY. In a bank, alerting topics are encrypted with a customer managed key, budgets are owned per cost centre, and budget actions can automatically attach a deny policy when a threshold is crossed.

Banking use case

"Harbour Bank" (fictional) gives every development team a sandbox account with a monthly budget. At 80% of budget, a budget action attaches a restrictive SCP that blocks creating new EC2, RDS and NAT Gateway resources; the team lead is paged; existing workloads keep running. Cost Anomaly Detection runs on a managed Linked account monitor in the management account and posts to the FinOps channel, while the security operations team receives the same anomalies because a spike in GPU instance hours is a classic sign of compromised credentials.

Cost traps you will meet in this course

Prices are US East (N. Virginia), on-demand, checked 2026-11-17 on the official pricing pages. A month is taken as 730 hours. Your credits may cover these, but they still burn credits.

TrapHow it billsApprox. cost if forgottenHow it sneaks up on youHow to find it
NAT GatewayUSD 0.045 per hour + USD 0.045 per GB processedabout USD 33/month each, before dataVPC wizards offer "1 NAT Gateway per AZ" โ€” three AZs is about USD 99/month idleVPC โ†’ NAT gateways (every Region)
Application Load BalancerUSD 0.0225 per hour (partial hours billed as full) + USD 0.008 per LCU-hourabout USD 16/month idleLeft behind when you delete the ECS service or Beanstalk app but not the ALBEC2 โ†’ Load balancers
RDS databasePer hour while running, plus storage and backupsdb.t4g.micro PostgreSQL Single-AZ USD 0.016/h โ‰ˆ USD 11.68/month; SQL Server Express db.t3.micro USD 0.022/h โ‰ˆ USD 16/month; Multi-AZ roughly doubles"Stopped" RDS instances restart automatically after 7 consecutive days; snapshots keep billingRDS โ†’ Databases and Snapshots
Public IPv4 addressesUSD 0.005 per hour per address, in use or idle (includes Elastic IPs)about USD 3.65/month per addressEvery public subnet instance, NAT Gateway and ALB node uses themVPC โ†’ Public IPs / EC2 โ†’ Elastic IPs; Amazon VPC IP Address Manager public IP insights
KMS customer managed keysUSD 1 per key per month (prorated hourly), +USD 1/month for each of the first two rotations; 20,000 free requests/monthUSD 1โ€“3/month per keyEvery lab that creates "its own key" adds one; keys pending deletion are not chargedKMS โ†’ Customer managed keys (every Region)
Secrets ManagerUSD 0.40 per secret per month + USD 0.05 per 10,000 API callsUSD 0.40/month per secretEach RDS lab can create a managed master-user secretSecrets Manager โ†’ Secrets
CloudWatch Logs retentionUSD 0.50 per GB ingested (Standard) + USD 0.03 per GB-month stored; 5 GB/month freeGrows foreverNew log groups default to Never expire; a chatty Lambda in a loop can ingest GBs per dayCloudWatch โ†’ Log groups โ†’ Retention column
EBS volumes and snapshotsgp3 USD 0.08 per GB-month; snapshots USD 0.05 per GB-monthUSD 2.40/month for a 30 GB volumeTerminating an instance may leave extra volumes; AMIs keep their snapshotsEC2 โ†’ Volumes (state "available") and Snapshots
Forgotten RegionsAny of the above, in a Region you never look atAnythingConsole defaults to the last Region used; a tutorial used eu-central-1Billing โ†’ Bills โ†’ charges by Region; Tag Editor with All regions

The Region-restricting SCP from the previous lesson shrinks the last trap to two Regions, and the teardown checklist catches the rest.

Common mistakes

  • Creating the billing alarm in your usual Region โ†’ the metric is missing โ†’ the billing metric exists only in us-east-1.
  • Not confirming the SNS subscription email โ†’ the alarm fires into the void โ†’ check the topic's subscription status is "Confirmed".
  • Relying on the default anomaly threshold โ†’ USD 100 and 40% is far above learner spend โ†’ lower it to USD 5.
  • Assuming management accounts get Free Tier alerts โ†’ they do not by default โ†’ tick "Receive AWS Free Tier alerts".
  • Thinking a budget stops spending โ†’ it only notifies (unless you configure actions) โ†’ delete resources yourself.
  • Assuming "free tier eligible" means free โ†’ limits are monthly and per service; on the Free plan only always-free offers apply โ†’ read the limit, not the badge.

Troubleshooting

SymptomLikely causeFix
No Billing namespace in CloudWatchBilling alerts not enabled, or wrong RegionEnable "Receive CloudWatch billing alerts"; switch to us-east-1; wait about 15 minutes
"Access denied" on Budgets or Cost ExplorerIAM access to billing not activated, or permission set lacks billing permissionsActivate IAM access as root once; use ManagementAdmin or BillingViewer
Budget shows USD 0 although you used resources todayBilling data delay (up to three updates per day)Wait; check Cost Explorer the next day
Alarm stuck in Insufficient dataNew metric, few data pointsNormal for the first hours; it moves to OK after data arrives
Cost Explorer says data is being preparedFirst visit enables itCurrent-month data appears in about 24 hours
Credits shown but charges still appearSome services or usage types are not covered by credits, or credits expiredBilling โ†’ Credits shows what applies; check the service list on the Free Tier page

Cost and cleanup

Cost: USD 0. Alert-only budgets are free, one billing alarm is within CloudWatch's free alarms, and a handful of alert emails is negligible (SNS email free allowance โš  VERIFY on the SNS pricing page โ€” it is not listed on the page checked). Keep these guardrails for the whole course.

If you ever remove them:

aws budgets delete-budget --account-id $acct --budget-name cea-monthly-5usd --profile learn-management
aws cloudwatch delete-alarms --alarm-names cea-billing-over-10usd --region us-east-1 --profile learn-management
aws sns delete-topic --topic-arn $topic --region us-east-1 --profile learn-management

Exercises

  • ๐ŸŸข Guided: Create the zero-spend budget, the USD 5 monthly budget, the billing alarm and the tuned anomaly subscription. Screenshot nothing โ€” instead, list each guardrail with its name and threshold in your learning journal.
  • ๐ŸŸก Challenge: Create a budget action on the monthly budget that, at 100% of actual spend, attaches an SCP to the Sandbox OU denying ec2:RunInstances, rds:CreateDBInstance and ec2:CreateNatGateway. Test the SCP manually (attach and detach) rather than by spending money.
  • ๐Ÿ”ด Live problem: On day 9 of the month you receive: "AWS Budgets: cea-monthly-5usd has exceeded 50%". You have not deployed anything for three days. Find the cause using only billing tools, decide what to delete, and write a five-line incident note.

Assignment

Add infra/guardrails/ to your learning-journal repository with the Terraform (or CDK) above, parameterised by email, plus a README.md explaining each alert, its threshold and why you chose it.

Solutions

Knowledge check

Interview questions

  • "How do you prevent surprise cloud bills in a development environment?" โ€” Separate accounts, budgets per account with actions, anomaly detection, mandatory tags, IaC so environments can be destroyed and rebuilt, scheduled shutdown of non-production, and a review of the top cost drivers each week.
  • "A developer says the AWS bill doubled. Where do you start?" โ€” Cost Explorer grouped by service, account, Region and usage type over daily granularity; then correlate with deployments and CloudTrail; check for leaked credentials if usage is unfamiliar.

Certification practice

Completion checklist

  • Zero-spend and USD 5 monthly budgets exist and I received the emails
  • Billing alerts enabled; cea-billing-over-10usd alarm in us-east-1 with a confirmed SNS email
  • Cost Anomaly Detection subscription threshold lowered to USD 5
  • Free Tier alerts opted in for the management account
  • I can name five cost traps and roughly what each costs per month

Key takeaways

  • Budgets, billing alarms and anomaly detection are alerts, not brakes โ€” teardown is the real control.
  • Put guardrails in the management account so they cover every member account.
  • The billing metric lives in us-east-1; enable it before creating the alarm.
  • Lower the default Cost Anomaly Detection threshold (USD 100 and 40%) to a learner-sized amount.
  • The biggest silent costs are hourly: NAT Gateways, load balancers, databases and public IPv4 addresses.

Further reading

Independent learning resource โ€” not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page