EC2-METADATA(8)

πŸ“¦
version 2.2.0 Β· 3 versions
, in epel 9, fedora 43, fedora 44, nixpkgs unstable

✨ EC2-METADATA(8) ✨

okay so bestie, welcome to the System Manager's Manual page for ec2-metadata β€” yes that's the section 8 one, the big-girl sysadmin section, and honestly? iconic. πŸ’…


🌸 NAME 🌸

ec2-metadata β€” retrieve instance metadata from inside a running EC2 instance. no cap, it just reaches out and grabs the tea about the box you're literally sitting on. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

ec2-metadata [options]

✨ DESCRIPTION ✨

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

So what even is instance metadata? It's data about your instance that you can use to configure or manage the running instance, and it's split up into categories β€” think host name, events, security groups, all that. 🌈

You can also use instance metadata to access user data that you specified when launching your instance. Like, you can specify parameters for configuring your instance, or just yeet a whole simple script in there. The whole point? You can build generic AMIs and then use user data to modify the configuration files supplied at launch time. πŸŽ€

for example β€” say you run web servers for various small businesses. They can all use the same generic AMI and just retrieve their content from the Amazon S3 bucket that you specify in the user data at launch. Adding a new customer at any time is literally just: 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. slay. 🧚

And here's the part everyone forgets: 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's part of the same reservation has a unique ami-launch-index number, which lets you write code that controls what to do. For example, the first host might elect itself as an initial master node in a cluster. main character energy, honestly πŸ‘‘


πŸ’… OPTIONS πŸ’…

so here's the vibe β€” ec2-metadata will print all known metadata fields by default. The following options can be used to restrict the output to the selected fields. πŸ’–

  • --all β€” Show all metadata information for this host (also default). yes bestie, it's the default and an option, it contains multitudes ✨
  • -a, --ami-id β€” The AMI ID used to launch this instance πŸŽ€
  • -l, --ami-launch-index β€” The index of this instance in the reservation (per AMI). πŸ¦‹
  • -m, --ami-manifest-path β€” The manifest path of the AMI with which the instance was launched. 🌸
  • -n, --ancestor-ami-ids β€” The AMI IDs of any instances that were rebundled to create this AMI. it's giving lineage πŸ’€
  • -b, --block-device-mapping β€” Defines native device names to use when exposing virtual devices. πŸ’œ
  • -i, --instance-id β€” The ID of this instance 🫢
  • -t, --instance-type β€” The type of instance to launch. For more information, see Instance Types. πŸ‘‘
  • -h, --local-hostname β€” The local hostname of the instance. 🏠
  • -o, --local-ipv4 β€” Public IP address if launched with direct addressing; private IP address if launched with public addressing. πŸ™ˆ
  • -k, --kernel-id β€” The ID of the kernel launched with this instance, if applicable. ⭐
  • -z, --availability-zone β€” The availability zone in which the instance launched. Same as placement. 🌈
  • -R, --region β€” The region in which the instance launched. πŸ—ΊοΈ
  • -c, --product-codes β€” Product codes associated with this instance. πŸ“
  • -p, --public-hostname β€” The public hostname of the instance. 🌟
  • -v, --public-ipv4 β€” NATted public IP Address πŸ’…
  • -u, --public-keys β€” Public keys. Only available if supplied at instance launch time. πŸ”‘
  • -r, --ramdisk-id β€” The ID of the RAM disk launched with this instance, if applicable. 🧁
  • -e, --reservation-id β€” ID of the reservation. 🎟️
  • -s, --security-groups β€” Names of the security groups the instance is launched in. Only available if supplied at instance launch time. πŸ›‘οΈ
  • -d, --user-data β€” User-supplied data. Only available if supplied at instance launch time. πŸ“
  • -t, --tags β€” Print EC2 resource tags if permitted in EC2 Instance Metadata Options. 🏷️
  • --quiet β€” Don't print metadata keys. 🀫
  • -h, --help β€” Show summary of options. πŸ†˜
ngl bestie, you may have clocked that -t and -h each show up twice in that list. that's exactly how the page reads β€” not a typo on my end, and definitely not me being messy. i'm just the messenger. πŸ’€βœ¨

πŸ”₯ SEE ALSO πŸ”₯

  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/ πŸ› οΈ
  3. Work with instance tags in instance metadata β€” https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#work-with-tags-in-IMDS 🏷️

and that's the whole page, periodt. this one landed in the world on May 4 2020 β€” the System Manager's Manual edition, EC2-METADATA(8) and all. go forth and fetch your metadata, bestie. you got this πŸ«Άβœ¨πŸ’–

πŸ“¦ where this page comes from