在AWS EC2中,如何查找不再存在的实例的元数据?

huangapple go评论121阅读模式
英文:

In AWS EC2, how to find metadata of an instance that no longer exists?

问题

我正在使用CloudTrail事件来重建过去90天的EC2使用历史记录,具有高时间分辨率。

对于某些实例,我知道ID,但不知道实例类型(例如,因为日志包含TerminateInstance事件,但前面的RunInstance事件已过期)。DescribeInstances EC2 API操作返回一个不存在的错误(可能是因为具有该ID的实例已经终止太久)。

在我仍然知道实例ID的情况下,如何找到不再存在的实例的实例类型?

英文:

I'm using CloudTrail Events to reconstruct the last 90 days of EC2 usage history with high temporal resolution.

For some instances I know the ID but not the instance type (for example, because the log contains the TerminateInstance event but the preceding RunInstance event has expired). The DescribeInstances EC2 API operation returns a non-existence error (presumably because the instance with that ID terminated too long ago).

How can I find the instance-type for an instance that no longer exists, assuming I still know the instance-id?

答案1

得分: 1

这可以潜在地从配置服务中提取。

配置服务应该是关于EC2实例状态历史信息的权威来源。即使相关的API事件历史(运行、启动、停止和终止事件)是完整的,有时实例可能会改变状态(例如自行关闭)而没有任何外部API事件。配置服务的保留期也可能与CloudTrail不同。

aws configservice get-resource-config-history                             \
         --resource-type AWS::EC2::Instance                               \
         --resource-id i-XXXXXXX                                          \
         --max-items 2                                                    \
| jq '.configurationItems[1].configuration | fromjson | .instanceType'
英文:

This can potentially be extracted from the config service.

The config service should be the authoritative source of information on an EC2 instance's status history. Even if the relevant API event history (the Run, Start, Stop and Terminate events) were complete, sometimes an instance may change state (e.g. shut itself down) without any external API event. The config service may also have a different retention period than CloudTrail.

aws configservice get-resource-config-history                             \
         --resource-type AWS::EC2::Instance                               \
         --resource-id i-XXXXXXX                                          \
         --max-items 2                                                    \
| jq '.configurationItems[1].configuration | fromjson | .instanceType'

huangapple
  • 本文由 发表于 2023年3月12日 08:58:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75710494.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定