NAME

Amazon::EC2

SYNOPSIS

use strict;
use warnings;

use Amazon::EC2;
use Amazon::Credentials;
use Data::Dumper;

my $ec2 = new Amazon::EC2({credentials => new Amazon::Credentials});

my $result = $ec2->DescribeInstances();

print Dumper($result);

DESCRIPTION

Perl interface to the Amazon EC2 API

METHODS

See the Amazon EC2 API documentation for method arguments. "http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html"

new

new( options )
region

AWS region. default: us-east-1

credentials

An Amazon::Credentials object. You can specify your credentials using this object or by setting your access keys and optional token directly.

aws_secret_access_key

Your AWS secret access key.

aws_access_key_id

Your AWS access key id.

token

Optional token if your credentials were temporary (from the role or assumed role).

Note that if no credentials are given, the constructor will behave as if you had done:

new Amazon::EC2({credentials => new Amazon::Credentials});

...which will use your default credentials. See Amazon::Credentials.

DescribeInstances

DescribeInstances(options)

options is a hash of optional parameters to pass to the API. See the API description at "http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html"

To create pass the Filter parameters, pass an array of hash references.

my $filter [{Name => 'instance-id', Value => 'i-0b91d8e165cf2f41b'}]);
my $result = $ec2->DescribeInstances(Filter => $filter);
print to_json($result, { pretty  => 1 });

CreateTags

CreateTags( resources ) 

CreateTags( $id => { Key => 'Name', Value => 'foo' } );
CreateTags( $id => [ { Key => 'Name', Value => 'foo' },
                     { Key => 'Environment', Value => 'boo'}
                   ]);

NOTES

This is a work-in-progress. I'll add API methods as I need them and pull requests gladly accepted. ;-)

Why another Perl module for the EC2 API when there are already a couple candidates out there and the PAWS project is tracking the Python boto library?

Well, probably for no good reason other than those others are, generally speaking, fairly heavy with lot's of dependencies. This module is designed to be light and require few additional Perl modules. Hopefully, that means it will be relatively fast compared to using something like the AWS CLI or Paws (which seems to rely on Moose, which seems to rely on, well most of the known CPAN universe).

YMMV, but if you find this useful, good. If not, try PAWS, Net::Amazon::EC2, or VM::EC2.

AUTHOR

Rob Lauer - <rlauer6@comcast.net>

SEE ALSO

Amazon::API, Amazon::Credentials, PAWS, Net::Amazon::EC2, VM::EC2