Retrieve the instance identity document for an Amazon EC2 instance
The instance identity document for an Amazon EC2 instance uses a plaintext JSON format. For a description of the contents of an instance identity document, see Instance identity documents for Amazon EC2 instances.
The instance identity document is stored in the instance metadata for the instance, in the instance-identity/document
dynamic data category. You access the instance identity document for an instance by connecting to the instance
and retrieving it from the instance metadata.
You can access instance metadata using the IPv4 address 169.254.169.254 or the IPv6 address fd00:ec2::254. These are Link-local addresses, meaning that you can access them only from the instance. The examples on this page use the IPv4 address of the IMDS: 169.254.169.254. To retrieve instance metadata for EC2 instances over IPv6, use fd00:ec2::254.
To verify the authenticity of an instance identity document after you retrieve it, see Verify instance identity document.
To retrieve the instance identity document
Connect to the instance and run the following command to access the instance identity document from the instance metadata.
The following is example output.
{
"devpayProductCodes" : null,
"marketplaceProductCodes" : [ "1abc2defghijklm3nopqrs4tu" ],
"availabilityZone" : "us-west-2b",
"privateIp" : "10.158.112.84",
"version" : "2017-09-30",
"instanceId" : "i-1234567890abcdef0",
"billingProducts" : null,
"instanceType" : "t2.micro",
"accountId" : "123456789012",
"imageId" : "ami-5fb8c835",
"pendingTime" : "2016-11-19T16:32:11Z",
"architecture" : "x86_64",
"kernelId" : null,
"ramdiskId" : null,
"region" : "us-west-2"
}