1Net::Amazon::EC2::MetadUastear(3C)ontributed Perl DocumeNnetta:t:iAomnazon::EC2::Metadata(3)
2
3
4
6 Net::Amazon::EC2::Metadata - Retrieves data from EC2 Metadata service.
7 Both script and API; Works only from an EC2 instance.
8
10 This document describes Net::Amazon::EC2::Metadata; version 0.10
11
13 # running on an EC2 instance.
14 use Net::Amazon::EC2::Metadata;
15 no warnings 'uninitialized';
16 my $data = Net::Amazon::EC2::Metadata->all_data;
17 for (sort keys %$data) {
18 print "$_: $data->{$_}\n";
19 }
20
21 ###############
22 use Net::Amazon::EC2::Metadata;
23 my $metadata_service= Net::Amazon::EC2::Metadata->new();
24 warn $metadata_service->ami_id;
25
27 This module queries Amazon's Elastic Compute Cloud Metadata service
28 described at:
29 http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/AESDG-chapter-instancedata.html
30 . It also fetches 'user_data' which follows the same API but is often
31 no considered part of the metadata service by Amazons documentation.
32 The module also ships with a command line tool ec2meta that provides
33 the same data.
34
35 THIS MODULE WILL ONLY WORK ON AN EC2 INSTANCE.
36
38 new()
39 A constructor - for convenience all methods are class methods.
40
41 all_data()
42 Returns a hash ref of all the keys, and their values. Note: this means
43 that public_keys is a listing of the keys not a listing of the values.
44
45 available_data()
46 A listing of all the meta_data and user_data available from this
47 module.
48
49 ami_id
50 ami_manifest_path
51 ami_launch_index
52 ancestor_ami_ids
53 instance_id
54 instance_type
55 kernel_id
56 ramdisk_id
57 placement
58 block_device_mapping
59 local_hostname
60 public_hostname
61 local_ipv4
62 public_ipv4
63 reservation_id
64 security_groups
65 product_codes
66 user_data
67 These methods all return the verbatim data from the calls to the
68 service, and take no parameters.
69
70 public_keys($key)
71 public_key($key)
72 Lists public keys if no key given, returns content of key if a key
73 is given.
74
76 Nathan McFarland "nathan@cpan.org"
77
79 Copyright (c) 2008 Nathan McFarland. This program is free software; you
80 can redistribute it and/or modify it under the same terms as Perl
81 itself.
82
84 Amazon EC2 Documentation: Lhttp://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html>
85 Amazon EC2 Metadata Documentation: L<http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?AESDG-chapter-instancedata.html>
86 Amazon Tutorial on EC2 Metadata: L<http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1085&categoryID=100>
87
88
89
90perl v5.30.1 2020-01-30 Net::Amazon::EC2::Metadata(3)