Reputation: 97
When a amazon EC2 instance goes down (AWS), how to find out the reason for the termination of the instance?
Is it possible to add a notification for the same?
Thanks.
Upvotes: 1
Views: 731
Reputation: 450
If the instance is in an auto-scaling group, you can look at the "Activity History" tab to find out broadly, why an instance went down e.g. it was considered unhealthy:
If your instances keep getting terminated, login to the instance before it goes down and watch any relevant logs. Or, even better, if your logs are going to CloudWatch then you can look at the instance logs there.
@Chandan Nayak's answer explains how to configure the SNS messaging.
Upvotes: 1
Reputation: 10877
After you launch an instance, you can check its status to confirm that it goes from the pending state to the running state, not the terminated state. If it is terminated you can check the description with ec2-describe-instances instance_id -v
as mentioned here : More Info - AWS Docs
If it gets launched correctly and goes to running state, it should not go to terminated state without explicit action on it, You can use terminate protection
option when creating the instance to remove the scope of accidental click.
If you want to use send notification, you can create a CloudWatch Event which can trigger a SNS topic:
Upvotes: 1