简体   繁体   English

如何使用命令行检查 aws ec2 实例创建日期?

[英]How to check the aws ec2 instance creation date using command line?

To determine how old the aws ec2 instances are, and to destroy those nodes if they are older than 90 days, I need to check the creation date of the node.要确定 aws ec2 实例的年龄,并销毁超过 90 天的节点,我需要检查节点的创建日期。

What is the correct way to do that using COMMAND LINE?使用命令行执行此操作的正确方法是什么?

What I tried?我试过什么?

I tried the command ec2metadata , but the output doesn't contain creation date.我尝试了命令ec2metadata ,但 output 不包含创建日期。

You can get this information with您可以通过以下方式获取此信息

aws configservice get-resource-config-history --resource-type AWS::EC2::Instance --resource-id i-xxxxxxxx   

The last element in this json is what you need.这个 json 中的最后一个元素就是你需要的。
You can check get-resource-config-history and find resources between specific dates.您可以检查get-resource-config-history并查找特定日期之间的资源。
You can also get creation date of your root volume with您还可以使用以下方式获取根卷的创建日期

aws ec2 describe-volumes --volume-ids vol-xxxxx    

This can also give you age of your root volume (if not changed).这也可以为您提供根卷的年龄(如果未更改)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM