Amazon AWS: How to get details of terminated EC2 instance from instance id

徘徊边缘 提交于 2019-12-30 05:39:27

问题


One of our EC2 instance went missing from running instance list, probably it got terminated accidentally by someone.

In cloudtrail events, I can see some terminate instance events along with event time, user and instance id's which got terminated.

Problems is, as instances are already terminated I am not able to find more details of those instances using instance id.

I am interested in more details such as ami, key pair, tags.

Is there a way to get these details for terminated instance?


回答1:


If the instance was started in the last 90 days, you can get the information you want from Cloudtrail dashboard.

If the instance was started more than 90 days ago: If you have Cloudtrail enabled and configured it to write to S3, then you can go through the Cloudtrail log and look for events related the instance id. If you are able to find the RunInstances event for that instance id, then you can get all information about that instance from that event.

The logs are compressed json files generated many times a day. It takes few lines of Python code to read the log files and find the events tied to that instance.

I have done the exact same thing and was able to get the information from cloudtrail logs.



来源:https://stackoverflow.com/questions/35054422/amazon-aws-how-to-get-details-of-terminated-ec2-instance-from-instance-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!