All examples for Dev Environment Cost Optimizer

AWS Dev Environment with CI/CD Constraints

Cost optimization for a complex setup with EC2, RDS, and Kubernetes that must preserve nightly CI/CD builds. Shows prioritized implementation and extended scheduling.

Input

What you provide to the skill

We have 3 EC2 instances, an RDS database, and a Kubernetes cluster on AWS for dev/staging. We work 9am-6pm EST weekdays but our CI/CD runs nightly builds. What’s the best approach?

Output

What the skill generates for you

Dev Environment Cost Optimization Plan

Your Savings Analysis

Current Setup:

  • 3 EC2 instances running 24/7
  • 1 RDS database running 24/7
  • 1 Kubernetes cluster running 24/7
  • Work schedule: 9am-6pm EST, Monday-Friday
  • CI/CD constraint: Nightly builds

Hours Analysis:

Total hours per month: 730 hours (24/7)
Work hours per month: ~189 hours (9 hours x ~21 weekdays)
Nightly CI/CD hours: ~63 hours (~3 hours x 21 weeknights)
Total needed hours: ~252 hours
Idle hours per month: 478 hours (65.5%)

Savings Projection:

  • EC2 savings: $91 x 65.5% = $60/month
  • RDS savings: $50 x 65.5% = $33/month
  • EKS node savings: $220 x 65.5% = $144/month
  • Total monthly savings: $237/month ($2,844/year)

CI/CD Compatibility Options

Option A: Extended Day Schedule (Recommended)

  • Start: 9am EST, Stop: 2am EST (after CI/CD completes)
  • Savings: ~65%
  • Simple to implement, preserves all workflows

Option B: Migrate to Ephemeral CI/CD

  • Use GitHub Actions or AWS CodeBuild (no 24/7 costs)
  • Savings: ~74%
  • Requires 1-2 days migration work

Prioritized Implementation

Priority 1: Kubernetes Cluster (55% of costs)

# Lambda function for EKS scaling
import boto3
eks = boto3.client('eks')
def lambda_handler(event, context):
action = event.get('action')
if action == 'stop':
eks.update_nodegroup_config(
clusterName='dev-cluster',
nodegroupName='main-nodegroup',
scalingConfig={'minSize': 0, 'maxSize': 0, 'desiredSize': 0}
)
elif action == 'start':
eks.update_nodegroup_config(
clusterName='dev-cluster',
nodegroupName='main-nodegroup',
scalingConfig={'minSize': 3, 'maxSize': 5, 'desiredSize': 3}
)
return {'statusCode': 200}

EventBridge Schedules (Extended for CI/CD):

# Start at 9am EST (2pm UTC)
aws events put-rule \
--name start-eks-dev \
--schedule-expression "cron(0 14 ? * MON-FRI *)"
# Stop at 2am EST (7am UTC) - after nightly CI/CD
aws events put-rule \
--name stop-eks-dev \
--schedule-expression "cron(0 7 ? * TUE-SAT *)"

Priority 2: EC2 Instances

aws ec2 create-tags \
--resources i-xxxxx1 i-xxxxx2 i-xxxxx3 \
--tags Key=Schedule,Value=dev-extended

Priority 3: RDS Database

aws rds add-tags-to-resource \
--resource-name arn:aws:rds:REGION:ACCOUNT:db:your-dev-db \
--tags Key=Schedule,Value=dev-extended

Note: AWS RDS auto-restarts after 7 days stopped.

4-Week Rollout Plan

Week 1: K8s cluster only - manual test, then deploy Lambda
Week 2: Monitor K8s stability, verify CI/CD compatibility
Week 3: Add EC2 instances to schedule
Week 4: Add RDS database, full validation

Rollback Procedure

# Disable schedules
aws events disable-rule --name start-eks-dev
aws events disable-rule --name stop-eks-dev
# Scale up immediately
aws eks update-nodegroup-config \
--cluster-name dev-cluster \
--nodegroup-name main-nodegroup \
--scaling-config minSize=3,maxSize=5,desiredSize=3
aws ec2 start-instances --instance-ids i-xxxxx1 i-xxxxx2 i-xxxxx3
aws rds start-db-instance --db-instance-identifier your-dev-db

Summary

What You’re Getting:

  • $237/month savings ($2,844/year) with 3-5 hours implementation
  • 55% cost reduction (preserves nightly CI/CD)
  • Option to reach 74% savings after migrating to ephemeral CI/CD
  • 4-week safe rollout with full rollback capability

Next Action: Test K8s manual scaling this Friday, deploy Lambda scheduler Monday.