Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

Identify EC2 Instances

You may benefit from a simple method to determine whether a system is an EC2 instance to determine if other resources like the Instance Metadata Service should be used to configure or verify the EC2 identity of the system. This topic describes two approaches to identifying an EC2 instance, one of them quick but potentially inaccurate, and the other more involved but also definitive.

Inspecting the System UUID

The methods described in this section determine optimistically whether a system is an EC2 instance by examining the system UUID. This approach looks for the presence of the characters "ec2" or "EC2" in the beginning octet of the UUID.

Note

There is a small chance that a system that is not an EC2 instance could also include these characters.

You can discover the system UUID using the approaches below. To handle all types of EC2 instances, both approaches must be used. For information about identifying Windows instances, see http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/identify_ec2_instances.html.

  • On a Linux system, run the following command:

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

    This returns a UUID:

    Copy
    ec2e1916-9099-7caf-fd21-012345abcdef

    In this example, the prepended "ec2" indicates that the system is probably an EC2 instance. If /sys/hypervisor/uuid does not exist, continue to the second approach of obtaining the system UUID from the Desktop Management Interface (DMI) table.

  • Additionally, on HVM instances only, the Desktop Management Interface (DMI) contains the system UUID. One of the following commands should return it:

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

    or

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

    returns

    Copy
    EC2E1916-9099-7CAF-FD21-01234ABCDEF

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 http://169.254.169.254/latest/dynamic/instance-identity/. For more information, see Instance Identity Documents.