Created
June 16, 2021 10:58
-
-
Save MrHassanMurtaza/34d14636eb637fc96e4db689f65abc56 to your computer and use it in GitHub Desktop.
reboot ec2 instance using lambda
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 json | |
import boto3 | |
EC2_INSTANCE_ID="i-xxxxxx" | |
ec2_handle = boto3.client( | |
'ec2' | |
) | |
def lambda_handler(event, context): | |
response = ec2_handle.reboot_instances( | |
InstanceIds=[ | |
EC2_INSTANCE_ID, | |
], | |
DryRun=False # change to True for dryrun | |
) | |
return { | |
'statusCode': 200, | |
'body': response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment