Instance Scheduler on AWS
Learn to use AWS Instance Scheduler to automatically start and stop EC2 instances and RDS databases on schedules, reducing costs by up to 70%.
What You'll Learn
Automated Cost Optimization
Many organizations run EC2 instances and RDS databases around the clock, even when they're only needed during business hours. AWS Instance Scheduler is a solution that automatically starts and stops these resources on a schedule you define. This can reduce compute costs by up to 70% for development, testing, and other non-production environments.
Key Point
Instance Scheduler can reduce costs by up to 70% by automatically stopping instances outside of business hours.
It's a Solution, Not a Service
Instance Scheduler is an AWS Solution—a reference implementation deployed via CloudFormation—not a managed AWS service. You deploy and manage the infrastructure yourself, which gives you full control and customization options.
Key Terms
An AWS Solution that automates starting and stopping of EC2 and RDS resources based on defined schedules
A configuration that defines when resources should be running, stored in DynamoDB
AWS tags applied to EC2 or RDS instances that associate them with a specific schedule
Instance Scheduler Architecture
How the Instance Scheduler solution components work together
CloudFormation
Deploys the solution
Lambda Function
Executes start/stop logic
EC2 Instances
Tagged with schedule
RDS Instances
Tagged with schedule
Auto Scaling Groups
Scale to 0/desired
DynamoDB
Stores schedules
Supported Resources
- EC2 Instances: Standalone instances can be stopped and started
- EC2 Auto Scaling Groups: Min/Max/Desired can be scaled to 0 and back
- RDS Instances: Database instances can be stopped and started
- Cross-account resources: Schedule resources in other AWS accounts
- Cross-region resources: Schedule resources across multiple regions
How It Works
The Instance Scheduler uses a Lambda function triggered on a regular interval (typically every 5 minutes). The Lambda function reads schedule definitions from a DynamoDB table, finds resources tagged with those schedules, and performs start or stop actions based on the current time and the schedule definition.
Key Point
Lambda reads schedules from DynamoDB and starts/stops tagged resources based on current time vs. schedule.
Setting Up Instance Scheduler
Deploy via CloudFormation
Launch the Instance Scheduler CloudFormation template from the AWS Solutions Library. This creates the Lambda function, DynamoDB table, and necessary IAM roles.
Define Schedules in DynamoDB
Create schedule entries in the DynamoDB table specifying running periods (e.g., 8 AM - 6 PM, Monday-Friday).
Tag Your Resources
Add the schedule tag (default: 'Schedule') to EC2 and RDS instances with the schedule name as the value.
Verify Operation
Monitor the Lambda function logs in CloudWatch to verify instances are being started and stopped correctly.
Office Hours Schedule Example
Problem
You have 20 development EC2 instances running 24/7, but developers only work 8 AM - 6 PM on weekdays. This wastes 70% of the compute time.
Solution
Why This Works
Running 10 hours/day instead of 24 hours, 5 days instead of 7, reduces running time from 168 hours/week to 50 hours/week—a 70% reduction in compute costs.
Cost Savings Scenarios
| Scenario | Running Hours | Cost Reduction | |
|---|---|---|---|
| 24/7 (baseline) | 168 hrs/week | 0% | |
| Business hours only | 50 hrs/week | ~70% | |
| Extended hours (12 hrs/day) | 60 hrs/week | ~64% | |
| Weekdays only (24 hrs) | 120 hrs/week | ~29% |
Actual savings depend on your specific schedule and instance pricing
Cross-Account Scheduling
Instance Scheduler supports cross-account scheduling. You can deploy it in a central account and configure it to manage resources in other accounts using IAM cross-account roles. This is ideal for organizations with multiple AWS accounts.
Data Persistence
Remember that stopping an EC2 instance preserves EBS data but loses anything on instance store volumes. For RDS, make sure your application can handle database restarts gracefully.
Best Practices
- Start with non-production environments to test schedules before applying to critical resources
- Use timezone-aware schedules to match your users' working hours
- Create exception schedules for resources that occasionally need extended hours
- Monitor CloudWatch logs to ensure the scheduler is working correctly
- Document your schedules so team members understand when resources will be available
Solution Documentation
For complete documentation and the latest CloudFormation templates, visit: https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/
Pause & Ponder
How would you implement Instance Scheduler in your organization?
- •Which environments would benefit most from scheduling (dev, staging, test)?
- •How would you handle resources that occasionally need to run outside scheduled hours?
- •What monitoring would you put in place to ensure schedules are working correctly?
Ready to Start Learning?
Dive deeper into this lesson with our interactive learning experience. Complete the quiz and earn 55 XP!
Start This LessonContinue Your Journey
EC2 Instance Type Management
Learn how to change EC2 instance types and understand the requirements for resiz...
Lesson 2EC2 Placement Groups
Master EC2 placement group strategies to optimize instance placement for perform...
Lesson 3EC2 SSH Connectivity & Troubleshooting
Master SSH connections to EC2 instances, including traditional SSH, EC2 Instance...