Created
February 23, 2019 18:50
-
-
Save 100daysofdevops/82b7db36251ca4dbcc2c5bfcc6105639 to your computer and use it in GitHub Desktop.
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
| import boto3 | |
| # Enter the region your instances are in. Include only the region without specifying Availability Zone; e.g., 'us-east-1' | |
| region = 'XX-XXXXX-X' | |
| # Enter your instances here: ex. ['X-XXXXXXXX', 'X-XXXXXXXX'] | |
| instances = ['X-XXXXXXXX'] | |
| def lambda_handler(event, context): | |
| ec2 = boto3.client('ec2', region_name=region) | |
| 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