Created
November 17, 2016 10:14
-
-
Save my-janala/2bffe88f7ef7ffcb76f37a52486d698c to your computer and use it in GitHub Desktop.
creating a simple lambda function to start ec2 instances
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 | |
# 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