Skip to content

Instantly share code, notes, and snippets.

@100daysofdevops
Created February 23, 2019 20:08
Show Gist options
  • Select an option

  • Save 100daysofdevops/21947bcdfd701e7269a4df4693a6cc62 to your computer and use it in GitHub Desktop.

Select an option

Save 100daysofdevops/21947bcdfd701e7269a4df4693a6cc62 to your computer and use it in GitHub Desktop.
import boto3
# Enter the region your instances are in. Include only the region without specifying Availability Zone; e.g.; 'us-east-1'
region = 'XX-XXXXX-X'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['X-XXXXXXXX']
def lambda_handler(event, context):
ec2 = boto3.client('ec2', region_name=region)
ec2.start_instances(InstanceIds=instances)
print 'started your instances: ' + str(instances)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment