Instance Scheduler
Setting up AWS Instance Scheduler to save EC2 instance costs for your dev/uat servers.
Use Case
When you have EC2 instances which are running when not needed (outside of work hours, on holidays, etc.) and billing you for it, Instance Scheduler will help you cut down on these costs by reducing the uptime of the server instance by shutting it down with a schedule but also conveniently bringing it back when needed (as scheduled).
Instructions
Disclaimer
This guide is correct and up to date only as of the publishing date. AWS have the rights to change features regarding this or change the pricing on their platform. I am not responsible for their actions, use the guide mainly as a reference but check their website and documentation for the updated details.
Special Thanks
THanks to DeshDeepakDhobi (DD) for his guide over on Medium which I used as a base to this guide. Some of the details seem a bit confusing and incomplete on his guide as well as the screenshots are a bit outdated, thus this new guide.
Set up Instance Scheduler in CloudFormation
Launch in the AWS Console option.
Region Check
Ensure you're on the correct region or you will end up creating the job in the wrong region.
On that page, you could change any options you want, but we'll keep the defaults and click Next.
Specify Stack Details page, give your CloudFormation Stack a name like dev-server-scheduler, and your Instance Scheduler a tag name like dev-scheduler. Set the default time zone to your time zone, this would help you avoid converting times later.
Frequencydepends on what you would schedule your timtings as. If you're doing something like 08:00 to 18:00, then I think a 60 minute frequency is good enough.- You could enable CloudWatch logs and metrics if you need. Do add
Started tagsandStopped tags, this would help you differentiate between Manual starts of the instance vs Instance Scheduler's.
Configure stack options page, I decided to keep everything default, you could add a role, if you already have or need something specific, for CloudFormation to use, but it'll create it's own role if you keep it empty.
CREATE_COMPLETE like in the image.
DynamoDB Setup
Tables option in the left sidebar.
ConfigTable in the name. Open that table and click on the Explore table items button.
period and schedules. We'll use the seattle-office-hours schedule and office-hours period for our purpose.
office-hours period as per the image, you can edit the timings and weekdays as you need.
seattle-office-hours schedule as per the image, while changing the name, description, and timezone as you need.
EC2 Tags
Actions > Instance Settings > Manage Tags.
dev-scheduler
Testing
Enjoy saving $$$, cheers!
