Skip to content

Instantly share code, notes, and snippets.

@my-janala
Created November 17, 2016 10:14
Show Gist options
  • Save my-janala/2bffe88f7ef7ffcb76f37a52486d698c to your computer and use it in GitHub Desktop.
Save my-janala/2bffe88f7ef7ffcb76f37a52486d698c to your computer and use it in GitHub Desktop.
creating a simple lambda function to start ec2 instances
import boto3
# Enter the region your instances are in, e.g. 'us-east-1'
region = 'eu-west-1'
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX']
instances = ['i-21d32eac', 'i-08a54cc8']
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