• < home >
  • < about >
  • < blog >

Install DynamoDB Local on EC2 Instance

admin · July 28, 2015 · AWS, Blog · 0 comments
0

Go to a directory below the root of your website (usually /var/www/). Get the latest version of DyanmoDB local from Amazon using the command below.

wget http://dynamodb-local.s3-website-us-west-2.amazonaws.com/dynamodb_local_latest.tar.gz

Unzip the file after you get it.
tar -zxvf dynamodb_local_latest.tar.gz

Remove the tar.gz file after unzipping it.
rm -f dynamodb_local_latest.tar.gz

You then need to run this command to start DynamoDB local.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

To run this on boot of the server, you can setup or add to the boot script of the server. The boot script file on CentOS is:
/etc/rc.d/rc.local

You would just add the below to the file. Adding the ‘&’ at the end will make it non-blocking so if you have processes that need to run after it.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb &

Once you have it setup and running you can use the javascript shell that comes with it to add tables or input, edit and delete items.
http://yourdomain.com:8000/shell

I used PHP and interacted with the setup. This got a little tricky and I found the documentation provided by Amazon is incorrect with the configuration. Instead of ‘endpoint’ you need to use ‘base_url’ and you also need your key and secret even though they will not be used.

$client = DynamoDbClient::factory(array(
‘profile’ => ‘default’,
‘region’ => ‘us-west-2’, #replace with your desired region
‘endpoint’ => ‘http://localhost:8000’,
‘base_url’ => ‘http://localhost:8000’,
‘key’ => ‘YOURKEY’,
‘secret’ => ‘YOURSECRET’
));

Once you have your configuration setup like the above for PHP you can start using the <a href=”http://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-dynamodb.html” target=”_blank”>PHP SDK</a> for Amazon like you would normally access the Hosted DyanmoDB.

Helpful links for Local Config
http://stackoverflow.com/questions/26022387/dynamodb-local-basic-php-setup
http://databasefaq.com/index.php/answer/64208/php-amazon-web-services-amazon-s3-s3client-php-sdk-object-of-class-class-could-not-be-converted-to-string

PHP DynamoDB
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LowLevelPHPItemCRUD.html

  Facebook   Pinterest   Twitter   Google+
  • Protected: phpMyAdmin Config
    March 18, 2016 · 0 comments
    <form class="protected-post-form"
    1
    0
    Read more
  • Postman Packaged App – View Browser Console
    March 25, 2015 · 2 comments
    Being able to view the developer console in the <a title="Postman Packaged App"
    564705
    0
    Read more
  • AWS Re:Invent Gameday 2015
    October 17, 2015 · 0 comments
    <strong>Objective of the Game</strong> The objective of the game was to host
    727089
    1
    Read more

Leave a Comment! Cancel reply

Your email address will not be published. Required fields are marked *

Categories
  • AWS
  • Blog
  • Development Tools
  • Uncategorized
Archives
  • March 2016
  • October 2015
  • July 2015
  • May 2015
  • March 2015
Copyright © 2008 jeremygerk. All Rights Reserved.