Cost Explorer, Budgets, and Cost Allocation Tags
Analyse spend trends in Cost Explorer, set budget alerts before you overspend, and tag resources for showback and chargeback reporting.
Cost Explorer, Budgets, and Cost Allocation Tags is a free AWS Solutions Architect lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Solutions Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Need for Cost Visibility
Without visibility into your AWS spending, cost optimisation is impossible. You cannot improve what you cannot measure. AWS provides three primary tools for cost visibility: Cost Explorer for analysing historical and forecasted spend, AWS Budgets for proactive alerts when spending exceeds thresholds, and Cost Allocation Tags for breaking down costs by team, project, or environment. Together, these tools give you the financial management foundation the Well-Architected Cost Optimisation pillar requires.
# AWS cost management tools:
# Cost Explorer: analyse past spending, forecast
# AWS Budgets: alert when approaching/exceeding limits
# Cost Allocation Tags: attribute costs to teams/projects
# Cost and Usage Report (CUR): granular data to S3 for BI tools
# Billing Dashboard: high-level current month summary
# Savings Plans/RI: analyse commitment coverageCost Explorer: Analysing Spend
AWS Cost Explorer provides a visual interface and API to explore your AWS cost and usage data. You can view spend by service, region, account, resource type, tag, and time period. Cost Explorer also provides 12-month spend forecasts based on historical trends, RI and Savings Plan coverage reports, and cost anomaly detection that uses ML to alert you when spending patterns change unexpectedly. Enable Cost Explorer in the Billing console — it takes 24 hours to populate data.
# Cost Explorer API: get last 30 days spend by service
aws ce get-cost-and-usage \
--time-period Start=2026-05-21,End=2026-06-21 \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=DIMENSION,Key=SERVICE \
--query 'ResultsByTime[0].Groups[].{Service:Keys[0],Cost:Metrics.BlendedCost.Amount}' \
--output table
# Example output:
# Amazon EC2: $8,450
# Amazon RDS: $2,200
# Amazon S3: $430
# AWS Lambda: $85Cost Anomaly Detection
AWS Cost Anomaly Detection uses machine learning to continuously monitor your costs and alert you to unexpected increases. It learns your normal spending patterns and detects statistically significant deviations. You configure anomaly monitors (what to monitor: service, linked account, cost category, or tag) and alert subscriptions (SNS email or Slack webhook when anomalies exceed a threshold). Anomaly Detection is invaluable for catching runaway Lambda costs, accidental large EC2 instance launches, or unexpected data transfer charges before they escalate.
# Create Cost Anomaly Detection monitor
aws ce create-anomaly-monitor \
--anomaly-monitor '{
"MonitorName": "AllServicesMonitor",
"MonitorType": "DIMENSIONAL",
"MonitorDimension": "SERVICE"
}'
# Create alert subscription for anomalies > $100
aws ce create-anomaly-subscription \
--anomaly-subscription '{
"SubscriptionName": "daily-anomaly-alert",
"MonitorArnList": ["arn:aws:ce::123:anomalymonitor/xxx"],
"Subscribers": [{"Address":"finops@example.com","Type":"EMAIL"}],
"Threshold": 100,
"Frequency": "DAILY"
}'AWS Budgets: Proactive Cost Alerts
AWS Budgets lets you set custom spending thresholds and receive alerts when actual or forecasted spend crosses them. Four budget types: Cost Budget (dollar amount), Usage Budget (hours, GB, requests), RI Utilisation Budget (alert if utilisation drops below threshold), and Savings Plans Utilisation Budget. Configure multiple alert thresholds per budget (e.g., 50%, 80%, 100% of budget, plus 110% of actual). Notifications go to email or SNS, and Budget Actions can automatically apply SCPs or IAM policies to stop further spending.
# Create monthly cost budget with alerts
aws budgets create-budget \
--account-id 123456789012 \
--budget '{
"BudgetName": "monthly-production-budget",
"BudgetLimit": {"Amount": "10000", "Unit": "USD"},
"TimeUnit": "MONTHLY",
"BudgetType": "COST"
}' \
--notifications-with-subscribers '[{
"Notification": {
"NotificationType": "ACTUAL",
"ComparisonOperator": "GREATER_THAN",
"Threshold": 80,
"ThresholdType": "PERCENTAGE"
},
"Subscribers": [{"SubscriptionType":"EMAIL","Address":"cto@example.com"}]
}]'Budget Actions for Automated Response
AWS Budget Actions can automatically respond when a budget threshold is breached — no human required. You can configure actions to: Apply an IAM policy that denies the ability to launch new EC2 instances. Apply a Service Control Policy (SCP) to an AWS Organizations target. Stop EC2 or RDS instances that are over budget. For example, a development account budget can automatically stop all EC2 instances if the monthly budget exceeds $5,000, preventing runaway costs from forgotten test environments.
# Budget Action: stop EC2 instances when budget exceeded
aws budgets create-budget-action \
--account-id 123456789012 \
--budget-name monthly-dev-budget \
--notification-type ACTUAL \
--action-type STOP_EC2_INSTANCES \
--action-threshold '{
"ActionThresholdValue": 100,
"ActionThresholdType": "PERCENTAGE"
}' \
--definition '{
"SsmActionDefinition": {
"ActionSubType": "STOP_EC2_INSTANCES",
"Region": "us-east-1",
"InstanceIds": ["i-dev-1","i-dev-2"]
}
}' \
--execution-role-arn arn:aws:iam::123:role/BudgetActionsRole \
--approval-model AUTOMATICCost Allocation Tags
Cost Allocation Tags enable you to attribute AWS costs to specific business dimensions. Two types: AWS-generated tags (e.g., aws:createdBy) and user-defined tags (your custom key-value pairs). You must activate tags in the Billing console before they appear in cost reports. Once activated, tags flow into Cost Explorer, CUR, and Budgets for filtering. Define a tag taxonomy: Project, Environment, Team, CostCenter — enforce it with Tag Policies in AWS Organizations.
# Tag an EC2 instance with cost allocation tags
aws ec2 create-tags \
--resources i-1234567890abcdef0 \
--tags \
Key=Project,Value=OrderService \
Key=Environment,Value=Production \
Key=Team,Value=PlatformEng \
Key=CostCenter,Value=CC-1042
# Activate tag in Billing console (CLI)
aws ce create-cost-category-definition \
--name ProjectCosts \
--rules '[{"Value":"OrderService","Rule":{"Tags":{"Key":"Project","Values":["OrderService"]}}}]'Tag Enforcement with Tag Policies
Tags are only useful if consistently applied. Tag Policies in AWS Organizations enforce tag key and value formats across all accounts in an organisation. A tag policy can specify that the Environment tag must exist and must be one of Production, Staging, or Development. Non-compliant resources appear in the tag policy compliance report. Combine tag policies with AWS Config rules (e.g., required-tags) to detect and alert on untagged resources before they accumulate costs you cannot attribute.
# Create Tag Policy in AWS Organizations
aws organizations create-policy \
--name RequiredTagsPolicy \
--type TAG_POLICY \
--content '{
"tags": {
"Environment": {
"tag_key": {"@@assign": "Environment"},
"tag_value": {"@@assign": ["Production","Staging","Development"]}
},
"Project": {
"tag_key": {"@@assign": "Project"}
}
}
}'
# Attach to an OU
aws organizations attach-policy \
--policy-id p-12345 \
--target-id ou-root-abc123Cost and Usage Report (CUR)
The AWS Cost and Usage Report (CUR) is the most granular billing data available — hourly line items for every resource in your account, including resource IDs, tags, Savings Plan coverage, and blended/unblended costs. CUR data is delivered to an S3 bucket in CSV or Parquet format. Query it with Amazon Athena for custom analysis, or feed it into Amazon QuickSight for dashboards. CUR is essential for organisations that need fine-grained showback or chargeback to business units.
# Create CUR definition (deliver to S3)
aws cur put-report-definition \
--report-definition '{
"ReportName": "my-cost-report",
"TimeUnit": "HOURLY",
"Format": "Parquet",
"Compression": "Parquet",
"AdditionalSchemaElements": ["RESOURCES"],
"S3Bucket": "my-cur-bucket",
"S3Prefix": "reports",
"S3Region": "us-east-1",
"ReportVersioning": "OVERWRITE_REPORT",
"IncludeResourceIds": true
}'
# Query with Athena:
# SELECT resource_id, sum(line_item_blended_cost)
# FROM cur_table
# WHERE resource_tags_user_project = 'OrderService'
# GROUP BY resource_idCost Categories for Logical Grouping
AWS Cost Categories let you map cost and usage into meaningful business categories using rules. For example, you can create a category called Production Environment that includes all resources tagged Environment=Production plus specific account IDs. Categories appear in Cost Explorer as a filter dimension, making it easy to see total production vs development costs even if your tagging is inconsistent. Cost Categories support rule-based mapping, so they can compensate for incomplete or inconsistent tagging historically.
# Create a Cost Category
aws ce create-cost-category-definition \
--name 'EnvironmentType' \
--rules '[{
"Value": "Production",
"Rule": {"Tags":{"Key":"Environment","Values":["prod","production","PROD"]}}
},{
"Value": "Development",
"Rule": {"Tags":{"Key":"Environment","Values":["dev","development","test"]}}
}]' \
--default-value 'Untagged'
# Use in Cost Explorer to filter:
# Filter: CostCategory = Production
# See all production costs regardless of tag variationsBuilding a FinOps Practice
FinOps (Financial Operations for the cloud) is the practice of managing cloud costs as a team responsibility, not just a finance function. Key practices: Visibility — every team can see their own spending in Cost Explorer. Accountability — teams own their cost allocations and budgets. Optimisation — regular right-sizing and RI/SP review. Forecasting — predict future spend using Cost Explorer forecasts. On AWS, implement FinOps by creating per-team AWS accounts under Organizations, per-team budgets, tag policies, and monthly cost reviews with engineering leads.
# FinOps implementation checklist:
# [ ] Activate cost allocation tags in Billing console
# [ ] Enable Cost Anomaly Detection
# [ ] Create monthly budgets per team/account
# [ ] Set up Budget Actions for dev accounts
# [ ] Enable CUR delivery to S3
# [ ] Create Athena tables over CUR for ad-hoc queries
# [ ] Build QuickSight dashboard for leadership
# [ ] Schedule monthly cost review meetings
# [ ] Track month-over-month cost per unit of workCost Forecasting and Planning
Cost Explorer forecasting uses your historical usage patterns to predict future costs up to 12 months out. This helps with budget planning and capacity planning. For new workloads with no history, use the AWS Pricing Calculator to estimate costs before deployment. Always add a 20-30% buffer to your forecast to account for unexpected growth or new services. For organisations with complex cost structures, consider AWS Budgets** reports that automatically generate monthly cost summaries delivered to email or S3.
# Get 3-month cost forecast
aws ce get-cost-forecast \
--time-period Start=2026-07-01,End=2026-09-30 \
--metric BLENDED_COST \
--granularity MONTHLY \
--filter '{
"Dimensions": {
"Key": "SERVICE",
"Values": ["Amazon EC2"]
}
}' \
--query 'ForecastResultsByTime[].{Month:TimePeriod.Start,Forecast:MeanValue,Lower:PredictionIntervalLowerBound,Upper:PredictionIntervalUpperBound}'Quick Check
Test your understanding of AWS Solutions Architect (SAA-C03) concepts from this lesson.
Lesson Recap
In this lesson you learned: Cost Explorer analyses historical and forecasted spend with cost anomaly detection, AWS Budgets provides proactive alerts and automated Budget Actions when thresholds are exceeded, and Cost Allocation Tags enable showback and chargeback by attributing costs to teams, projects, and environments. Tag Policies in AWS Organizations enforce consistent tagging. Next up we explore S3 and data transfer cost optimisation techniques.
Frequently asked questions
Is the “Cost Explorer, Budgets, and Cost Allocation Tags” lesson free?
Yes — the full text of “Cost Explorer, Budgets, and Cost Allocation Tags” is free to read here on the web, and the AWS Solutions Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Solutions Architect course, upgrade to CoddyKit PRO.
What will I learn in “Cost Explorer, Budgets, and Cost Allocation Tags”?
Analyse spend trends in Cost Explorer, set budget alerts before you overspend, and tag resources for showback and chargeback reporting. You practise AWS Solutions Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Solutions Architect?
No prior experience is required. AWS Solutions Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Cost Explorer, Budgets, and Cost Allocation Tags” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Solutions Architect lesson?
Yes. Every AWS Solutions Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Right-Sizing and Compute Optimizer
- Reserved Instances, Savings Plans, and Spot
- Cost Explorer, Budgets, and Cost Allocation Tags
- S3 and Data Transfer Cost Optimisation