Lesson 8-AWS SysOps Administrator Associate

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%.

14 Topics
5 Quiz Questions
55 XP Reward

What You'll Learn

1

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.

Vocabulary

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
6

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

1

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.

2

Define Schedules in DynamoDB

Create schedule entries in the DynamoDB table specifying running periods (e.g., 8 AM - 6 PM, Monday-Friday).

3

Tag Your Resources

Add the schedule tag (default: 'Schedule') to EC2 and RDS instances with the schedule name as the value.

4

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

1. Deploy Instance Scheduler via CloudFormation 2. Create schedule 'dev-hours': Monday-Friday, 8:00 AM - 6:00 PM 3. Tag all 20 instances with 'Schedule: dev-hours' 4. Instances automatically stop at 6 PM and start at 8 AM

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.

Comparison

Cost Savings Scenarios

ScenarioRunning HoursCost Reduction
24/7 (baseline)168 hrs/week0%
Business hours only50 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

  1. Start with non-production environments to test schedules before applying to critical resources
  2. Use timezone-aware schedules to match your users' working hours
  3. Create exception schedules for resources that occasionally need extended hours
  4. Monitor CloudWatch logs to ensure the scheduler is working correctly
  5. 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/

Reflection

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 Lesson

Continue Your Journey