Reference: AWS User Guide - Instance data retrieval
Contents:
- Versions
- Options
- Amazon machine image (AMI) ID
- Amazon machine image (AMI) launch index value
- Amazon manifest path
- Block device mapping
- Events
- Hostname
- IAM
- Instance action
- Instance ID
- Instance life cycle
- Instance type
- Local hostname
- Local IP4
- MAC address
- Metrics
- Network
- Placement
- Profile
- Public hostname
- Public IP4
- Public keys
- Reservation ID
- Security groups
- Services
According to the AWS documentation, "the earlier versions are available to you in case you have scripts that rely on the structure and information present in a previous version."
curl http://169.254.169.254/
1.0
2007-01-19
2007-03-01
2007-08-29
2007-10-10
2007-12-15
2008-02-01
2008-09-01
2009-04-04
2011-01-01
2011-05-01
2012-01-12
2014-02-25
2014-11-05
2015-10-20
2016-04-19
2016-06-30
2016-09-02
2018-03-28
2018-08-17
2018-09-24
2019-10-01
2020-10-27
2021-01-03
The way that this would be used.
For the latest:
curl http://169.254.169.254/latest/meta-data/
For a specific version (e.g. 2021-01-03):
curl http://169.254.169.254/2021-01-03/meta-data/
Using latest version:
curl http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
events/
hostname
iam/
identity-credentials/
instance-action
instance-id
instance-life-cycle
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
curl http://169.254.169.254/latest/meta-data/ami-id
ami-07f990e4e7551b774
When running up new instances (aws ec2 run-instances) and running up multiple instances of the same AMI (using the count option).
Each instance will be launched with a unique index started from a zero-index (0) and incrementing by 1 for each additional instance.
Reference: AWS User Guide - Amazon Launch Index
curl http://169.254.169.254/latest/meta-data/ami-launch-index
0
curl http://169.254.169.254/latest/meta-data/ami-manifest-path
(unknown)
curl http://169.254.169.254/latest/meta-data/block-device-mapping/
ami
One level deeper:
curl http://169.254.169.254/latest/meta-data/block-device-mapping/ami
xvda(python3)
curl http://169.254.169.254/latest/meta-data/events/
maintenance/(python3)
One level deeper:
curl http://169.254.169.254/latest/meta-data/events/maintenance
history
One level deeper:
curl http://169.254.169.254/latest/meta-data/events/maintenance/history
[](python3)
curl http://169.254.169.254/latest/meta-data/hostname
ip-123-45-67-89.us-east-1.compute.internal(python3)
curl http://169.254.169.254/latest/meta-data/iam
security-credentials/(python3)
One level deeper:
curl http://169.254.169.254/latest/meta-data/iam/security-credentials
example_iam_role(python3)
curl http://169.254.169.254/latest/meta-data/instance-action
none(python3)
curl http://169.254.169.254/latest/meta-data/instance-id
i-1234d5bf6f789b123(python3)
curl http://169.254.169.254/latest/meta-data/instance-life-cycle
on-demand(python3)
curl http://169.254.169.254/latest/meta-data/instance-type
t3.micro(python3)
curl http://169.254.169.254/latest/meta-data/local-hostname
ip-172-12-34-56.us-east-1.compute.internal(python3)
curl http://169.254.169.254/latest/meta-data/local-ipv4
172.12.34.56(python3)
curl http://169.254.169.254/latest/meta-data/mac
12:3a:c4:a5:c6:d7(python3)
curl http://169.254.169.254/latest/meta-data/metrics/
vhostmd(python3)
One level deeper:
curl http://169.254.169.254/latest/meta-data/metrics/vhostmd
<?xml version="1.0" encoding="UTF-8"?>(python3)
curl http://169.254.169.254/latest/meta-data/network/
interfaces/(python3)
One level deeper:
curl http://169.254.169.254/latest/meta-data/network/interfaces
macs/(python3)
One level deeper:
curl http://169.254.169.254/latest/meta-data/network/interfaces/macs
12:3a:c4:a5:c6:d7(python3)
curl http://169.254.169.254/latest/meta-data/placement/
availability-zone
region(python3)
One level deeper (availability-zone):
curl http://169.254.169.254/latest/meta-data/placement/availability-zone
us-east-1a(python3)
One level deeper (region):
curl http://169.254.169.254/latest/meta-data/placement/region
us-east-1(python3)
curl http://169.254.169.254/latest/meta-data/profile
default-hvm(python3)
curl http://169.254.169.254/latest/meta-data/public-hostname
ec2-123-234-123-234.us-east-1.compute.amazonaws.com(python3)
curl http://169.254.169.254/latest/meta-data/public-ipv4
123.234.123.234(python3)
curl http://169.254.169.254/latest/meta-data/public-keys/
0=example_public_key(python3)
curl http://169.254.169.254/latest/meta-data/reservation-id/
r-1d23bb4567f89e1c2(python3)
curl http://169.254.169.254/latest/meta-data/security-groups
example_security_group
curl http://169.254.169.254/latest/meta-data/services/
domain
partition(python3)
One level deeper (domain):
curl http://169.254.169.254/latest/meta-data/services/domain
amazonaws.com(python3)
One level deeper (partition):
curl http://169.254.169.254/latest/meta-data/services/partition
aws(python3)