|
Resources
Sample Code and Libraries
Perl Library for Amazon SimpleDB
 |
Perl Library for Amazon SimpleDB
| Submitted By: |
Elena@AWS
|
| AWS Products Used: |
Amazon SimpleDB |
| Language(s): |
Perl |
| License: |
Apache License 2.0 |
|
|
 |
About this Library
- Based on the 2009-04-15 API version.
What's New?
- 2009-05-07: Deprecate Query and QueryWithAttributes. Please migrate to Select API
- 2009-03-23: Support for BatchPutAttributes
- 2008-12-26: Url and utf8 encoding fix for signature version 2
- 2008-12-17: Support for signature version 2, DomainMetadata and Select API, https endpoint
- 2008-08-28: Support for new API - QueryWithAttributes
Prerequisites
- Amazon SimpleDB account (http://aws.amazon.com/simpledb).
- Perl 5.6.0 or newer (http://www.perl.org/)
- 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 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:
- Extract the amazon-simpledb-2009-04-15-perl-library.zip file into a working directory.
- Edit desired sample. For example: src/Amazon/SimpleDB/Samples/CreateDomainSample.pl
- 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::SimpleDB::Model::CreateDomainRequest;
# @TODO: set request. request can be passed as Amazon::SimpleDB::Model::CreateDomainRequest
# object or hash of parameters
# invokeCreateDomain($service, $request);
- And set request with DomainName parameter:
use Amazon::SimpleDB::Model::CreateDomainRequest;
my $request = Amazon::SimpleDB::Model::CreateDomainRequest->new;
invokeCreateDomain($service, $request->withDomainName("MyDomain"));
- Run CreateDomain sample:
perl src/Amazon/SimpleDB/Samples/CreateDomainSample.pl
- You should see the output
similar to the following:
CreateDomainResponse
ResponseMetadata
RequestId
95cdcb68-f46c-400b-8265-8c2de2a5c475
- Experiment with samples. When ready, install library in the perl include path and use it.
Notes
You can use alternative hash-based interface with the library. For example, instead of:
my $request = Amazon::SimpleDB::Model::CreateDomainRequest->new;
$request->setDomainName("MyDomain");
my $response = $service->createDomain($request);
You can write:
my $response = $service->createDomain({DomainName => "MyDomain"});
Happy coding!
Making Requests to a Different Region
To make the service call to a different region, instantiate the client with the configuration object, and pass the region-specific endpoint. For example:
my $service = Amazon::SimpleDB::Client->new
($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY,
{"ServiceURL" => "https://sdb.eu-west-1.amazonaws.com"});
See the Amazon SimpleDB Developer Guide for a complete list of region endpoints.
Previous Version Download
Comments, Questions or Feedback
If you have any comments, questions or feedback on the library, please start discussion here.
|
Posts:
1
Registered:
7/3/09
|
|
|
|
Library not working
Posted:
Jul 3, 2009 7:18 AM PDT
in response to: Elena@AWS
|
|
|
I've tried out this package several times and every time I issue a command (including the CreateDomainSample example outlined in the documentation I get an error 501 returned by AWS. Here's the output of the CreateDomainSample script:
Caught Exception: Internal Error
Response Status Code: 501
Error Code:
Error Type:
Request ID:
XML:
When I use all teh same parameters in the SimpleDB Javascript scratchpad it works without any problems. Any advice?
|
|
Posts:
1
Registered:
7/14/09
|
|
|
|
Re: Library not working
Posted:
Jul 14, 2009 12:47 PM PDT
in response to: synclouds
|
|
|
I'm getting this exact same error when I try the Perl examples for CreateQueueSample.pl and and ListQueuesSample.pl for the Amazon Queue Services. It seems that the "eval" statement fails, as nothing runs in that block, and instead the exception happens.
I've also tried the Scratchpad app and it works fine with my keys.
I've double-checked my keys, etc. and have no idea what I'm doing wrong.
I'm going to try the PHP example next...
|
|
Posts:
5
Registered:
3/19/09
|
|
|
|
Re: Library not working
Posted:
Sep 24, 2009 2:29 PM PDT
in response to: altostratuscloud
|
|
|
Me too:
my $request = Amazon::SimpleDB::Model::SelectRequest->new({SelectExpression => "Select * From ec2metadata"});
invokeSelect($service, $request);
Caught Exception: Internal Error
Response Status Code: 501
Error Code:
Error Type:
Request ID:
XML:
|
|
Posts:
5
Registered:
3/19/09
|
|
|
|
Re: Library not working
Posted:
Sep 29, 2009 11:38 AM PDT
in response to: J. Wilton
|
|
|
I solved this. The host lacked openssl and openssl-devel packages. Make sure you completely install all required packages, perl modules and dependencies as stated in the documentation, including all dependencies. Use cpan for the perl modules and yum for the rpms.
|
|
Posts:
1
Registered:
12/8/08
|
|
|
|
Re: Digest::HMAC_SHA1 is required
Posted:
Oct 19, 2009 12:22 AM PDT
in response to: Elena@AWS
|
|
|
could you publish this on CPAN, please?
|
|
|
|
 |
|
|