Problem:
You are using Skeddly to start an EC2 instance and your EC2 instance starts, but it then immediately stops.
However, using the AWS Management Console, you are able to start the same EC2 instance without problems.
Please Check:
On the AWS Management Console:
Check your EC2 instance's "State Transition Reason" and "State Transition Reason Message" values:
Go to the EC2 Management Console
Click "Instances" on the left navigation bar
Find your EC2 instance in the list of instances and select it.
In the details pane, find the following:
State transition reason: Server.InternalError
State transition reason message: Client.InternalError: Client error on launch
Check if your root EBS volume is encypted using a KMS key:
Go to the EC2 Management Console
Click "Volumes" on the left navigation bar
Find your root EBS volume in the list of volumes and select it.
In the details pane, find the following:
Solution:
To resolve this issue, there are 2 possible options.
Option 1: Allow the IAM role/user used by Skeddly to access the KMS key
Find the KMS key used to encrypt the EBS volume in the KMS Management Console.
Modify the "Key Policy" of the KMS key to allow the IAM role/user to "allow use of the key". You do this by adding your IAM role/user to the "Key users" section.
Once the user is allowed to "use" the KMS keys, the EC2 instance should start correctly.
Option 2: Allow the IAM role/user used by Skeddly to execute kms:CreateGrant
In the IAM Management Console, find the IAM role/user used by Skeddly.
Add a new "Inline Policy" to the user with the following JSON body:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCreateGrant",
"Effect": "Allow",
"Action": "kms:CreateGrant",
"Resource": "*"
}
]
}
This policy will allow the IAM role/user to grant permission to AWS to use the KMS key.
With this policy applied to the IAM role/user, the EC2 instance should start correctly.