Examples:
- Obtaining the Instance ID:
$ wget -q -O - http://169.254.169.254/latest/meta-data/instance-id i-87eef4e2 |
- Public Hostname:
$ wget -q -O - http://169.254.169.254/latest/meta-data/public-hostname ec2-50-17-85-234.compute-1.amazonaws.com |
- Public IPv4 Address:
$ wget -q -O - http://169.254.169.254/latest/meta-data/public-ipv4 50.17.85.234 |
Check the Instance Metadata manual page for further reference.
Unfortunately, the Instance Tags are not available through Metadata yet (forums). There is a workaround using the API ec2-describe-instances command.
Example: To obtain a whole Tag list from the instance we are running in:
$ ec2-describe-instances `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id` --show-empty-fields | grep TAG TAG instance i-87eef4e2 Another Tag Another Value TAG instance i-87eef4e2 Name mymachine1 |
No comments:
Post a Comment