NAME
Net::Amazon::EC2::Metadata - Retrieves data from EC2 Metadata service. Both script and API; Works only from an EC2 instance.
VERSION
This document describes Net::Amazon::EC2::Metadata; version 0.10
SYNOPSIS
# running on an EC2 instance.
use Perl6::Say;
use Net::Amazon::EC2::Metadata;
no warnings 'uninitialized';
my $data = Net::Amazon::EC2::Metadata->all_data;
for (sort keys %$data) {
say "$_: $data->{$_}";
}
###############
use Net::Amazon::EC2::Metadata;
my $metadata_service= Net::Amazon::EC2::Metadata->new();
warn $metadata_service->ami_id;
DESCRIPTION
This module queries Amazon's Elastic Compute Cloud Metadata service described at: http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html . It also fetches 'user_data' which follows the same API but is often no considered part of the metadata service by Amazons documentation. The module also ships with a command line tool ec2meta that provides the same data.
THIS MODULE WILL ONLY WORK ON AN EC2 INSTANCE.
METHODS
new()
A constructor - for convenience all methods are class methods.
all_data()
Returns a hash ref of all the keys, and their values. Note: this means that public_keys is a listing of the keys not a listing of the values.
available_data()
A listing of all the meta_data and user_data available from this module.
- ami_id
- ami_manifest_path
- ami_launch_index
- ancestor_ami_ids
- instance_id
- instance_type
- 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.
- 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
COPYRIGHT
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
Amazon EC2 Documentation: L<http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/>
Amazon EC2 Metadata Documentation: L<http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html>
Amazon Tutorial on EC2 Metadata: L<http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1085&categoryID=100>