Amazon::EC2
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);
Perl interface to the Amazon EC2 API
See the Amazon EC2 API documentation for method arguments. "http://docs.aws.amazon.com/AWSEC2/latest/APIReference/Welcome.html"
new( options )
AWS region. default: us-east-1
An Amazon::Credentials object. You can specify your credentials using this object or by setting your access keys and optional token directly.
Amazon::Credentials
Your AWS secret access key.
Your AWS access key id.
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(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"
options
To create pass the Filter parameters, pass an array of hash references.
Filter
my $filter [{Name => 'instance-id', Value => 'i-0b91d8e165cf2f41b'}]); my $result = $ec2->DescribeInstances(Filter => $filter); print to_json($result, { pretty => 1 });
CreateTags( resources ) CreateTags( $id => { Key => 'Name', Value => 'foo' } ); CreateTags( $id => [ { Key => 'Name', Value => 'foo' }, { Key => 'Environment', Value => 'boo'} ]);
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?
PAWS
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).
Paws
YMMV, but if you find this useful, good. If not, try PAWS, Net::Amazon::EC2, or VM::EC2.
Net::Amazon::EC2
VM::EC2
Rob Lauer - <rlauer6@comcast.net>
Amazon::API, Amazon::Credentials, PAWS, Net::Amazon::EC2, VM::EC2
Amazon::API
To install Amazon::EC2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Amazon::EC2
CPAN shell
perl -MCPAN -e shell install Amazon::EC2
For more information on module installation, please visit the detailed CPAN module installation guide.