I have a Lambda function to reboot instances:
import boto3
region = 'us-east-1'
instances = ['i-xxxxxxxxxxxxxxxxxxxxxxxxxx']
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
response = ec2.reboot_instances(
InstanceIds=[
'i-xxxxxxxxxxxxxxxxxxxxxx',
],
)
print(response)
It just refuses to work.
The response when I trigger it:
{'ResponseMetadata': {'RequestId': '12994c92-98ab-4b62-bc10-a0e0b4881aaa', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': '12994c92-98ab-4b62-bc10-a0e0b4881aaa', 'content-type': 'text/xml;charset=UTF-8', 'content-length': '231', 'date': 'Sun, 30 Aug 2020 15:44:40 GMT', 'server': 'AmazonEC2'}, 'RetryAttempts': 0}}
The interesting part: if I change ec2.reboot_instances to ec2.start_instances then it works.
So I am trying to find out why would a reboot command be refused and a start/stop command be accepted?
Note: I included the permission in IAM to reboot instances. The instance is a linux openvpn server AMI bundle
start_instances()
-- does that mean the instance was in a Stopped state? How are you confirming whether the reboot worked -- I don't think it appears in the system status, you would need to connect to the instance to know if it is working. – John Rotenstein