Sunday, May 25, 2014

Using ec2metadata webservice to get more information about your running EC2 instance

It is recommended to install ec2metadata script in each of your instance that you launch so that you can get information about the instance if needed using SSH commands. You can get more information in AWS documentation link - ec2metadata

The bash script will give output like below:
**************
$ ./ec2-metadata
ami-id: ami-xxxx
ami-launch-index: 0
ami-manifest-path: (unknown)
ancestor-ami-ids: not available
block-device-mapping:
         ami: /dev/sda1
         root: /dev/sda1
instance-id: i-xxxx
instance-type: m3.large
local-hostname: ip-10-187-x-x.ec2.internal
local-ipv4: 10.187.x.x
kernel-id: aki-1ecebd
placement: us-east-1a
product-codes: not available
public-hostname: ec2-54-234-x-x.compute-1.amazonaws.com
public-ipv4: 54.234.x.x
public-keys:
keyname:test
index:0
format:openssh-key
key:(begins from next line)
ssh-rsa AAAA...VzIzBEfObTbXF4IUdnqe/ test
ramdisk-id: not available
reservation-id: r-ba6cabc
security-groups: test
user-data: not available
**************

You can download the script from Amazon url - ec2metadata download

The above script makes a call from within the instance to an Amazon web service at the below url:-

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

No comments:

Post a Comment