Stop and Start instances using the AWS Instance Scheduler - STOPINATOR
Anuvindh
Posted on February 11, 2022
DAY 6 - STOPINATOR- Start and Stop EC2 at predefined times š“š¢
āļø100 days of Cloud- Day Six
ā
Follow Me on Twitter
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
- Install Scheduler CLI
- Python 2 installed on instance
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 | |
Enter Stack Name | |
Choose your frequency (in Mins) | |
Enable CloudWatch Logs | |
Start & Stop tag | |
keep everything default and acknowledge then click create stack |
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 UTC+1300
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 go to ec2 and select Manage tags
Key = Schedule
Value = QuickSchedule
š Congratulations š you have successfully configured STOPINATOR
Posted on February 11, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.