Retrieving Metadata from Servers

Each virtual machine has its own set of information that can be accessed via the HTTP protocol using GET requests. The interface is available at the address: https://169.254.169.254/latest/meta-data from within the virtual machine.

Parameter List

  • public-ipv4 - returns the ipv4 address of the virtual machine.
  • mac - returns the MAC address of the network card of the virtual machine.
  • instance-id - returns the internal identifier of the virtual machine.
  • owner - returns the email address of the owner of the machine account.
  • disk-info - returns information about the disks in the form: identifier, type, size;
  • type - takes a value of 1 for the basic disk in the machine, 0 for additional; size given in bytes.
  • virtual-machines - returns a list of virtual machines for the account.
  • state - returns the state of the virtual machine
  • public_key - displays the public key imported or generated via the API or panel.
  • user-data - displays user_data set by the API


Command Invocation Method

Command

curl https://169.254.169.254/latest/meta-data/public-ipv4

Result

178.216.200.XXX


Alternative Method

Information about the machine can be obtained with the ec2-metadata command:

# ec2-metadata --all
ami-id: ami-000006d8
ami-launch-index: 0
ami-manifest-path: not available
ancestor-ami-ids: not available
block-device-mapping: not available
instance-id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
instance-type: c1.m1024
local-hostname: ip-178-216-200-XXX.e24cloud.com
local-ipv4: 178.216.200.XXX 178.216.201.XXX
kernel-id: not available
placement: eu-poland-1
product-codes: not available
public-hostname: ip-178-216-200-XXX.e24cloud.com
public-ipv4: 178.216.200.XXX 178.216.201.XXX
public-keys: 
ramdisk-id: not available
reservation-id: not available
security-groups: 
user-data: