Analyze AWS account costs and usage for the current month, identify cost reduction opportunities across all major services (EC2, RDS, Lambda, S3, EBS, Load Balancers, etc.), generate detailed recommendations, and export findings as Excel/CSV reports with charts. Use whenever the user mentions AWS costs, cloud spending, cost optimization, AWS bill, reducing cloud expenses, analyzing AWS usage, rightsizing instances, or finding unused resources. Also trigger for phrases like "my AWS bill is too high", "optimize my cloud costs", "find expensive resources", or "AWS cost analysis".
Resources
5Install
npx skillscat add 636137/aws-cost-optimizer-skill Install via the SkillsCat registry.
AWS Cost Optimizer
This skill helps analyze AWS account costs and resource usage to identify cost savings opportunities. It examines current month usage across all major AWS services, identifies underutilized or idle resources, provides actionable recommendations, and generates comprehensive Excel/CSV reports with visualizations.
Core Capabilities
- Current Month Cost Analysis - Query AWS Cost Explorer for month-to-date spending by service
- Resource Inventory - Scan EC2, RDS, Lambda, S3, EBS, Load Balancers, and other services for usage patterns
- Optimization Recommendations - Identify idle, underutilized, or oversized resources
- Cost Savings Projection - Calculate potential monthly savings from implementing recommendations
- Excel/CSV Reports - Generate detailed spreadsheets with charts showing costs, recommendations, and savings
How It Works
Step 1: Check AWS Configuration
Before starting, verify the AWS CLI is configured and the user has appropriate permissions:
aws sts get-caller-identityIf this fails, guide the user to configure AWS CLI with aws configure or set environment variables. The skill requires read permissions for:
- Cost Explorer API (
ce:GetCostAndUsage) - EC2 (
ec2:Describe*) - RDS (
rds:Describe*) - Lambda (
lambda:List*,lambda:Get*) - S3 (
s3:ListAllMyBuckets,s3:GetBucketLocation) - ELB/ALB (
elasticloadbalancing:Describe*) - CloudWatch (
cloudwatch:GetMetricStatistics)
Step 2: Gather Cost and Usage Data
Use the bundled analysis script scripts/aws_cost_analyzer.py to collect data. This script:
- Queries Cost Explorer for current month costs by service
- Inventories running EC2 instances with CloudWatch CPU metrics
- Lists RDS databases and their sizes
- Analyzes Lambda function invocation counts
- Identifies unattached EBS volumes
- Finds idle load balancers
- Checks for S3 buckets and estimates storage costs
Run it with:
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/aws_cost_analyzer.py \
--region <user-region-or-us-east-1> \
--output /tmp/aws_cost_data.jsonThis outputs a JSON file with all collected data for further processing.
Step 3: Analyze and Generate Recommendations
Use the bundled recommendation engine scripts/generate_recommendations.py to process the data:
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/generate_recommendations.py \
--input /tmp/aws_cost_data.json \
--output /tmp/aws_recommendations.jsonThis script applies cost optimization rules:
EC2 Optimization Rules:
- Instances with <5% average CPU over 7 days → Recommend stop/downsize (saves ~$50-500/mo per instance)
- Instances running 24/7 that could be scheduled → Recommend scheduling (saves 60-70% of instance cost)
- Older generation instances (t2, m4, c4) → Recommend upgrading to current gen (saves 10-20%)
- Over-provisioned instance types → Recommend rightsizing
RDS Optimization Rules:
- Low connection count (<5 connections) → Recommend downsize or Aurora Serverless
- Dev/test databases running 24/7 → Recommend scheduling (saves 70%)
- Single-AZ databases in production → Flag (not cost, but best practice)
Storage Optimization Rules:
- Unattached EBS volumes → Recommend deletion (saves ~$0.10/GB/mo)
- EBS volumes with low IOPS usage → Recommend switching from io1/io2 to gp3
- S3 buckets without lifecycle policies → Recommend adding policies (saves 50-90% on archival data)
Lambda Optimization Rules:
- Functions with high memory but low usage → Recommend memory reduction
- Over-provisioned concurrent executions → Reduce reserved concurrency
Load Balancer Optimization Rules:
- Load balancers with 0 targets → Recommend deletion (saves $16-23/mo per LB)
- Application Load Balancers serving <10 requests/day → Consider CloudFront or API Gateway
Step 4: Generate Excel Report
Use the bundled report generator scripts/create_excel_report.py:
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/create_excel_report.py \
--input /tmp/aws_recommendations.json \
--output ~/Downloads/aws_cost_optimization_report_$(date +%Y%m%d).xlsxThe Excel workbook includes:
- Executive Summary - Total current costs, total potential savings, ROI
- Cost Breakdown - Pie chart and table showing costs by service
- Top Recommendations - Sorted by potential savings (high to low)
- EC2 Analysis - Instance details with CPU metrics and recommendations
- RDS Analysis - Database details with connection metrics
- Storage Analysis - EBS and S3 optimization opportunities
- Other Services - Lambda, Load Balancers, and miscellaneous findings
- Action Plan - Prioritized implementation checklist
Charts are embedded for visual analysis.
Step 5: Present Findings
Show the user:
- Location of the Excel report file
- Total current month-to-date spending
- Total potential monthly savings if all recommendations are implemented
- Top 5 highest-impact recommendations
Example summary:
📊 AWS Cost Optimization Report Generated
Current Month Spending: $3,847.22
Potential Monthly Savings: $1,432.50 (37% reduction)
Top Recommendations:
1. Stop 8 underutilized EC2 instances (t3.large) → Save $584/mo
2. Delete 47 unattached EBS volumes (1.2TB) → Save $120/mo
3. Rightsize RDS db.m5.xlarge to db.t3.large → Save $280/mo
4. Remove 3 idle Application Load Balancers → Save $69/mo
5. Implement S3 lifecycle policies on 5 buckets → Save $210/mo
Full report: ~/Downloads/aws_cost_optimization_report_20260326.xlsxAdvanced Usage
Multi-Region Analysis
By default, the script analyzes resources in the configured AWS region. For multi-region analysis:
for region in us-east-1 us-west-2 eu-west-1; do
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/aws_cost_analyzer.py \
--region $region \
--output /tmp/aws_cost_data_$region.json
done
# Merge the JSON files
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/merge_regional_data.py \
--input /tmp/aws_cost_data_*.json \
--output /tmp/aws_cost_data_merged.jsonThen proceed with recommendations and report generation using the merged file.
Custom Recommendation Rules
If the user has specific optimization criteria (e.g., "flag all instances over $100/mo"), modify the recommendation rules by editing the thresholds in generate_recommendations.py or passing custom parameters:
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/generate_recommendations.py \
--input /tmp/aws_cost_data.json \
--output /tmp/aws_recommendations.json \
--cpu-threshold 10 \
--days-to-analyze 14 \
--min-savings-threshold 50CSV Export (Alternative to Excel)
If the user prefers CSV files:
python3 ~/.copilot/skills/aws-cost-optimizer/scripts/create_csv_reports.py \
--input /tmp/aws_recommendations.json \
--output-dir ~/Downloads/aws_cost_reports/This creates separate CSV files for each analysis section (ec2_recommendations.csv, rds_recommendations.csv, etc.)
Important Notes
Permissions and Safety
This skill is read-only by design. It does NOT make any changes to AWS resources. All scripts use Describe* and Get* APIs only. The user must implement recommendations manually through the AWS Console, CLI, or infrastructure-as-code tools.
Always remind the user to:
- Review recommendations in context of their business requirements
- Test changes in non-production environments first
- Consider dependencies before stopping/deleting resources
- Coordinate with team members who may be using the resources
Cost Explorer Data Latency
AWS Cost Explorer data has a 24-hour delay. Today's spending won't appear until tomorrow. The analysis shows month-to-date costs through yesterday.
CloudWatch Metrics
The skill looks at 7 days of CloudWatch metrics by default. For production instances, consider analyzing 14-30 days to account for periodic workloads (batch jobs, monthly reports, etc.). Short analysis windows might misidentify legitimate low-utilization resources as idle.
Savings Estimates
Savings projections are estimates based on AWS pricing as of the analysis date. Actual savings may vary based on:
- Reserved Instance or Savings Plans commitments
- Volume discounts
- Regional pricing differences
- Free tier usage
AWS Organizations and Multiple Accounts
For AWS Organizations with multiple accounts, run the analysis once per account or use a consolidated billing account with appropriate cross-account permissions. The skill can process multiple accounts by running the analyzer with different AWS credential profiles:
AWS_PROFILE=prod-account python3 scripts/aws_cost_analyzer.py --output prod.json
AWS_PROFILE=dev-account python3 scripts/aws_cost_analyzer.py --output dev.jsonTroubleshooting
"An error occurred (AccessDeniedException)"
→ The AWS credentials lack required permissions. Review the IAM policy requirements in Step 1.
"Cost Explorer is not enabled"
→ Enable Cost Explorer in the AWS Billing console. It takes 24 hours after activation to populate data.
"No data returned for Cost Explorer query"
→ This is the first month of the account, or the account has no usage. The skill requires at least 1 day of cost data.
Charts not rendering in Excel
→ Ensure openpyxl and matplotlib are installed: pip3 install openpyxl matplotlib pandas boto3
Script runs but finds 0 resources
→ Check that the AWS region parameter matches where resources are deployed. Try --region us-east-1 or the user's primary region.
When to Use This Skill
Trigger this skill when the user:
- Asks about AWS spending or costs
- Mentions their "AWS bill is too high"
- Wants to "optimize cloud costs" or "reduce cloud spending"
- Needs to "find unused AWS resources" or "idle instances"
- Asks for "cost analysis", "cost breakdown", or "where is money being spent"
- Mentions "rightsizing", "instance optimization", or "storage cleanup"
- Wants to "analyze EC2 usage", "find expensive RDS databases", or similar service-specific queries
- Needs a "monthly cost report" or "cost optimization report"
This skill is specifically for AWS cost analysis. For Azure or GCP cost optimization, different approaches are needed.