Issue
I'm running Python code on an instance and I'm trying to start an EC2 instance using boto3 start_instances
. The code works and gives the following response:
Response: {'StartingInstances': [{'CurrentState': {'Code': 0, 'Name': 'pending'}, 'InstanceId': 'i-<id>', 'PreviousState': {'Code': 80, 'Name': 'stopped'}}], [..]
But in the UI it's not up, not even pending. I've run the code 7 times and its the same thing. To make a test, I tried the opposite: I started the instance using the UI and used the stop_instances
function and it worked!
The permissions are these:
"ec2:StartInstances",
"ec2:StopInstances"
What might be happening?
Solution
The problem was that the instance that I was trying to start have an encrypted EBS volume. Then, it is necessary to give some KMS permissions, I found them here: https://nqbao.medium.com/aws-correct-permission-to-start-an-ec2-instance-with-encrypted-ebs-507933c01511
It is weird that the console don't show an error in this case.
Answered By - Luis Felipe Answer Checked By - Clifford M. (WPSolving Volunteer)