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. 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 Xen Domain UUID
The methods described in this section determine optimistically whether a Windows virtual machine is an EC2 instance by examining the Xen domain UUID. This approach looks for the presence of the characters "EC" in the beginning octet of the UUID.
There is a small chance that a Xen instance not in EC2 could also include these characters.
You can discover the Xen UUID using the approaches below. For information about identifying Linux instances, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
On a Windows VM, you can use the Windows Management Instrumentation command line (WMIC):Copy
C:\>wmic path win32_computersystemproduct get uuid
This returns the UUID:Copy
In this example, the appended "EC" indicates that you are probably looking at an EC2 instance.
Alternatively, you can use PowerShell:Copy
PS C:\>Get-WmiObject -query "select uuid from Win32_ComputerSystemProduct" | Select UUID
UUID ---- 8D7126EC-E6BC-C83B-5EA2-01234EXAMPLE
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