user2732748
user2732748

Reputation: 97

Find the reason for the failure of a EC2 instance

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

Answers (2)

cjwfuller
cjwfuller

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:

activity history

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

Chandan Nayak
Chandan Nayak

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:

  1. Create a new CloudWatch event
  2. In Event selector section, select specific and choose Terminated
  3. Select target instance as Any or Specific
  4. Add a target as SNS topic for notification

Upvotes: 1

Related Questions