How do i retrieve instance metadata on aws ec2?
-
Link: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
The stored information about your ec2 instance can be accessed via the reserved IP URL.
The /latest mean the latest API.
$ curl http://169.254.169.254/latest/meta-data/ ami-id ami-launch-index ami-manifest-path block-device-mapping/ hostname instance-action instance-id instance-type local-hostname local-ipv4 mac metrics/ network/ placement/ profile public-hostname public-ipv4 public-keys/ reservation-id security-groups
An older API has less metadata available to it.
$ curl http://169.254.169.254/2007-01-19/meta-data/ ami-id ami-launch-index ami-manifest-path hostname instance-id local-hostname local-ipv4 public-hostname public-ipv4 public-keys/ reservation-id
If defined when creating the instance user data can also be retrieved.
© Lightnetics 2024