0
votes

I added Cloudwatch Logs trigger to Lambda function, which gets triggered when a particular word is found(for example: 'application started') and then it processes certain functions like sending an SNS Notification. What I need is help with the python code to reboot an EC2 instance from inside the lambda function. I've seen everyone doing start and stop EC2 instances from lambda's but not rebooting them.

Thanks!

1

1 Answers

0
votes

You can check this documentation, which explains the reboot_instances command from boto3 package.

import boto3

ec2 = boto3.client('ec2')
response = ec2.reboot_instances(InstanceIds=['string'])

So simple.