aws-billing-and-cost-management
aws/agent-toolkit-for-aws
Analyze AWS costs, optimize spending, manage budgets, and right-size resources with Compute Optimizer and Cost Optimization Hub.
What is aws-billing-and-cost-management?
This skill provides domain expertise for analyzing AWS spending, evaluating savings opportunities, managing budget alerts, and right-sizing compute resources. Use it when investigating cost trends, setting up budgets, evaluating Savings Plans or Reserved Instances, querying detailed billing data, or detecting cost anomalies.
- Analyze costs by service, account, tag, or time range using Cost Explorer
- Set up and manage budget alerts with optional billing view scoping
- Get right-sizing recommendations for EC2, Lambda, RDS, and EBS via Compute Optimizer
- Evaluate Savings Plans and Reserved Instance purchase decisions
- Look up AWS service pricing using the Price List API
- Query detailed billing data (CUR 2.0) with Athena
How to install aws-billing-and-cost-management
npx skills add https://github.com/aws/agent-toolkit-for-aws --skill aws-billing-and-cost-management- AWS CLI configured with appropriate IAM permissions (billing, cost-explorer, compute-optimizer, budgets)
- Compute Optimizer requires opt-in via `update-enrollment-status --status Active`
- Cost Explorer hourly granularity requires enablement in preferences
- Budgets API requires us-east-1 region
- CUR 2.0 and Athena require prior setup in your AWS account
How to use aws-billing-and-cost-management
- 1.Determine the current date using a tool before making any API calls
- 2.Use Cost Explorer to analyze spending by service, account, or tag for your time period
- 3.Run Cost Optimization Hub to get aggregated savings recommendations across services
- 4.For specific resources, use Compute Optimizer (EC2, Lambda, RDS, EBS) or service-specific references
- 5.Evaluate Savings Plans and Reserved Instance recommendations from Cost Explorer
- 6.Set up budget alerts using the Budgets API, optionally scoped to a billing view
- 7.For detailed analysis, query CUR 2.0 data with Athena or use a Python script for calculations
- 8.Always use a script or calculator tool for numerical operations on cost data—never rely on LLM arithmetic
Use cases
- Conduct a cost audit to identify top cost drivers and optimization opportunities
- Evaluate whether to purchase Savings Plans or Reserved Instances for committed workloads
- Right-size EC2 instances or Lambda functions based on utilization recommendations
- Set up monthly budget alerts for a team or billing group
- Query CUR data to analyze detailed line-item costs by tag or dimension
- Cloud cost engineers and FinOps practitioners
- AWS account owners managing multi-account billing
- Engineering teams optimizing infrastructure spend
- Finance teams tracking and forecasting cloud costs
- DevOps engineers right-sizing compute resources
aws-billing-and-cost-management FAQ
Cost Explorer provides aggregated cost/usage data queryable by service, tag, or dimension with a simple API. CUR 2.0 provides detailed line-item billing data that you query yourself via Athena. Use Cost Explorer for quick analysis; use CUR for deep-dive audits or custom aggregations.
Yes. Run `aws compute-optimizer update-enrollment-status --status Active` before requesting recommendations. The service analyzes your resource utilization over time before generating recommendations.
Yes. Cost Explorer, Cost Forecast, and Budgets support `--billing-view-arn`. Reservation coverage/utilization and Savings Plans coverage/utilization do NOT support billing view scoping.
LLM arithmetic is unreliable. Always use a Python script or calculator tool to sum, average, or compare numbers from API responses. The skill includes patterns in `references/deterministic-calculations.md`.
Using the wrong dimension key (e.g., `CHARGE_TYPE` instead of `RECORD_TYPE`). Call `GetDimensionValues` first to discover valid filter values, or refer to the troubleshooting table in the skill documentation.
Full instructions (SKILL.md)
Source of truth, from aws/agent-toolkit-for-aws.
name: aws-billing-and-cost-management description: | Analyze AWS costs, find savings, manage budgets, evaluate Savings Plans and Reserved Instances, right-size EC2/Lambda/RDS/EBS with Compute Optimizer, look up service pricing, query CUR with Athena, detect cost anomalies, scope costs to billing views, and monitor Free Tier usage. Triggers on: AWS bill, cost analysis, reduce spend, savings plan, reserved instance, right-size, budget alert, cost optimization, pricing, free tier, cost anomaly, CUR, cost audit, billing view, billing view ARN. version: 1
Billing and Cost Management
Overview
Analyze, optimize, and manage AWS costs. This skill encodes domain expertise from AWS's cost management products — gotchas, correct API usage patterns, and optimization workflows that models frequently get wrong.
Usage
Use this skill when:
- Analyzing AWS spending, cost trends, or cost breakdowns
- Setting up or managing budget alerts
- Evaluating Savings Plans or Reserved Instance purchases
- Right-sizing EC2, Lambda, RDS, or EBS resources
- Looking up AWS service pricing
- Running cost audits or investigating cost spikes
- Querying CUR data with Athena
- Scoping cost analysis to a specific billing view
- Checking Free Tier usage
Core Concepts
- Cost Explorer — query cost/usage data by service, account, tag, or time range
- Budgets — set spending thresholds with alerts; supports billing view scoping
- Billing Views — scope cost data to a subset of billing (custom view, billing group, or primary)
- Compute Optimizer — right-sizing recommendations for EC2, Lambda, EBS, RDS
- Cost Optimization Hub — aggregated savings recommendations across services
- Savings Plans / Reserved Instances — commitment-based discounts
- CUR 2.0 — detailed line-item billing data queryable via Athena
Recommended setup: Use the AWS MCP server for sandboxed execution, audit logging, and enterprise controls. See: https://docs.aws.amazon.com/aws-mcp/
Without AWS MCP: All commands use standard AWS CLI syntax and work with any agent that has CLI access.
Critical Rule: Always Check the Current Date
Before making ANY Cost Explorer, Budgets, or Savings Plans API call, you MUST determine the current date. Use a tool to get the current date and time — do NOT assume or guess the year. LLMs frequently default to dates from their training data instead of the actual current date, producing analyses of stale data that appear correct but are completely wrong.
Critical Rule: Deterministic Calculations
You MUST NEVER perform numerical calculations (sums, averages, percentages, comparisons, counts, min/max) by reasoning in your response. LLM arithmetic is unreliable and produces wrong answers on cost data.
You MUST ALWAYS use a script or calculator tool for any math on data returned from API calls. Write a Python script that performs the calculation and prints the result. If the AWS MCP server's run_script tool is available, use it. Otherwise, run the script locally.
Read references/deterministic-calculations.md for patterns and examples.
Decision Guide
| Question | Tool | Reference |
|---|---|---|
| What am I spending? Where are costs going up? | Cost Explorer | references/cost-explorer.md |
| How much does a service cost? | Price List API | references/pricing-lookup.md |
| Where can I save money? (start here) | Cost Optimization Hub | references/cost-optimization-hub.md |
| Should I buy Savings Plans? | CE SP Recommendations | references/savings-plans.md |
| Should I buy Reserved Instances? | CE RI Recommendations | references/reserved-instances.md |
| Deep-dive on a specific EC2/Lambda/EBS/RDS rec? | Compute Optimizer | references/ec2-rightsizing.md, references/lambda-optimization.md, references/rds-optimization.md, references/ebs-optimization.md |
| How do I set up budget alerts? | Budgets | references/budgets.md |
| What's causing a cost spike? | Cost Anomaly Detection | references/cost-explorer.md |
| Am I within Free Tier? | Free Tier API | references/free-tier.md |
| How do I reduce my bill? | Cost Audit workflow | references/cost-audit.md |
| How do I query detailed billing data? | CUR 2.0 + Athena | references/cur-athena.md |
| How do I optimize specific services? | Per-service patterns | references/service-optimization.md |
| How do I scope costs to a billing view? | Billing Views | See Billing Views below |
Common Tasks
Analyze costs by service
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
Default to UnblendedCost. Exclude Credits/Refunds with --filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}'. End date is exclusive.
Run a cost audit
Read references/cost-audit.md for the full 7-step workflow: top cost drivers → month-over-month comparison → optimization recommendations → idle resources → commitment coverage → per-service quick wins → report.
Get right-sizing recommendations
Compute Optimizer requires opt-in first: aws compute-optimizer update-enrollment-status --status Active. Then read references/ec2-rightsizing.md for EC2 or the relevant resource-specific reference.
Look up service pricing
Read references/pricing-lookup.md for service codes and attribute filters. Common trap: Price List API service codes differ from Cost Explorer service names.
Billing Views
A billing view scopes cost and usage data to a specific slice of an account's billing (e.g., a billing group, custom view, or the default primary view). When the user wants to analyze costs through a particular billing view, add --billing-view-arn to supported API calls.
Discover available billing views
aws billing list-billing-views \
--billing-view-types PRIMARY CUSTOM BILLING_GROUP
Requires billing:ListBillingViews permission.
Use a billing view with Cost Explorer
aws ce get-cost-and-usage \
--time-period Start=2026-03-01,End=2026-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE \
--billing-view-arn arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID
Create a budget scoped to a billing view
In the --budget JSON, include the BillingViewArn field:
aws budgets create-budget --account-id ACCOUNT_ID \
--budget '{
"BudgetName": "TeamX-Monthly",
"BudgetLimit": {"Amount": "1000", "Unit": "USD"},
"TimeUnit": "MONTHLY",
"BudgetType": "COST",
"BillingViewArn": "arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID"
}'
API support for --billing-view-arn
Supports --billing-view-arn | Does NOT support it |
|---|---|
ce get-cost-and-usage | ce get-reservation-coverage |
ce get-cost-and-usage-with-resources | ce get-reservation-utilization |
ce get-cost-forecast | ce get-savings-plans-coverage |
ce get-usage-forecast | ce get-savings-plans-utilization |
ce get-dimension-values | |
ce get-tags | |
ce get-cost-comparison-drivers | |
budgets create-budget (in budget JSON) |
Troubleshooting
| Error | Cause | Fix |
|---|---|---|
ValidationException on Cost Explorer | Wrong dimension key (e.g., CHARGE_TYPE instead of RECORD_TYPE) | Use RECORD_TYPE for charge type filtering |
| Empty results with filter | Filter value doesn't match exactly | Call GetDimensionValues first to get valid values |
AccessDeniedException on hourly data | Hourly granularity not enabled | Enable in Cost Explorer preferences |
Account not registered on Compute Optimizer | Not opted in | Run update-enrollment-status --status Active |
| Budgets API fails outside us-east-1 | Budgets requires us-east-1 | Set --region us-east-1 |
Cost Explorer Total empty with GroupBy | By design — totals excluded when grouping | Make separate call without GroupBy, or sum grouped results using a script |
AccessDeniedException on list-billing-views | Missing permission | User needs billing:ListBillingViews permissions |
ValidationException with --billing-view-arn | API doesn't support billing views, or malformed ARN | Check the API support table above; ARN format is arn:aws:billing::ACCOUNT_ID:billingview/VIEW_ID |
Budget shows UNHEALTHY health status | Billing view access revoked or view deleted | Check HealthStatus.StatusReason in describe-budget output; ensure billing:GetBillingViewData is granted |
Additional Resources
- AWS Cost Management User Guide: https://docs.aws.amazon.com/cost-management/
- AWS Pricing Calculator: https://calculator.aws/
- Compute Optimizer User Guide: https://docs.aws.amazon.com/compute-optimizer/
- Well-Architected Cost Optimization Pillar: https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/
Related skills
More from aws/agent-toolkit-for-aws and the wider catalog.

aws-cdk
Author, deploy, and troubleshoot AWS infrastructure with CDK in TypeScript or Python.

aws-cleanrooms
Troubleshoots and debugs AWS Clean Rooms collaboration issues related to IAM roles, S3 bucket policies, KMS keys, Lake Formation permissions, and CloudWatch logging for custom ML model training and inference jobs. Use when a customer reports permission failures, access errors, or log publishing issues in Clean Rooms.

aws-cloudformation
Author, validate, and troubleshoot AWS CloudFormation templates with secure defaults and root-cause diagnostics.

aws-containers
Deploy and operate containerized workloads on ECS, Fargate, and ECR with task definitions, scaling, and debugging.

aws-iam
Verified corrections for IAM edge cases, policy evaluation quirks, and common agent mistakes.

aws-messaging-and-streaming
Choose and implement AWS messaging (SQS, SNS, EventBridge, MQ) and streaming (Kinesis, Firehose, Flink, MSK) services.