aws-cost-optimizer – skill DevOps & Hạ tầng cho agent AI
Phân tích chi phí AWS toàn diện và khuyến nghị tối ưu bằng AWS CLI và Cost Explorer
Cài skill aws-cost-optimizer bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/aws-cost-optimizer-4bed2.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /aws-cost-optimizer – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/aws-cost-optimizer-4bed2.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $aws-cost-optimizer – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/aws-cost-optimizer-4bed2.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /aws-cost-optimizer – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/aws-cost-optimizer-4bed2.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /aws-cost-optimizer – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
AWS Cost Optimizer
Analyze AWS spending patterns, identify waste, and provide actionable cost reduction strategies.
When to Use This Skill
Use this skill when you need to analyze AWS spending, identify cost optimization opportunities, or reduce cloud waste.
Core Capabilities
Cost Analysis
- Parse AWS Cost Explorer data for trends and anomalies
- Break down costs by service, region, and resource tags
- Identify month-over-month spending increases
Resource Optimization
- Detect idle EC2 instances (low CPU utilization)
- Find unattached EBS volumes and old snapshots
- Identify unused Elastic IPs
- Locate underutilized RDS instances
- Find old S3 objects eligible for lifecycle policies
Savings Recommendations
- Suggest Reserved Instance/Savings Plans opportunities
- Recommend instance rightsizing based on CloudWatch metrics
- Identify resources in expensive regions
- Calculate potential savings with specific actions
Analysis and change boundary
Confirm AWS account/profile, regions and reporting dates. Examples use GNU date (-d), not macOS BSD date. Cost Explorer end dates are exclusive and usage data can lag. Low CPU or unattached state alone does not establish deletion safety; check owners, recovery retention, I/O/network/memory and business cycles. Deletion, termination, rightsizing and commitment purchases require explicit authorized scope and a recovery plan.
AWS CLI Commands
Get Cost and Usage
# Last 30 days cost by service
aws ce get-cost-and-usage \
--time-period Start=$(date -d '30 days ago' +%Y-%m-%d),End=$(date +%Y-%m-%d) \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Daily costs for current month
aws ce get-cost-and-usage \
--time-period Start=$(date +%Y-%m-01),End=$(date +%Y-%m-%d) \
--granularity DAILY \
--metrics UnblendedCostFind Unused Resources
# Unattached EBS volumes
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[*].[VolumeId,Size,VolumeType,CreateTime]' \
--output table
# Unused Elastic IPs
aws ec2 describe-addresses \
--query 'Addresses[?AssociationId==null].[PublicIp,AllocationId]' \
--output table
# Idle EC2 instances (requires CloudWatch)
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-xxxxx \
--start-time $(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%S) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
--period 86400 \
--statistics Average
# Old EBS snapshots (>90 days)
aws ec2 describe-snapshots \
--owner-ids self \
--query 'Snapshots[?StartTime<=`'$(date -d '90 days ago' --iso-8601)'`].[SnapshotId,StartTime,VolumeSize]' \
--output tableRightsizing Analysis
# List EC2 instances with their types
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,InstanceType,State.Name,Tags[?Key==`Name`].Value|[0]]' \
--output table
# Get RDS instance utilization
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name CPUUtilization \
--dimensions Name=DBInstanceIdentifier,Value=mydb \
--start-time $(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%S) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%S) \
--period 86400 \
--statistics Average MaximumOptimization Workflow
1. Baseline Assessment
- Pull 3-6 months of cost data
- Identify top 5 spending services
- Calculate growth rate
2. Candidate savings requiring owner review
- Delete unattached EBS volumes
- Release unused Elastic IPs
- Stop/terminate idle EC2 instances
- Delete old snapshots
3. Strategic Optimization
- Analyze Reserved Instance coverage
- Review instance types vs. workload
- Implement S3 lifecycle policies
- Consider Spot instances for non-critical workloads
4. Ongoing Monitoring
- Set up AWS Budgets with alerts
- Enable Cost Anomaly Detection
- Tag resources for cost allocation
- Monthly cost review meetings
Cost Optimization Checklist
- [ ] Enable AWS Cost Explorer
- [ ] Set up cost allocation tags
- [ ] Create AWS Budget with alerts
- [ ] Review and delete unused resources
- [ ] Analyze Reserved Instance opportunities
- [ ] Implement S3 Intelligent-Tiering
- [ ] Review data transfer costs
- [ ] Optimize Lambda memory allocation
- [ ] Use CloudWatch Logs retention policies
- [ ] Consider multi-region cost differences
Example Prompts
Analysis
- "Show me AWS costs for the last 3 months broken down by service"
- "What are my top 10 most expensive resources?"
- "Compare this month's spending to last month"
Optimization
- "Find all unattached EBS volumes and calculate savings"
- "Identify EC2 instances with <5% CPU utilization"
- "Suggest Reserved Instance purchases based on usage"
- "Calculate savings from deleting snapshots older than 90 days"
Implementation
- "Create a script to delete unattached volumes"
- "Set up a budget alert for $1000/month"
- "Generate a cost optimization report for leadership"
Best Practices
- Always test in non-production first
- Verify resources are truly unused before deletion
- Document all cost optimization actions
- Calculate ROI for optimization efforts
- Automate recurring optimization tasks
- Use AWS Trusted Advisor recommendations
- Enable AWS Cost Anomaly Detection
Integration with Kiro CLI
This skill works seamlessly with Kiro CLI's AWS integration:
# Use Kiro to analyze costs
kiro-cli chat "Use aws-cost-optimizer to analyze my spending"
# Generate optimization report
kiro-cli chat "Create a cost optimization plan using aws-cost-optimizer"Safety Notes
- Risk Level: Low - Read-only analysis is safe
- Deletion Actions: Medium Risk - Always verify before deleting resources
- Production Changes: High Risk - Test rightsizing in dev/staging first
- Maintain backups before any deletion
- Use
--dry-runflag when available
Additional Resources
- [AWS Cost Optimization Best Practices](https://aws.amazon.com/pricing/cost-optimization/)
- [AWS Well-Architected Framework - Cost Optimization](https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/welcome.html)
- [AWS Cost Explorer API](https://docs.aws.amazon.com/cost-management/latest/APIReference/Welcome.html)
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Skill liên quan
- aws-ec2 – Quản lý EC2 instance, AMI và auto-scaling group. Cấu hình security group, key pair và…
- aws-ecs-fargate – Triển khai container trên ECS và Fargate. Cấu hình task definition, service và load…
- aws-iam – Quản lý người dùng, vai trò và chính sách IAM. Triển khai truy cập đặc quyền tối thiểu…
- aws-iam-best-practices – Rà soát, tăng cường bảo mật và triển khai đặc quyền tối thiểu cho chính sách IAM
- aws-lambda – Xây dựng và triển khai hàm serverless trên AWS Lambda. Cấu hình trigger, quản lý quyền…
- aws-penetration-testing – Cung cấp kỹ thuật kiểm thử xâm nhập môi trường đám mây AWS toàn diện. Bao gồm liệt kê…
- aws-rds – Cung cấp và quản lý cơ sở dữ liệu RDS. Cấu hình sao lưu, sao chép và bảo mật. Dùng khi…
- aws-s3 – Cấu hình S3 bucket, chính sách và quy tắc vòng đời. Triển khai versioning, replication…