Last active
November 21, 2020 18:25
-
-
Save bmwitcher/4a1e00d5394e1fc3f5d58b8f40c78ee0 to your computer and use it in GitHub Desktop.
stop ec2 lambda python code
This file contains hidden or 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
# 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