Are you looking for solutions to AWS error "instance terminates immediately error"?
This guide is for you.
When you terminate an EC2 instance, the instance will be shutdown and the virtual machine that was provisioned for you will be permanently taken away and you will no longer be charged for instance usage. Any data that was stored locally on the instance will be lost.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix AWS related errors.
In this context, we shall look into the the causes for this error and steps to fix it.
There are different reasons for an instance to terminate immediately after launching or starting it. Here are some of them;
i. Reaching the EBS volume limit.
ii. Corruption of EBS snapshot
iii. You do not have permission to access the KMS key for decryption since the root EBS volume is encrypted.
iv. The instance store-backed AMI that you used to launch the instance is missing a required part (an image.part.xx file).
First, we need to find the reason for this error in order to resolve it. We can find it through the Amazon EC2 console or AWS Command Line Interface to get the termination reason.
Then follow the steps below to tackle why the termination reason through the Amazon EC2 console;
i. First, open the Amazon EC2 console using the link: https://console.aws.amazon.com/ec2/
ii. Then in the left navigation pane, choose Instances, and select the instance.
iii. After that, from the Description tab, you can find the reason next to the State transition reason label. Now, note it down.
To find the termination reason through the AWS Command Line Interface, follow the steps below;
i. Run the below describe-instances command and specify the instance ID.
ii. aws ec2 describe-instances –instance-id instance_id
iii. As a result, of the above command, a JSON result is received. Now, please note down the values in the StateReason response element.
For example, here is a code of 'StateReason' response element;
“StateReason”: {
“Message”: “Client.VolumeLimitExceeded: Volume limit exceeded”,
“Code”: “Server.InternalError”
},
In cases where the reason for the error is "Client.VolumeLimitExceeded: Volume limit exceeded" then you have reached the EBS volume limit.
In case, if the reason for the error is "Client.InternalError: Client error on launch" then it indicates that the root volume is encrypted but you have no permissions to access the KMS key for decryption. To get permission to access the required KMS key, add the appropriate KMS permissions to your IAM user.
This article will guide you on the different methods to resolve AWS error "instance terminates immediately" which occurs due to different reasons.