CloudWatch Events allow us to create rules that we can trigger by services and API calls or through scheduling. These rules can then interact with many different services in our environment. CloudWatch Events are the central block in many automation workflows we can build as well. This lesson dives into the specifics and shows some examples of how we can use this service.
import boto3 def lambda_handler(event, context): # set the region to the region the event occured in region=event['region'] instances=[event['detail']['instance-id']] print 'detected stopped instance : ' + str(instances) ec2 = boto3.client('ec2', region_name=region) ec2.start_instances(InstanceIds=instances) print 'started your instances: ' + str(instances)