Skip to content

Instantly share code, notes, and snippets.

@bmwitcher
Last active November 21, 2020 18:25
Show Gist options
  • Save bmwitcher/4a1e00d5394e1fc3f5d58b8f40c78ee0 to your computer and use it in GitHub Desktop.
Save bmwitcher/4a1e00d5394e1fc3f5d58b8f40c78ee0 to your computer and use it in GitHub Desktop.
stop ec2 lambda python code
# Stops the EC2 instances
import boto3
region = 'us-east-1'
instances = ['i-12345', 'i-2345']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment