Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (46 sloc) 2.87 KB

Identify EC2 Linux Instances

Your application might need to determine whether it is running on an EC2 instance.

For information about identifying Windows instances, see Identify EC2 Windows Instances in the Amazon EC2 User Guide for Windows Instances.

Inspecting the Instance Identity Document

For a definitive and cryptographically verified method of identifying an EC2 instance, check the instance identity document, including its signature. These documents are available on every EC2 instance at the local, non-routable address For more information, see Instance Identity Documents.

Inspecting the System UUID

You can get the system UUID and look for the presence of the characters "ec2" or "EC2" in the beginning octet of the UUID. This method to determine whether a system is an EC2 instance is quick but potentially inaccurate because there is a small chance that a system that is not an EC2 instance could have a UUID that starts with these characters. Furthermore, for EC2 instances that are not using Amazon Linux, the distribution's implementation of SMBIOS might represent the UUID in little-endian format, therefore the "EC2" characters do not appear at the beginning of the UUID.

Example : Get the UUID from the hypervisor
If /sys/hypervisor/uuid exists, you can use the following command:

[ec2-user ~]$ cat /sys/hypervisor/uuid

In the following example output, the UUID starts with "ec2", which indicates that the system is probably an EC2 instance.


Example : Get the UUID from DMI (HVM instances only)
On HVM instances only, you can use the Desktop Management Interface (DMI).
You can use the dmidecode tool to return the UUID. On Amazon Linux, use the following command to install the dmidecode tool if it's not already installed on your instance:

[ec2-user ~]$ sudo yum install dmidecode -y

Then run the following command:

[ec2-user ~]$ sudo dmidecode --string system-uuid

Alternatively, use the following command:

[ec2-user ~]$ sudo cat /sys/devices/virtual/dmi/id/product_uuid

In the following example output, the UUID starts with "EC2", which indicates that the system is probably an EC2 instance.


In the following example output, the UUID is represented in little-endian format.


On Nitro instances, the following command can be used:

[ec2-user ~]$ cat /sys/devices/virtual/dmi/id/board_asset_tag

This returns the instance ID, which is unique to EC2 instances:

You can’t perform that action at this time.