Last active
April 19, 2023 09:17
-
-
Save nhammad/fe7e3b8e6d5d013840a9e7142402736a 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 logging | |
import os | |
import boto3 | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
def turn_off_instances(instance_ids): | |
ec2 = boto3.client('ec2', region_name=region) | |
ec2.stop_instances(InstanceIds=instance_ids) | |
logger.info(f'Instance stopped') | |
def lambda_handler(event, context): | |
logger.info(f'event info: {event}') | |
global region | |
region = 'eu-east-1' | |
instance_ids = ["test-instance-id-1245"] | |
turn_off_instances(instance_ids) | |
return { | |
'statusCode': 200, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment