Automatically stop dev/staging EC2 and RDS instances at night, start them in the morning. Save up to 65% on non-production AWS costs.
Your dev and staging environments run 24/7 but are only used 10 hours a day, 5 days a week. That's 70% waste.
Without scheduling: 24h × 7d = 168 hours/week (paying for all)
With scheduling: 10h × 5d = 50 hours/week (paying for usage)
Savings: 70% reduction
Lambda (Start) Lambda (Stop)
│ │
8:30 AM IST ──► Start EC2 + RDS 8:00 PM IST ──► Stop EC2 + RDS
(Mon-Fri) instances (Mon-Fri) instances
│ │
EventBridge EventBridge
Cron Schedule Cron Schedule
module "scheduler" {
source = "github.com/akshayghalme/terraform-scheduled-scaling"
name = "dev-env"
ec2_instance_ids = ["i-0abc123", "i-0def456"]
rds_instance_ids = ["dev-database"]
# Start at 8:30 AM IST (3:00 AM UTC) Mon-Fri
start_cron = "0 3 ? * MON-FRI *"
# Stop at 8:00 PM IST (2:30 PM UTC) Mon-Fri
stop_cron = "30 14 ? * MON-FRI *"
tags = { Environment = "dev" }
}| Work Hours (Local) | Timezone | start_cron | stop_cron |
|---|---|---|---|
| 9 AM – 6 PM | IST (UTC+5:30) | 30 3 ? * MON-FRI * |
30 12 ? * MON-FRI * |
| 9 AM – 6 PM | UTC | 0 9 ? * MON-FRI * |
0 18 ? * MON-FRI * |
| 9 AM – 6 PM | EST (UTC-5) | 0 14 ? * MON-FRI * |
0 23 ? * MON-FRI * |
| 9 AM – 6 PM | PST (UTC-8) | 0 17 ? * MON-FRI * |
0 2 ? * TUE-SAT * |
| Resource | Monthly (24/7) | Monthly (scheduled) | Savings |
|---|---|---|---|
| t3.medium EC2 | $30.40 | $9.10 | $21.30/mo |
| db.t3.medium RDS | $49.60 | $14.90 | $34.70/mo |
| 3 EC2 + 1 RDS dev env | $140.80 | $42.20 | $98.60/mo |
| Annual (above) | $1,689 | $507 | $1,182/year |
| Name | Description | Default |
|---|---|---|
name |
Name prefix | required |
ec2_instance_ids |
EC2 IDs to schedule | [] |
rds_instance_ids |
RDS identifiers to schedule | [] |
start_cron |
Start cron (UTC) | 0 3 ? * MON-FRI * |
stop_cron |
Stop cron (UTC) | 30 14 ? * MON-FRI * |
- All cron times are in UTC
- RDS instances take 5-10 minutes to start/stop
- RDS auto-restarts after 7 days if stopped — this module handles re-stopping
- Tag your EC2 instances with
ScheduledScaling = true
MIT
Akshay Ghalme — akshayghalme.com