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 "EC" in the beginning octet of the UUID.
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 Linux instances, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html
On a Windows system, 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 the system is probably 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