원클릭으로
aws-cost-optimizer
Cost-aware AWS interaction and optimization patterns
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Cost-aware AWS interaction and optimization patterns
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | aws-cost-optimizer |
| description | Cost-aware AWS interaction and optimization patterns |
| version | 1.0.0 |
| category | aws |
| agents | ["aws-coworker-core","aws-coworker-planner","aws-coworker-observability-cost"] |
| tools | ["Read","Bash"] |
This skill provides patterns for cost-aware AWS interactions, ongoing cost optimization, and financial governance. Use it to understand costs, identify savings opportunities, and implement cost controls.
# Monthly cost by service (last 3 months)
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-04-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE \
--profile {profile}
# Daily cost for current month
aws ce get-cost-and-usage \
--time-period Start=$(date -d "$(date +%Y-%m-01)" +%Y-%m-%d),End=$(date +%Y-%m-%d) \
--granularity DAILY \
--metrics UnblendedCost \
--profile {profile}
# Cost by tag (e.g., Environment)
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=TAG,Key=Environment \
--profile {profile}
# Cost by account (for Organizations)
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=LINKED_ACCOUNT \
--profile {profile}
# 3-month forecast
aws ce get-cost-forecast \
--time-period Start=$(date +%Y-%m-%d),End=$(date -d "+3 months" +%Y-%m-%d) \
--granularity MONTHLY \
--metric UNBLENDED_COST \
--profile {profile}
# Create monthly budget with alert
aws budgets create-budget \
--account-id {account-id} \
--budget '{
"BudgetName": "monthly-total",
"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": "alerts@example.com"}
]
}
]' \
--profile {profile}
| Type | Use Case |
|---|---|
| Cost Budget | Overall or service-specific spending |
| Usage Budget | Resource usage limits (e.g., EC2 hours) |
| RI Utilization | Reserved Instance coverage |
| Savings Plans Utilization | Savings Plans coverage |
## Recommended Budgets
### Account Level
- Total monthly budget with 80%, 100%, 120% alerts
- Per-service budgets for top 3-5 services
### Environment Level
- Production budget (track actual vs expected)
- Development budget (cap to prevent waste)
- Sandbox budget (strict limit)
### Team Level
- Cost allocation by CostCenter tag
- Alerts to team owners
# Get right-sizing recommendations
aws ce get-rightsizing-recommendation \
--service EC2 \
--configuration '{
"RecommendationTarget": "SAME_INSTANCE_FAMILY",
"BenefitsConsidered": true
}' \
--profile {profile}
# Detailed instance utilization
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-xxxxxxxxx \
--start-time $(date -d "7 days ago" -u +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 3600 \
--statistics Average Maximum \
--profile {profile} \
--region {region}
| Utilization | Action |
|---|---|
| < 20% average CPU | Consider smaller instance |
| 20-60% average CPU | Likely right-sized |
| > 80% average CPU | Consider larger instance |
| Spiky usage | Consider auto-scaling |
# RDS utilization check
aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name CPUUtilization \
--dimensions Name=DBInstanceIdentifier,Value={db-id} \
--start-time $(date -d "7 days ago" -u +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 3600 \
--statistics Average Maximum \
--profile {profile} \
--region {region}
# Get Savings Plans recommendations
aws ce get-savings-plans-purchase-recommendation \
--savings-plans-type COMPUTE_SP \
--term-in-years ONE_YEAR \
--payment-option NO_UPFRONT \
--lookback-period-in-days THIRTY_DAYS \
--profile {profile}
# Current Savings Plans utilization
aws ce get-savings-plans-utilization \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--profile {profile}
# Get RI recommendations
aws ce get-reservation-purchase-recommendation \
--service EC2 \
--term-in-years ONE_YEAR \
--payment-option NO_UPFRONT \
--lookback-period-in-days THIRTY_DAYS \
--profile {profile}
# Current RI utilization
aws ce get-reservation-utilization \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--profile {profile}
## Commitment Decision Framework
### Savings Plans (Preferred)
- Compute Savings Plans: Most flexible, covers EC2, Lambda, Fargate
- EC2 Instance Savings Plans: Larger discount, specific instance family
### Reserved Instances (When Needed)
- Use for RDS, ElastiCache, Redshift
- Use when RI-specific features needed (capacity reservation)
### Commitment Levels
| Commitment | Best For |
|------------|----------|
| 1-year No Upfront | Moderate confidence, cash flow preference |
| 1-year All Upfront | High confidence, maximum savings |
| 3-year | Very stable workloads, largest discount |
# Unattached EBS volumes
aws ec2 describe-volumes \
--filters Name=status,Values=available \
--query 'Volumes[*].[VolumeId,Size,CreateTime]' \
--output table \
--profile {profile} \
--region {region}
# Unassociated Elastic IPs
aws ec2 describe-addresses \
--filters Name=association-id,Values="" \
--query 'Addresses[*].[PublicIp,AllocationId]' \
--output table \
--profile {profile} \
--region {region}
# Unused NAT Gateways (check connections)
aws ec2 describe-nat-gateways \
--filter Name=state,Values=available \
--profile {profile} \
--region {region}
# Old snapshots (> 90 days)
aws ec2 describe-snapshots \
--owner-ids self \
--query 'Snapshots[?StartTime<=`2024-01-01`].[SnapshotId,VolumeSize,StartTime,Description]' \
--output table \
--profile {profile} \
--region {region}
# Delete unattached volume (DESTRUCTIVE - ensure backup)
aws ec2 delete-volume \
--volume-id vol-xxxxxxxxx \
--profile {profile} \
--region {region}
# Release Elastic IP
aws ec2 release-address \
--allocation-id eipalloc-xxxxxxxxx \
--profile {profile} \
--region {region}
# Delete old snapshot
aws ec2 delete-snapshot \
--snapshot-id snap-xxxxxxxxx \
--profile {profile} \
--region {region}
| Use Case | Cost-Effective Choice |
|---|---|
| Variable compute | Lambda or Fargate Spot |
| Steady-state compute | Reserved EC2 or Savings Plans |
| Data storage | S3 with lifecycle policies |
| Database reads | ElastiCache or read replicas |
| Batch processing | Spot instances |
## Data Transfer Cost Reduction
### Within AWS
- Use VPC endpoints for AWS services
- Keep resources in same AZ when possible
- Use private IPs instead of public
### To Internet
- Use CloudFront for static content
- Compress data before transfer
- Cache at edge when possible
### Cross-Region
- Minimize cross-region replication
- Use S3 Transfer Acceleration for large uploads
- Consider regional consolidation
# S3 storage analysis
aws s3api list-buckets --query 'Buckets[*].Name' --output text | \
xargs -I {} sh -c 'echo "Bucket: {}"; aws s3api get-bucket-location --bucket {} 2>/dev/null'
# Enable S3 Intelligent Tiering
aws s3api put-bucket-lifecycle-configuration \
--bucket {bucket} \
--lifecycle-configuration '{
"Rules": [{
"ID": "IntelligentTiering",
"Status": "Enabled",
"Filter": {},
"Transitions": [{
"Days": 0,
"StorageClass": "INTELLIGENT_TIERING"
}]
}]
}' \
--profile {profile}
## Required Cost Tags
| Tag | Purpose | Example |
|-----|---------|---------|
| Environment | Environment allocation | production, development |
| CostCenter | Chargeback/showback | CC-1234 |
| Owner | Responsibility | platform-team |
| Project | Project allocation | project-phoenix |
## Tag Enforcement
- Use AWS Organizations SCP to require tags
- Use AWS Config rules to detect untagged resources
- Regular tag compliance reports
# Find untagged EC2 instances
aws ec2 describe-instances \
--query 'Reservations[*].Instances[?!not_null(Tags[?Key==`CostCenter`].Value)].[InstanceId,State.Name]' \
--output table \
--profile {profile} \
--region {region}
## Monthly Cost Review Checklist
### Visibility
- [ ] Review Cost Explorer trends
- [ ] Check budget alerts
- [ ] Analyze cost by tag/team
- [ ] Identify anomalies
### Right-Sizing
- [ ] Review EC2 utilization
- [ ] Review RDS utilization
- [ ] Check right-sizing recommendations
- [ ] Implement approved changes
### Idle Resources
- [ ] Identify unattached volumes
- [ ] Check unused Elastic IPs
- [ ] Review old snapshots
- [ ] Clean up approved resources
### Reserved Capacity
- [ ] Review RI/SP utilization
- [ ] Check for new recommendations
- [ ] Plan upcoming purchases
- [ ] Adjust coverage as needed
### Architecture
- [ ] Review data transfer costs
- [ ] Check S3 storage classes
- [ ] Evaluate serverless options
- [ ] Consider Spot for suitable workloads
When planning new resources:
## Cost Estimate Template
### Resource: {Resource Type}
| Component | Quantity | Unit Cost | Monthly Cost |
|-----------|----------|-----------|--------------|
| EC2 (m5.large) | 2 | $0.096/hr | $140 |
| EBS (gp3, 100GB) | 2 | $0.08/GB | $16 |
| Data Transfer | 100GB | $0.09/GB | $9 |
| **Total** | | | **$165** |
### With Optimization
| Option | Savings | New Monthly |
|--------|---------|-------------|
| 1yr Savings Plan | 30% | $115 |
| Spot (if suitable) | 60-70% | ~$60 |
### Recommendation
{Which option and why}
aws-cli-playbook — CLI patterns for cost commandsaws-well-architected — Cost optimization pillaraws-governance-guardrails — Cost policiesaws-observability-setup — Cost of monitoring**AWS Coworker Development Guardrails** - MANDATORY when extending or modifying AWS Coworker itself. TRIGGERS (use this skill when ANY of these apply): - User asks to add new skills, agents, or commands to AWS Coworker - User asks to modify existing AWS Coworker components - User asks about AWS Coworker architecture or design - User wants to add support for new AWS services - Discussion involves directory structure or file organization - User mentions "extending", "customizing", or "adding to" AWS Coworker - Creating or modifying files in: skills/, .claude/agents/, .claude/commands/, config/ NOT for: Using AWS Coworker to interact with AWS (that's CLAUDE.md's domain)
Canonical AWS CLI patterns for discover, plan, deploy, validate, and rollback
AWS Well-Architected Framework alignment for planning and review
Organization governance policies - never do, always do, and compliance rules
Git and GitHub best practices for AWS Coworker change management
Multi-account and OU strategy, landing zone patterns, and workload placement