Skip to content

Instantly share code, notes, and snippets.

@asolera
Created March 23, 2021 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolera/d00e74ae682e3617aacbb8ffa2c5aaf8 to your computer and use it in GitHub Desktop.
Save asolera/d00e74ae682e3617aacbb8ffa2c5aaf8 to your computer and use it in GitHub Desktop.
Start AWS EC2 Instances with Lambda
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