DOKK / manpages / debian 12 / amazon-ec2-utils / ec2-metadata.8.en
EC2-METADATA(8) System Manager's Manual EC2-METADATA(8)

ec2-metadata - Retrieve instance metadata from within a running EC2 instance

ec2-metadata [options]

The ec2-metadata program is a utility to retrieve EC2 instance metadata from within a running EC2 instance.

Instance metadata is data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories, for example, host name, events, and security groups.

You can also use instance metadata to access user data that you specified when launching your instance. For example, you can specify parameters for configuring your instance, or include a simple script. You can build generic AMIs and use user data to modify the configuration files supplied at launch time. For example, if you run web servers for various small businesses, they can all use the same generic AMI and retrieve their content from the Amazon S3 bucket that you specify in the user data at launch. To add a new customer at any time, create a bucket for the customer, add their content, and launch your AMI with the unique bucket name provided to your code in the user data. If you launch more than one instance at the same time, the user data is available to all instances in that reservation. Each instance that is part of the same reservation has a unique ami-launch-index number, allowing you to write code that controls what to do. For example, the first host might elect itself as an initial master node in a cluster.

ec2-metadata will print all known metadata fields by default. The following options can be used to restrict the output to the selected fields.

The index of this instance in the reservation (per AMI).
The manifest path of the AMI with which the instance was launched.
The AMI IDs of any instances that were rebundled to create this AMI.
Defines native device names to use when exposing virtual devices.
The ID of this instance
The type of instance to launch. For more information, see Instance Types.
The local hostname of the instance.
Public IP address if launched with direct addressing; private IP address if launched with public addressing.
The ID of the kernel launched with this instance, if applicable.
The availability zone in which the instance launched. Same as placement
Product codes associated with this instance.
The public hostname of the instance.
NATted public IP Address
Public keys. Only available if supplied at instance launch time
The ID of the RAM disk launched with this instance, if applicable.
ID of the reservation.
Names of the security groups the instance is launched in. Only available if supplied at instance launch time
User-supplied data.Only available if supplied at instance launch time.
Show summary of options.

1.
Instance metadata and user data
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
2.
EC2 Instance Metadata Query Tool
https://aws.amazon.com/code/ec2-instance-metadata-query-tool/

May 4 2020