Closed atqhg23 closed 1 year ago
Thanks for raising this @atqhg23. Really interesting discovery. Let me look into it and see what the best approach would be.
The issue with using the root volume attach time is that the root volume can be replaced which would return the wrong time if it had been replaced.
I checked with AWS on this, and it seems like the best approach would be to use the attach time of the instance's primary ENI since the primary ENI cannot de detached or deleted until the EC2 instance is deleted as well. The primary ENI can be identified by looking at the DeviceIndex, the primary ENI will always have the DeviceIndex set to 0.
Thanks for that info @atqhg23. I've made the change within https://github.com/servian/aws-auto-cleanup/tree/better-ec2-launch-time
Mind testing it out for me? 😄
Will do, thanks!
This worked! Thanks again for the help
Describe the bug Currently, the launch time is used to determine the age of the EC2 instance, but this value is reset when someone restarts the instance allowing users to indefinitely keep an instance from being cleaned up.
To Reproduce
Expected behavior I looked into this and it seems like looking at the root volume attach time is the best way to determine the actual age of an instance.