Perl Library for Amazon EC2

items>Perl Library for Amazon EC2
Community Contributed Software

  • Amazon Web Services provides links to these packages as a convenience for our customers, but software not authored by an "@AWS" account has not been reviewed or screened by AWS.
  • Please review this software to ensure it meets your needs before using it.

Perl Library for Amazon EC2


Submitted By: Jason@AWS
AWS Products Used: Amazon EC2
Language(s): Perl
License: Apache License 2.0
Created On: August 21, 2008 4:38 AM GMT
Last Updated: July 21, 2010 8:48 PM GMT

What's New?

  • 2010-07-21:
    • Support for Amazon EC2 API Version 2010-06-15.
  • 2009-12-13:
    • Support for Amazon EC2 API Version 2009-11-30.
  • 2009-12-02:
    • Support for Amazon EC2 API Version 2009-10-31.
  • 2009-09-29:
    • Fix typo and response transformation on VpcAttachment
  • 2009-09-28:
  • 2009-09-23:
    • Support for Shared Snapshots API
  • 2009-09-10:
    • Fix for missing VPC fields on RunningInstance
  • 2009-08-25:
    • Support for VPC API
  • 2009-05-17:
    • Support for monitoring API
  • 2009-04-09:
    • Support for reserved instances API
  • 2008-12-26:
    • Url and utf8 encoding fix for signature version 2
  • 2008-12-17:
    • Support for regions, signature version 2, https endpoint
  • 2008-10-21:
    • Support for Windows Bundling, new API version - 2008-08-08
  • 2008-08-20:
    • Initial release, support for Amazon Elastic Block Store


  • Amazon EC2 account (
  • Perl 5.6.0 or newer (
  • Depending on the version of PERL you are using, you may need to install additional packages. To install additional packages, run following command:
    • perl -MCPAN -e 'install Digest::SHA'
    • perl -MCPAN -e 'install XML::Simple'
    • perl -MCPAN -e 'install Bundle::LWP'
    • perl -MCPAN -e 'install XML::LibXSLT'
    • perl -MCPAN -e 'install Crypt::SSLeay'

Package Content

Directory Overview
src Source distribution of library.

Quick Start

Library comes with code samples for each available service API. To get started with the library, follow these steps:
  1. Extract the download file into a working directory.
  2. Edit desired sample. For example: src/Amazon/EC2/Samples/

    • Set AWS Access Key ID and AWS Secret Access Key
    •  my $AWS_ACCESS_KEY_ID        = "<Your Access Key ID>";
       my $AWS_SECRET_ACCESS_KEY    = "<Your Secret Access Key>";

    • Set request parameters. For example, find following pre-generated snippet:
    •  use Amazon::EC2::Model::DescribeImagesRequest;
       # @TODO: set action. Action can be passed as Amazon::EC2::Model::DescribeImagesRequest
       # object or hash of parameters
       # invokeDescribeImages($service, $request);

    • And set action with ImageId parameter:
    •  use Amazon::EC2::Model::DescribeImages;
       my $request = Amazon::EC2::Model::DescribeImagesRequest->new;
       invokeDescribeImages($service, $request->withImageId("ami-be3adfd7"));

  3. Run DescribeImages sample:
  4.    perl src/Amazon/EC2/Samples/
  5. You should see the output similar to the following:

  6.     DescribeImagesResponse

  7. Experiment with samples. When ready, install library in the perl include path and use it.

Making Requests to a Different Region

To make a service call to a different region, instantiate the client with a configuration object, and pass the region-specific endpoint. For example:

    my $ec2Config =  {ServiceURL => ""};
    my $ec2 = Amazon::EC2::Client->new($accessKeyId, $secretAccessKey, $ec2Config);

Please see the Amazon EC2 Developer Guide for a complete list of region endpoints.


You can use alternative hash-based interface with the library. For example, instead of:

    my $request = Amazon::EC2::Model::DescribeImagesRequest->new;
    my $response = $service->describeImages($request);
You can write:
    my $response = $service->describeImages({ImageId => "ami-be3adfd7"});

Happy coding!

Comments, Questions or Feedback

If you have any comments, questions or feedback on the library, please start discussion here.
©2017, Amazon Web Services, Inc. or its affiliates. All rights reserved.