Net::A...tadata(3pm)

πŸ“¦
version 0.10 Β· 2 versions
, in fedora 43

✨ NAME ✨

Net::Amazon::EC2::Metadata β€” it grabs data from the EC2 Metadata service πŸ’… and it's both a script and an API. Oh, and heads up bestie: it only works from an EC2 instance. No instance, no vibes. 🫢


🌸 VERSION 🌸

This doc describes Net::Amazon::EC2::Metadata; version 0.10 ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#  running on an EC2 instance.
use Net::Amazon::EC2::Metadata;
no warnings 'uninitialized';
my $data = Net::Amazon::EC2::Metadata->all_data;
for (sort keys %$data)      {
    print "$_: $data->{$_}\n";
}
###############
use Net::Amazon::EC2::Metadata;
my $metadata_service= Net::Amazon::EC2::Metadata->new();
warn $metadata_service->ami_id;

πŸ’– DESCRIPTION πŸ’–

okay so this module queries Amazon's Elastic Compute Cloud Metadata service, which is described over here:

http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html

It also fetches 'user_data' β€” which follows the same API, but Amazon's docs often don't count it as part of the metadata service. Rude, but okay. πŸ™ˆ

The module also ships with a command line tool, ec2meta, that hands you the exact same data. Iconic.

🚨 THIS MODULE WILL ONLY WORK ON AN EC2 INSTANCE. Like, literally. Not a suggestion, it's the whole vibe check. 🚨

πŸ‘‘ METHODS πŸ‘‘

πŸ’« new()

A constructor β€” but for convenience, all the methods are class methods. Slay, no object bookkeeping required. ✨

πŸ’« all_data()

Returns a hash ref of all the keys and their values. ⚠️ Note: this means public_keys is a listing of the keys, not a listing of the values. iykyk.

πŸ’« available_data()

A listing of all the meta_data and user_data available from this module. Here's the whole roster, no gatekeeping πŸŽ€:

  • ami_id
  • ami_manifest_path
  • ami_launch_index
  • ancestor_ami_ids
  • instance_id
  • instance_type
  • kernel_id
  • ramdisk_id
  • placement
  • block_device_mapping
  • local_hostname
  • public_hostname
  • local_ipv4
  • public_ipv4
  • reservation_id
  • security_groups
  • product_codes
  • user_data

These methods all return the verbatim data from the calls to the service, and take no parameters. fr fr, no args, just data.

πŸ’« public_keys($key)

πŸ’« public_key($key)

Lists public keys if no key given, returns content of key if a key is given. πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

Nathan McFarland "nathan@cpan.org" β€” the icon who wrote this πŸ’–


Copyright (c) 2008 Nathan McFarland. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🌈


⭐ SEE ALSO ⭐


and that's the whole page, bestie!! πŸ¦‹ this gem of a doc was brought to you by perl v5.42.0 on 2025-07-25 πŸ’… go forth and read your metadata, you absolute main character πŸ‘‘βœ¨

πŸ“¦ where this page comes from