Identify EC2 Instances in a Mixed Computing Environment
If you are running computer resources on another cloud infrastructure, such as Azure or Google Cloud Platform, or if you use on-premises virtualization from VMware, Xen, or KVM, you may benefit from a simple method to determine whether a virtual machine is an EC2 instance. The methods described in this topic determine optimistically whether a virtual machine is an EC2 instance by examining the Xen domain UUID. The UUID of a non-EC2 virtual machine is less likely to contain "ec2" as its first three characters.
Note
There is a small chance that a Xen instance not in EC2 could also begin with these characters.
You can discover the Xen UUID using the following approaches:
On a Linux VM, run the following command:
$ cat /sys/hypervisor/uuidThis returns a UUID:
ec2e1916-9099-7caf-fd21-012345abcdefIn this example, the prepended "ec2" indicates that you are probably looking at an EC2 instance.
Alternatively, on HVM instances only, the Desktop Management Interface (DMI) contains the same UUID as the System Serial Number and the System UUID (capitalized):
$ sudo dmidecode --string system-serial-number ec2e1916-9099-7caf-fd21-32803a1d3c6b $ sudo dmidecode --string system-uuid EC2E1916-9099-7CAF-FD21-32803A1D3C6BNote
Unlike the previous method, the DMI method requires superuser privileges. However, some older Linux kernels may not expose the UUID via
/sys/.You can also use this method on a Windows VM using the Windows Management Instrumentation command line (WMIC):
C:\>wmic path win32_computersystemproduct get uuidOr, you can use PowerShell:
PS C:\>Get-WmiObject -query "select uuid from Win32_ComputerSystemProduct" | Select UUIDFor a cryptographically verified method, check the instance identity document, including its signature. For more information, see Instance Identity Documents.

