Saturday, August 9, 2008

SimpleDB in EC2 Ubuntu

I am showing here the How to guide for amazon-simpledb-cli(Command Line Interface)
This tool depends on the following Perl modules from CPAN:
      Getopt::Long
Pod::Usage
Digest::SHA1
Digest::HMAC
XML::Simple

You can install them using the "cpan" command on many Linux distros:
sudo cpan Getopt::Long
sudo cpan Pod::Usage
sudo cpan Digest::SHA1
sudo cpan Digest::HMAC
sudo cpan XML::Simple

This tool also depends on the Amazon::SDB modules provided by Amazon(not the one in CPAN). Amazon's modules can be found here:

http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1136

Here is the How to for the above:
curl -Lo amazon-simpledb-perl-library.zip \
http://amazon-simpledb-perl-library.notlong.com

unzip amazon-simpledb-perl-library.zip

sitelib=$(perl -MConfig -le 'print $Config{sitelib}')
sudo scp -r amazon-simpledb-*-perl-library/src/Amazon $sitelib

Finally, this command line interface can be installed with:

sudo curl -Lo /usr/local/bin/simpledb http://simpledb-cli.notlong.com
sudo chmod +x /usr/local/bin/simpledb

Now to test your installation::
  1. Extract the amazon-simpledb-2007-11-07-perl-library.zip file into a working directory.
  2. 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        = "";
      my $AWS_SECRET_ACCESS_KEY = "";

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

    • And set action with DomainName parameter:
    •  use Amazon::SimpleDB::Model::CreateDomain; 
      my $action = Amazon::SimpleDB::Model::CreateDomain->new;
      invokeCreateDomain($service, $action->withDomainName("MyDomain"));

  3. Run CreateDomain sample:
  4.    perl src/Amazon/SimpleDB/Samples/CreateDomainSample.pl
  5. You should see the output similar to the following:


  6.     CreateDomainResponse
    ResponseMetadata
    RequestId
    95cdcb68-f46c-400b-8265-8c2de2a5c475

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

SEE ALSO
Amazon SimpleDB (SDB)
http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b/?node=342335011

Amazon SimpleDB Developer Guide
http://docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGui
de/




AddThis Feed Button

1 comment:

satpla said...

Saltmarch Media is organizing Great Indian Developer Summit event in Bangalore. This Summit will be a boost for the Software Developing Industries. It covers the topics like .Net, Java, SimpleDB, MongoDB, NoSQL and Richweb and has 1 day workshop at the end as well. Any one attending this event?

Register @ www.developersummit.com