This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import time | |
## | |
# First function will try to filter for EC2 instances that contain a tag named `Scheduled` which is set to `True` | |
# If that condition is meet function will compare current time (H:M) to a value of the additional tags which defines the trigger `ScheduleStop` or `ScheduleStart`. | |
# Value of the `ScheduleStop` or `ScheduleStart` must be in the following format `H:M` - example `09:00` | |
# | |
# In order to trigger this function make sure to setup CloudWatch event which will be executed every minute. | |
# Following Lambda Function needs a role with permission to start and stop EC2 instances and writhe to CloudWatch logs. |