How to Retrieve Metadata of AWS EC2 Machine

|
| By Webner

Metadata is data about your EC2 instance that is used to manage and configure the instance. Developers use the metadata in the script in order to configure the instances and their resources.

Please login to your EC2 machine and run the following command:

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

Curl command will retrieve the information associated with your EC2 machine, check the below image.
AWS

I have checked few metadata of the AWS EC2 machine, please check below:

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/hostname
OutPut: ip-172-31-2-247.ap-south-1.compute.internal

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/security-groups
OutPut: launch-wizard-1

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/public-hostname
OutPut: ec2-13-233-163-92.ap-south-1.compute.amazonaws.com

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/hostname
OutPut: ip-172-31-2-247.ap-south-1.compute.internal

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/instance-id
OutPut: i-049a37cb6053d0813

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/instance-type
OutPut: t2.micro

[ec2-user@ip-172-31-2-247 ~]$ curl http://169.254.169.254/latest/meta-data/public-hostname
OutPut: ec2-13-233-163-92.ap-south-1.compute.amazonaws.com

Leave a Reply

Your email address will not be published. Required fields are marked *