Reputation: 5321
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.
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.
Upvotes: 0
Views: 2299
Reputation: 1167
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.
You can check get-resource-config-history and find resources between specific dates.
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).
Upvotes: 2