Created
September 22, 2020 15:34
-
-
Save mcj-la/a51477a3886cdf6f615b076bf9246d07 to your computer and use it in GitHub Desktop.
Lambda Function
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 | |
#This simple lambda function is available from AWS with instructions on starting and stopping an instance at regular intervals using Lambda and CloudWatch: https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/ | |
# Enter the region your instances are in. Include only the region without specifying Availability Zone; e.g., 'us-east-1' | |
region = 'us-east-1' | |
# Enter your instances here: ex. ['X-XXXXXXXX'] you can comma separate the instance IDs for more than one instance: i.e. ['X-XXXXXXXXX', 'X-XXXXXXXXX"] | |
instances = ['i-0902effe70a087ae7'] | |
def lambda_handler(event, context): | |
ec2 = boto3.client('ec2', region_name=region) | |
ec2.stop_instances(InstanceIds=instances) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can we pull multiple instance id's from lambda environment variables ?