Skip to main content

Access the metadata and user data of a VM

You can obtain information about the configuration of a VM (Virtual Machine) by accessing its metadata and user data from the VM itself. This action lets you access information that would otherwise be inaccessible from the VM.

Permissions

info

This action requires the following IAM (Identity and Access Management) permissions:

  • compute.vm.get

Access the metadata of a VM

To access the metadata of a VM, type the following command in a terminal of the VM, where CATEGORY is one of the available categories or categories/subcategories:

Example request
curl http://169.254.169.254/latest/meta-data/CATEGORY
CATEGORYDescription
ami-idThe ID of the image used to create the VM.
ami-launch-indexThe creation index of the VM.
block-device-mapping/This category contains the following subcategories:

ami: the device name associated with the system volume of the VM.

ebsN: the device name associated with any other volume attached to the VM, where N is an index starting at 1.
root: identical to ami.
hostnameThe main private DNS name of the VM.
VM-idThe ID of the VM.
VM-typeThe type of the VM.
local-hostnameIdentical to hostname.
local-ipv4The main private IP (Internet Protocol) of the VM.
macThe main Media Access Control (MAC) address of the VM.
network/interfaces/macs/A list of MAC addresses associated with the VM.
network/interfaces/macs/MAC_ADDRESS/This category contains the following subcategories, where MAC_ADDRESS is any MAC address associated with the VM:
device-number: the number of the ethernet device for this network interface.
gateway-ipv4: the private IP for the gateway.
interface-id: the ID of the network interface.
ipv4-associations/PUBLIC_IP: the private IP associated with the public address PUBLIC_IP for this network interface.
local-hostname: the private DNS name for this network interface.
local-ip4s: the private IP for this network interface.
mac: the MAC address for this network interface.
owner-id: the account ID of the owner of the network interface.
public-hostname: the public DNS name, if any, for this network interface.
public-ipv4s: the public IP for this network interface.
security-group-ids: a list of IDs of security groups for this network interface.
security-groups: a list of security group names for this network interface.
subnet-id: the ID of the subnet for this network interface.
subnet-ipv4-cidr-block: in a VPC (Virtual Private Cloud), an IP range for the subnet, in CIDR notation.
vpc-id: in a VPC, the ID of the VPC for this network interface.
placement/This category contains the following subcategories:
availability-zone: the availability zone where the VM is located.
server: the server where the VM is located.
cluster: the cluster where the VM is located.
public-hostnameThe public DNS name of the VM.
public-keys/0/openssh-keyThe public part of the key pair associated with the VM.
reservation-idThe ID of the reservation that the VM is part of.
security-groupsA list of security group names for the VM.
tags/A list of tags associated with the VM.
tags/KEY_NAMEThe tag value corresponding to the KEY_NAME key of the tag.

Access the user data of a VM

To access the user data of a VM, type the following command in a terminal of the VM:

Example request
curl http://169.254.169.254/latest/user-data
Cette page vous a-t-elle été utile ?