{"id":"cost-optimization","name":"cost-optimization","summary":"リソースの適正化、タグ付け戦略、予約インスタンス、支出分析を通じて、AWS、Azure、GCP、OCI全体でクラウドコストを最適化します。","body":"# Cloud Cost Optimization\n\nStrategies and patterns for optimizing cloud costs across AWS, Azure, GCP, and OCI.\n\n## Purpose\n\nImplement systematic cost optimization strategies to reduce cloud spending while maintaining performance and reliability.\n\n## When to Use\n\n- Reduce cloud spending\n- Right-size resources\n- Implement cost governance\n- Optimize multi-cloud costs\n- Meet budget constraints\n\n## Cost Optimization Framework\n\n### 1. Visibility\n\n- Implement cost allocation tags\n- Use cloud cost management tools\n- Set up budget alerts\n- Create cost dashboards\n\n### 2. Right-Sizing\n\n- Analyze resource utilization\n- Downsize over-provisioned resources\n- Use auto-scaling\n- Remove idle resources\n\n### 3. Pricing Models\n\n- Use reserved capacity\n- Leverage spot/preemptible instances\n- Implement savings plans\n- Use committed use discounts\n\n### 4. Architecture Optimization\n\n- Use managed services\n- Implement caching\n- Optimize data transfer\n- Use lifecycle policies\n\n## AWS Cost Optimization\n\n### Reserved Instances\n\n```\nSavings: 30-72% vs On-Demand\nTerm: 1 or 3 years\nPayment: All/Partial/No upfront\nFlexibility: Standard or Convertible\n```\n\n### Savings Plans\n\n```\nCompute Savings Plans: 66% savings\nEC2 Instance Savings Plans: 72% savings\nApplies to: EC2, Fargate, Lambda\nFlexible across: Instance families, regions, OS\n```\n\n### Spot Instances\n\n```\nSavings: Up to 90% vs On-Demand\nBest for: Batch jobs, CI/CD, stateless workloads\nRisk: 2-minute interruption notice\nStrategy: Mix with On-Demand for resilience\n```\n\n### S3 Cost Optimization\n\n```hcl\nresource \"aws_s3_bucket_lifecycle_configuration\" \"example\" {\n  bucket = aws_s3_bucket.example.id\n\n  rule {\n    id     = \"transition-to-ia\"\n    status = \"Enabled\"\n\n    transition {\n      days          = 30\n      storage_class = \"STANDARD_IA\"\n    }\n\n    transition {\n      days          = 90\n      storage_class = \"GLACIER\"\n    }\n\n    expiration {\n      days = 365\n    }\n  }\n}\n```\n\n## Azure Cost Optimization\n\n### Reserved VM Instances\n\n- 1 or 3 year terms\n- Up to 72% savings\n- Flexible sizing\n- Exchangeable\n\n### Azure Hybrid Benefit\n\n- Use existing Windows Server licenses\n- Up to 80% savings with RI\n- Available for Windows and SQL Server\n\n### Azure Advisor Recommendations\n\n- Right-size VMs\n- Delete unused resources\n- Use reserved capacity\n- Optimize storage\n\n## GCP Cost Optimization\n\n### Committed Use Discounts\n\n- 1 or 3 year commitment\n- Up to 57% savings\n- Applies to vCPUs and memory\n- Resource-based or spend-based\n\n### Sustained Use Discounts\n\n- Automatic discounts\n- Up to 30% for running instances\n- No commitment required\n- Applies to Compute Engine, GKE\n\n### Preemptible VMs\n\n- Up to 80% savings\n- 24-hour maximum runtime\n- Best for batch workloads\n\n## OCI Cost Optimization\n\n### Flexible Shapes\n\n- Scale OCPUs and memory independently\n- Match instance sizing to workload demand\n- Reduce wasted capacity from fixed VM shapes\n\n### Commitments and Budgets\n\n- Use annual commitments for predictable spend\n- Set compartment-level budgets with alerts\n- Track monthly forecasts with OCI Cost Analysis\n\n### Preemptible Capacity\n\n- Use preemptible instances for batch and ephemeral workloads\n- Keep interruption-tolerant autoscaling groups\n- Mix with standard capacity for critical services\n\n## Tagging Strategy\n\n### AWS Tagging\n\n```hcl\nlocals {\n  common_tags = {\n    Environment = \"production\"\n    Project     = \"my-project\"\n    CostCenter  = \"engineering\"\n    Owner       = \"team@example.com\"\n    ManagedBy   = \"terraform\"\n  }\n}\n\nresource \"aws_instance\" \"example\" {\n  ami           = \"ami-12345678\"\n  instance_type = \"t3.medium\"\n\n  tags = merge(\n    local.common_tags,\n    {\n      Name = \"web-server\"\n    }\n  )\n}\n```\n\n**Reference:** See `references/tagging-standards.md`\n\n## Cost Monitoring\n\n### Budget Alerts\n\n```hcl\n# AWS Budget\nresource \"aws_budgets_budget\" \"monthly\" {\n  name              = \"monthly-budget\"\n  budget_type       = \"COST\"\n  limit_amount      = \"1000\"\n  limit_unit        = \"USD\"\n  time_period_start = \"2024-01-01_00:00\"\n  time_unit         = \"MONTHLY\"\n\n  notification {\n    comparison_operator        = \"GREATER_THAN\"\n    threshold                  = 80\n    threshold_type            = \"PERCENTAGE\"\n    notification_type         = \"ACTUAL\"\n    subscriber_email_addresses = [\"team@example.com\"]\n  }\n}\n```\n\n### Cost Anomaly Detection\n\n- AWS Cost Anomaly Detection\n- Azure Cost Management alerts\n- GCP Budget alerts\n- OCI Budgets and Cost Analysis\n\n## Architecture Patterns\n\n### Pattern 1: Serverless First\n\n- Use Lambda/Functions for event-driven\n- Pay only for execution time\n- Auto-scaling included\n- No idle costs\n\n### Pattern 2: Right-Sized Databases\n\n```\nDevelopment: t3.small RDS\nStaging: t3.large RDS\nProduction: r6g.2xlarge RDS with read replicas\n```\n\n### Pattern 3: Multi-Tier Storage\n\n```\nHot data: S3 Standard\nWarm data: S3 Standard-IA (30 days)\nCold data: S3 Glacier (90 days)\nArchive: S3 Deep Archive (365 days)\n```\n\n### Pattern 4: Auto-Scaling\n\n```hcl\nresource \"aws_autoscaling_policy\" \"scale_up\" {\n  name                   = \"scale-up\"\n  scaling_adjustment     = 2\n  adjustment_type        = \"ChangeInCapacity\"\n  cooldown              = 300\n  autoscaling_group_name = aws_autoscaling_group.main.name\n}\n\nresource \"aws_cloudwatch_metric_alarm\" \"cpu_high\" {\n  alarm_name          = \"cpu-high\"\n  comparison_operator = \"GreaterThanThreshold\"\n  evaluation_periods  = \"2\"\n  metric_name         = \"CPUUtilization\"\n  namespace           = \"AWS/EC2\"\n  period              = \"60\"\n  statistic           = \"Average\"\n  threshold           = \"80\"\n  alarm_actions       = [aws_autoscaling_policy.scale_up.arn]\n}\n```\n\n## Cost Optimization Checklist\n\n- [ ] Implement cost allocation tags\n- [ ] Delete unused resources (EBS, EIPs, snapshots)\n- [ ] Right-size instances based on utilization\n- [ ] Use reserved capacity for steady workloads\n- [ ] Implement auto-scaling\n- [ ] Optimize storage classes\n- [ ] Use lifecycle policies\n- [ ] Enable cost anomaly detection\n- [ ] Set budget alerts\n- [ ] Review costs weekly\n- [ ] Use spot/preemptible instances\n- [ ] Optimize data transfer costs\n- [ ] Implement caching layers\n- [ ] Use managed services\n- [ ] Monitor and optimize continuously\n\n## Tools\n\n- **AWS:** Cost Explorer, Cost Anomaly Detection, Compute Optimizer\n- **Azure:** Cost Management, Advisor\n- **GCP:** Cost Management, Recommender\n- **OCI:** Cost Analysis, Budgets, Cloud Advisor\n- **Multi-cloud:** CloudHealth, Cloudability, Kubecost\n\n\n## Related Skills\n\n- `terraform-module-library` - For resource provisioning\n- `multi-cloud-architecture` - For cloud selection","author":"@wshobson","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/wshobson/agents/tree/main/plugins/cloud-infrastructure/skills/cost-optimization","license":"MIT","category":"devops","lang":"en","tokens":1609,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/tagging-standards.md","size":832,"sha256":"79e557818a8c0a700fbc9389ee4f78404ba9c7fdc72b1b12ffec0abfba6ac1af"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}