Optimize cloud costs through resource rightsizing, tagging strategies, reserved instances, and spending analysis. Use when reducing cloud expenses, analyzing infrastructure costs, or implementing cost governance policies.
Add this skill
npx mdskills install sickn33/cost-optimizationComprehensive cost optimization guide with concrete examples and multi-cloud coverage
1---2name: cost-optimization3description: Optimize cloud costs through resource rightsizing, tagging strategies, reserved instances, and spending analysis. Use when reducing cloud expenses, analyzing infrastructure costs, or implementing cost governance policies.4---56# Cloud Cost Optimization78Strategies and patterns for optimizing cloud costs across AWS, Azure, and GCP.910## Do not use this skill when1112- The task is unrelated to cloud cost optimization13- You need a different domain or tool outside this scope1415## Instructions1617- Clarify goals, constraints, and required inputs.18- Apply relevant best practices and validate outcomes.19- Provide actionable steps and verification.20- If detailed examples are required, open `resources/implementation-playbook.md`.2122## Purpose2324Implement systematic cost optimization strategies to reduce cloud spending while maintaining performance and reliability.2526## Use this skill when2728- Reduce cloud spending29- Right-size resources30- Implement cost governance31- Optimize multi-cloud costs32- Meet budget constraints3334## Cost Optimization Framework3536### 1. Visibility37- Implement cost allocation tags38- Use cloud cost management tools39- Set up budget alerts40- Create cost dashboards4142### 2. Right-Sizing43- Analyze resource utilization44- Downsize over-provisioned resources45- Use auto-scaling46- Remove idle resources4748### 3. Pricing Models49- Use reserved capacity50- Leverage spot/preemptible instances51- Implement savings plans52- Use committed use discounts5354### 4. Architecture Optimization55- Use managed services56- Implement caching57- Optimize data transfer58- Use lifecycle policies5960## AWS Cost Optimization6162### Reserved Instances63```64Savings: 30-72% vs On-Demand65Term: 1 or 3 years66Payment: All/Partial/No upfront67Flexibility: Standard or Convertible68```6970### Savings Plans71```72Compute Savings Plans: 66% savings73EC2 Instance Savings Plans: 72% savings74Applies to: EC2, Fargate, Lambda75Flexible across: Instance families, regions, OS76```7778### Spot Instances79```80Savings: Up to 90% vs On-Demand81Best for: Batch jobs, CI/CD, stateless workloads82Risk: 2-minute interruption notice83Strategy: Mix with On-Demand for resilience84```8586### S3 Cost Optimization87```hcl88resource "aws_s3_bucket_lifecycle_configuration" "example" {89 bucket = aws_s3_bucket.example.id9091 rule {92 id = "transition-to-ia"93 status = "Enabled"9495 transition {96 days = 3097 storage_class = "STANDARD_IA"98 }99100 transition {101 days = 90102 storage_class = "GLACIER"103 }104105 expiration {106 days = 365107 }108 }109}110```111112## Azure Cost Optimization113114### Reserved VM Instances115- 1 or 3 year terms116- Up to 72% savings117- Flexible sizing118- Exchangeable119120### Azure Hybrid Benefit121- Use existing Windows Server licenses122- Up to 80% savings with RI123- Available for Windows and SQL Server124125### Azure Advisor Recommendations126- Right-size VMs127- Delete unused resources128- Use reserved capacity129- Optimize storage130131## GCP Cost Optimization132133### Committed Use Discounts134- 1 or 3 year commitment135- Up to 57% savings136- Applies to vCPUs and memory137- Resource-based or spend-based138139### Sustained Use Discounts140- Automatic discounts141- Up to 30% for running instances142- No commitment required143- Applies to Compute Engine, GKE144145### Preemptible VMs146- Up to 80% savings147- 24-hour maximum runtime148- Best for batch workloads149150## Tagging Strategy151152### AWS Tagging153```hcl154locals {155 common_tags = {156 Environment = "production"157 Project = "my-project"158 CostCenter = "engineering"159 Owner = "team@example.com"160 ManagedBy = "terraform"161 }162}163164resource "aws_instance" "example" {165 ami = "ami-12345678"166 instance_type = "t3.medium"167168 tags = merge(169 local.common_tags,170 {171 Name = "web-server"172 }173 )174}175```176177**Reference:** See `references/tagging-standards.md`178179## Cost Monitoring180181### Budget Alerts182```hcl183# AWS Budget184resource "aws_budgets_budget" "monthly" {185 name = "monthly-budget"186 budget_type = "COST"187 limit_amount = "1000"188 limit_unit = "USD"189 time_period_start = "2024-01-01_00:00"190 time_unit = "MONTHLY"191192 notification {193 comparison_operator = "GREATER_THAN"194 threshold = 80195 threshold_type = "PERCENTAGE"196 notification_type = "ACTUAL"197 subscriber_email_addresses = ["team@example.com"]198 }199}200```201202### Cost Anomaly Detection203- AWS Cost Anomaly Detection204- Azure Cost Management alerts205- GCP Budget alerts206207## Architecture Patterns208209### Pattern 1: Serverless First210- Use Lambda/Functions for event-driven211- Pay only for execution time212- Auto-scaling included213- No idle costs214215### Pattern 2: Right-Sized Databases216```217Development: t3.small RDS218Staging: t3.large RDS219Production: r6g.2xlarge RDS with read replicas220```221222### Pattern 3: Multi-Tier Storage223```224Hot data: S3 Standard225Warm data: S3 Standard-IA (30 days)226Cold data: S3 Glacier (90 days)227Archive: S3 Deep Archive (365 days)228```229230### Pattern 4: Auto-Scaling231```hcl232resource "aws_autoscaling_policy" "scale_up" {233 name = "scale-up"234 scaling_adjustment = 2235 adjustment_type = "ChangeInCapacity"236 cooldown = 300237 autoscaling_group_name = aws_autoscaling_group.main.name238}239240resource "aws_cloudwatch_metric_alarm" "cpu_high" {241 alarm_name = "cpu-high"242 comparison_operator = "GreaterThanThreshold"243 evaluation_periods = "2"244 metric_name = "CPUUtilization"245 namespace = "AWS/EC2"246 period = "60"247 statistic = "Average"248 threshold = "80"249 alarm_actions = [aws_autoscaling_policy.scale_up.arn]250}251```252253## Cost Optimization Checklist254255- [ ] Implement cost allocation tags256- [ ] Delete unused resources (EBS, EIPs, snapshots)257- [ ] Right-size instances based on utilization258- [ ] Use reserved capacity for steady workloads259- [ ] Implement auto-scaling260- [ ] Optimize storage classes261- [ ] Use lifecycle policies262- [ ] Enable cost anomaly detection263- [ ] Set budget alerts264- [ ] Review costs weekly265- [ ] Use spot/preemptible instances266- [ ] Optimize data transfer costs267- [ ] Implement caching layers268- [ ] Use managed services269- [ ] Monitor and optimize continuously270271## Tools272273- **AWS:** Cost Explorer, Cost Anomaly Detection, Compute Optimizer274- **Azure:** Cost Management, Advisor275- **GCP:** Cost Management, Recommender276- **Multi-cloud:** CloudHealth, Cloudability, Kubecost277278## Reference Files279280- `references/tagging-standards.md` - Tagging conventions281- `assets/cost-analysis-template.xlsx` - Cost analysis spreadsheet282283## Related Skills284285- `terraform-module-library` - For resource provisioning286- `multi-cloud-architecture` - For cloud selection287
Full transparency — inspect the skill content before installing.