Blog Details

How to Stop and Start instances using the AWS Instance Scheduler – STOPINATOR -100 days of cloud: Day 6

+1
0
+1
0
+1
0
+1
0
+1
0

DAY 6 – STOPINATOR- Start and Stop EC2 at predefined times 🔴🟢

#webdev #devops #automation #aws

☁️100 days of Cloud- Day Six
✅Follow Me on Twitter

Cover

Tweet This Blog – Read on GitHub – Read On iCTPro.co.nz


Stopping and starting EC2 instances automatically

Using Instance scheduler you can start and stop instance automatically using Cloud formation

Prerequisites

Installing Scheduler CLI

curl "https://s3.amazonaws.com/solutions-reference/aws-instance-scheduler/latest/scheduler-cli.zip" -o "scheduler-cli.zip"

Unzip

unzip scheduler-cli.zip

Install

sudo python setup.py install

Check

scheduler-cli --version

Creating AWS CloudFormation Stack

Launch Solution , or download template

Comments ScreenShots
Click on to Launch Solution Stack launch
Enter Stack Name Image StackName
Choose your frequency (in Mins) Image frequency
Enable CloudWatch Logs Image Cloudwatchlogs
Start & Stop tag Image startandstop
keep everything default and acknowledge then click create stack Image Stack creation

Creating Start and Stop Period

Go to instance and paste this script

scheduler-cli create-period --stack Ec2instanceScheduler --region ap-southeast-2 --name mon-fri-9-5 --begintime 9:00 --endtime 16:59 --weekdays mon-fri

Here i am setting up to start time 9 am and stop time 4.59 Pm from Monday to Friday.

Now go to AWS Console and open the DynamoDB.

Click on to Tables and choose the config table .
Then Choose the Items , and check for QuickPeriod appears under Name.

Creating Schedule for the period

Each schedule must contain at least one schedule period, it defines the time instance should run.

SSH into ec2

scheduler-cli create-schedule --stack Ec2Stopinator --name QuickSchedule --region ap-southeast-2 --periods QuickPeriod --timezone PST

goto the DynamoDB.

Click on to Tables and choose the config table .
Then Choose the Items , and check for QuickSchedule appears under Name.

Tagging the Schedule

Now got to ec2 and select Manage tags
Key = Schedule
Value = QuickSchedule

🎉 Congratulations 🎉 you have successfully configured STOPINATOR