This script checks for instances with tags "start", "shutdown" or "restart" and starts, stops or restarts them based on the time specified in the tag value relative to the past execution.
- Build the container
docker build .
- Set up the necessary IAM permissions for the script to run. An example IAM policy would be:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "EC2StateSchedulerPermissions", "Effect": "Allow", "Action": [ "ec2:DescribeInstances", "ec2:StartInstances", "ec2:StopInstances", "ec2:RebootInstances" ], "Resource": "*" } ] }
- Schedule the container in your favorite container orchestration platform.
- Profit
- Set up your AWS credentials using one of the methods described in the Boto3 documentation.
- Install requirements
pip install -r requirements.txt
- Run the script:
python app.py
This project is licensed under the terms of the LICENSE file.
Unit tests are located in app.test.py
and can be executed via python app.test.py
.