Created
March 23, 2021 18:13
-
-
Save asolera/d00e74ae682e3617aacbb8ffa2c5aaf8 to your computer and use it in GitHub Desktop.
Start AWS EC2 Instances with Lambda
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 | |
# Enter the region your instances are in, e.g. 'us-east-1' | |
region = 'us-east-1' | |
# Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX'] | |
instances = ['i-0ab7xdx71x8xeff33'] | |
def lambda_handler(event, context): | |
ec2 = boto3.client('ec2', region_name=region) | |
ec2.start_instances(InstanceIds=instances) | |
return 'Starting instances...' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment