Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique and constant ID from Amazon EC2 instance

I'm looking for a unique ID associated with an Amazon EC2 instance. This ID must not change across reboots/poweroff-on/etc, and the ID must not be able to be duplicated (by cloning the instance) etc.

Can someone confirm if the instance id (i-XXXXXX) is such a number? If not, I suspect I could use the MAC address (if the instance has ENI option which makes MAC permanent).

Is there another number to use?

like image 775
TSG Avatar asked Oct 27 '25 09:10

TSG


1 Answers

Your instance IDs are globally unique, for as long as you have access to the resource.

source: https://forums.aws.amazon.com/message.jspa?messageID=319825


By access, I mean so long as the instance is in your console / assigned to your account.

If you can't see the instance in your console, you can assume you no longer have access to that resource (and as such, can't expect you'll ever get another instance with the same ID).

If you see the instance in your console, regardless of state (other than terminated, which takes some minutes to be cleaned up from the console), the instance is "yours" and the unique ID will not change. This includes reboots.

If your instance needs to be "re-provisioned" or some other terminology in a notice from AWS, you can expect the instance will come up with a different unique ID. This sometimes happens if the underlying host that's servicing what you see as your "instance" needs maintenance work done that can not avoid a restart / tearing down of the instances that machine hosts, etc. Typically, this will not occur without ample notice from AWS.

like image 79
MrDuk Avatar answered Oct 30 '25 05:10

MrDuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!