AWS Billing And Cost Management
AWSOfficialPublished by AWS
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to managing AWS expenditures by leveraging native cost management services. It includes workflows for identifying cost drivers, auditing resource utilization, and implementing savings strategies through commitment-based discounts and right-sizing recommendations. The skill emphasizes data-driven decision-making, requiring users to perform calculations via scripts to ensure accuracy and to verify current dates before executing queries to avoid stale data analysis.
What it does
- Analyzes AWS cost trends and identifies top spending drivers.
- Provides workflows for right-sizing EC2, Lambda, RDS, and EBS resources.
- Evaluates Savings Plans and Reserved Instance coverage and utilization.
- Configures budget alerts and monitors Free Tier usage.
- Queries detailed billing data using CUR and Athena.
- Detects cost anomalies and scopes analysis to specific billing views.
When to use it
- When you need to perform a comprehensive monthly cost audit.
- When investigating unexpected spikes in your AWS bill.
- When evaluating whether to purchase or renew Savings Plans or Reserved Instances.
- When identifying idle or underutilized resources to reduce waste.
- When setting up automated budget alerts for specific teams or projects.
Advantages
- Reduces human error by mandating script-based calculations for all cost data.
- Prevents stale data analysis by enforcing date verification.
- Consolidates complex AWS cost management workflows into a single reference.
- Supports granular cost scoping using Billing View ARNs.
- Provides clear, actionable steps for both immediate and long-term cost optimization.
Usage examples
- “What are my top AWS cost drivers for the last month?”
- The agent will execute a cost-and-usage query grouped by service, filter out credits/refunds, and present a table of the highest spending services.
- “Are there any idle resources I can delete to save money?”
- The agent will scan for unattached EBS volumes and idle Elastic IPs, providing a list of resources that can be safely removed.
- “Should I purchase a Savings Plan?”
- The agent will analyze your current usage patterns and commitment coverage to provide a data-backed recommendation on potential savings.
- “Set up a monthly budget alert for my production environment.”
- The agent will create a budget with specified thresholds and notification subscribers, scoped to your production billing view.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/aws/aws-billing-and-cost-management/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip aws-billing-and-cost-management.zip -d .agents/skills
Documentation by AWS
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=SERVICEDefault 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_GROUPRequires 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_IDCreate 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/
Files
- ATTRIBUTION.mdAdded by AutoGineer927 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer67 B
- SKILL.md8.9 KiB
- references/budgets.md2.4 KiB
- references/cost-audit.md3.2 KiB
- references/cost-explorer.md7.3 KiB
- references/cost-optimization-hub.md7.2 KiB
- references/cur-athena.md7.0 KiB
- references/deterministic-calculations.md2.5 KiB
- references/ebs-optimization.md2.7 KiB
- references/ec2-rightsizing.md3.3 KiB
- references/free-tier.md1.6 KiB
- references/lambda-optimization.md2.2 KiB
- references/pricing-lookup.md3.8 KiB
- references/rds-optimization.md1.8 KiB
- references/reserved-instances.md2.3 KiB
- references/savings-plans.md3.3 KiB
- references/service-optimization.md3.0 KiB
references/cost-explorer.md
Cost Explorer API Patterns
Pricing note: All prices shown are approximate as of early 2026 and may change. Always verify current pricing before reporting to users.
Defaults
Metric:
UnblendedCost(single account). UseAmortizedCostwhen customer has SPs/RIs.Exclude Credits/Refunds:
--filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}'End date is exclusive:
Start=2026-03-01,End=2026-04-01returns all of March.Max 2 GroupBy dimensions per request.
Critical Gotchas
EC2 service names: EC2 charges split into two services. "Amazon Elastic Compute Cloud - Compute" is instance usage. "EC2 - Other" (with spaces around hyphen) is NAT Gateway, EBS, data transfer. WRONG: "EC2-Other", "EC2Other". If "EC2 - Other" returns $0, call GetDimensionValues to confirm the exact service name, then retry.
RECORD_TYPE not CHARGE_TYPE: The dimension for charge type filtering is RECORD_TYPE. Using CHARGE_TYPE throws ValidationException.
Empty Total with GroupBy: By design — Total is empty when GroupBy is used. Sum grouped results using a script (see references/deterministic-calculations.md), or make a separate call without GroupBy.
Filter validation: Cost Explorer does not distinguish between valid filters with no data and invalid filters. If a filter returns no results, call GetDimensionValues to verify the filter value exists.
API cost: Each GetCostAndUsage or GetCostForecast call costs $0.01. Cache results.
Hourly granularity: Requires opt-in in Cost Explorer preferences. Only available for past 14 days. Hourly + resource-level only works for EC2 Compute.
Tags take 24 hours to appear after activation, and only for resources that incurred costs after activation — not retroactive.
Usage Quantity Analysis
When using USAGE_QUANTITY metric:
MUST group by usage type OR filter for usage types with the same unit (e.g., GB-month)
NEVER aggregate different usage units (GB-months + instance-hours)
If API returns usage units of
"NA", multiple units were aggregated — discard these results
Data Transfer Analysis
Data transfer costs in Cost Explorer are spread across multiple usage type patterns. Use a script with regex for accurate filtering — do NOT rely on broad keyword matching (Bytes, Transfer) as it produces many false positives.
Core data transfer (product family "Data Transfer" in CUR):
DataTransfer-*-Bytes— Internet ingress/egress, intra-region cross-AZ*-AWS-Out-Bytes,*-AWS-In-Bytes— inter-region transfer*-Bytes-Internet,*-Bytes-AWS— Global AcceleratorCloudFront-*-Bytes— CloudFront to/from origin*-DataXfer-*— Direct Connect*-ABytes-*— S3 Transfer Acceleration
Networking data processing (billed under respective services, not under "Data Transfer"):
*-NatGateway-Bytes— per-byte NAT Gateway processing (service:EC2 - Other)*-VpcEndpoint-Bytes— per-byte VPC Endpoint / PrivateLink processing (service:Amazon Virtual Private Cloud)*-TransitGateway-Bytes— per-byte Transit Gateway processing (service:Amazon Virtual Private Cloud)*-DataProcessing-Bytes— per-byte processing, but source varies by service:Elastic Load Balancing→ NLB/GLB data processing (networking, include)AmazonCloudWatch→ VPC Flow Logs processing (observability, exclude)Other services → check context before including
Group by both SERVICE and USAGE_TYPE to disambiguate DataProcessing-Bytes. Only include it when the service is Elastic Load Balancing.
Networking infrastructure (hourly charges for networking resources that facilitate data movement):
*-NatGateway-Hours— NAT Gateway hourly charge*-VpcEndpoint-Hours— VPC Endpoint hourly charge*-TransitGateway-Hours— Transit Gateway attachment hourly chargeGlobalAccelerator*— Global Accelerator hourly + data transfer*-LCUUsage— ALB capacity units
Include both networking categories in your analysis as separate sections — customers asking about "data transfer costs" often want to see the full networking picture, not just per-byte charges.
NOT data transfer (common false positives):
Ingestion-Bytes (CloudWatch Logs), PaidEventsAnalyzed-Bytes (CloudTrail), QueryScanned-Bytes (Logs Insights), VendedLog-Bytes, LambdaNetworkLogsAnalyzed-Bytes, Select-Scanned-Bytes/Select-Returned-Bytes (S3 Select).
Script: Query GetCostAndUsage grouped by both SERVICE and USAGE_TYPE (max 2 GroupBy per request), then filter:
import re
TRANSFER_RE = re.compile(r'DataTransfer|AWS-(In|Out)-Bytes|Bytes-(Internet|AWS)|CloudFront-.*-Bytes|DataXfer|-ABytes-')
NETWORKING_PROCESSING_RE = re.compile(r'NatGateway-Bytes|VpcEndpoint-Bytes|TransitGateway-Bytes')
NETWORKING_INFRA_RE = re.compile(r'NatGateway-Hours|VpcEndpoint-Hours|TransitGateway-Hours|GlobalAccelerator|LCUUsage')
# Each group has keys [service, usage_type] and cost
for service, usage_type, cost in results:
if TRANSFER_RE.search(usage_type):
pass # Core data transfer
elif NETWORKING_PROCESSING_RE.search(usage_type):
pass # Networking data processing
elif 'DataProcessing-Bytes' in usage_type and service == 'Elastic Load Balancing':
pass # ELB data processing (networking) — exclude CloudWatch/other services
elif NETWORKING_INFRA_RE.search(usage_type):
pass # Networking infrastructure (hourly)
# Everything else: not data transferUsage types with no regional prefix may be us-east-1 or global. The "EU" prefix means eu-west-1.
For deeper analysis with resource-level detail, recommend CUR + Athena with product_family = 'Data Transfer'. Reference: https://aws.amazon.com/blogs/networking-and-content-delivery/understand-aws-data-transfer-details-in-depth-from-cost-and-usage-report-using-athena-query-and-quicksight/
Resource-Level Analysis
Use GetCostAndUsageWithResources (not GetCostAndUsage) for individual resource costs.
Only available for past 14 days
Requires opt-in via Cost Management Preferences (per-service)
MUST include a filter (typically by service) and group by
RESOURCE_IDResources without opt-in show as
"No Resource ID"
Date Handling
If user says "last month" without a year, use the most recent completed month
ALWAYS check the current date before querying. Use
dateor equivalent to confirm the current year and month. Models frequently default to dates from training data. An analysis of "last month" using the wrong year will return real data that looks plausible but is entirely stale — the most dangerous kind of error.NEVER compare a complete month to a partial current month without calculating daily averages
Cost data has ~24-hour delay — current day data is estimated
Common CLI Commands
# Monthly cost 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
# Cost forecast
aws ce get-cost-forecast \
--time-period Start=2026-04-02,End=2026-05-01 \
--metric UNBLENDED_COST --granularity MONTHLY
# Get valid dimension values
aws ce get-dimension-values \
--time-period Start=2026-03-01,End=2026-04-01 \
--dimension SERVICE
# Cost anomaly detection
aws ce get-anomalies \
--date-interval '{"StartDate":"2026-03-01","EndDate":"2026-04-01"}'Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs a command-line tool
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS
- Publisher
- AWS (Official)
- Source
- aws/agent-toolkit-for-aws · skills/core-skills/aws-billing-and-cost-management · commit 0a218f8
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- aws/agent-toolkit-for-aws
AutoGineer is not affiliated with or endorsed by AWS.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download aws-billing-and-cost-management.zip