In this hands-on lab, we will deploy the AWS Instance Scheduler solution to shut down an EC2 instance based on a custom schedule we will create. Instance Scheduler can help you save money and provide cost optimization for workloads.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Deploy AWS Instance Scheduler
- Navigate to the AWS Instance Scheduler.
- Click Launch solution in the AWS Console.
- In the CloudFormation console, enter a name for our CloudFormation stack.
- Add tags:
started-by=InstanceScheduler
stopped-by=InstanceScheduler
- Edit the DynamoDB Tables
- Navigate to DynamoDB > Tables.
- elect the ConfigTable.
- Select the
uk-office-hours
item. - Click Actions > Duplicate.
- Change the description to "Office hours in US".
- Change the string to "us-office-hours".
- Change the time zone to "US/Eastern".
- Click Save and then refresh the table.
- Add Tag to EC2 Instance
- Navigate to EC2 > Instances.
- Select the running instance.
- Add the following tag:
- Key: Schedule
- Value: us-office-hours
- Click Save.
- Update CloudWatch Events Rule
- Navigate to CloudWatch > Rules.
- Select the listed rule.
- Click Actions > Edit.
- Under Event Source, select Fixed rate of.
- In the box, enter "1".
- From the dropdown, select Minutes.
- Click Configure details.
- Click Update rule.
- Update DynamoDB Config Table
- Navigate to DynamoDB > Tables.
- Click the ConfigTable.
- Update the
endtime
so the business day ends five minutes from your current time (e.g., if it’s 8 AM where you are right now, change theendtime
to08:05
.) - Click Save.
- Verify EC2 Instance Stopped
- Navigate to EC2 > Instances.
- Verify our EC2 instance has stopped.