How to Get Meta-Data Information From an AWS EC2 Instance


If you need to query meta-data information from your running EC2 instance, you can curl the following location:

curl http://169.254.169.254/latest/meta-data

This will provide a list of all information that can be retrieved.

Say you want to get the local IPv4 address, this can be done as follows:

curl http://169.254.169.254/latest/meta-data/local-ipv4

You can also get JSON blocks of information back, such as querying the IAM Info:

curl http://169.254.169.254/latest/meta-data/iam/info