Amazon AWS:如何从实例ID获取终止的EC2实例的详细信息 [英] Amazon AWS: How to get details of terminated EC2 instance from instance id

查看:423
本文介绍了Amazon AWS:如何从实例ID获取终止的EC2实例的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个EC2实例从正在运行的实例列表中丢失,可能是某人意外终止了它。

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

在cloudtrail事件中,我可以看到一些终止实例事件以及事件时间,被终止的用户和实例ID。

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

问题是,由于实例已经终止,因此我无法使用实例ID找到这些实例的更多详细信息。

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

我对更多详细信息感兴趣,例如ami,密钥对,标签。

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

是否可以获取终止实例的这些详细信息?

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

推荐答案

如果实例在最近90天内启动,则可以从Cloudtrail仪表板获取所需的信息。

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

如果实例是开始于90天之前:如果启用了Cloudtrail并将其配置为写入S3,则可以浏览Cloudtrail日志并查找与实例ID相关的事件。如果您能够找到该实例ID的 RunInstances 事件,则可以从该事件中获取有关该实例的所有信息。

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.

日志是每天生成多次的压缩json文件。只需几行Python代码即可读取日志文件并查找与该实例相关的事件。

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.

我做了完全一样的事情,并且能够获取信息来自cloudtrail日志。

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

这篇关于Amazon AWS:如何从实例ID获取终止的EC2实例的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆