Net::Amazon::EC2::Metadata - Retrieves data from EC2 Metadata service. Both script and API; Works only from an EC2 instance.
This document describes Net::Amazon::EC2::Metadata; version 0.10
# 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;
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.
A constructor - for convenience all methods are class methods.
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.
A listing of all the meta_data and user_data available from this module.
These methods all return the verbatim data from the calls to the service, and take no parameters.
Lists public keys if no key given, returns content of key if a key is given.
Nathan McFarland nathan@cpan.org
nathan@cpan.org
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.
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>
To install Net::Amazon::EC2::Metadata, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Amazon::EC2::Metadata
CPAN shell
perl -MCPAN -e shell install Net::Amazon::EC2::Metadata
For more information on module installation, please visit the detailed CPAN module installation guide.