How I can work with Amazon's Dynamodb Local in Node?

danmcc picture danmcc · Nov 8, 2013 · Viewed 19.8k times · Source

Amazon offers a local simulator for their Dynamodb product but the examples are only in PHP.

These examples mention passing the parameter "base_url" to specify that you're using a local Dynamodb, but that returns this error in Node:

{ [UnrecognizedClientException: The security token included in the request is invalid.]
  message: 'The security token included in the request is invalid.',
  code: 'UnrecognizedClientException',
  name: 'UnrecognizedClientException',
  statusCode: 400,
  retryable: false }

How do I get Dynamodb_local working in Node?

Answer

aaaristo picture aaaristo · Nov 9, 2013

You should follow this blog post to setup your DynamoDB Local, an then you can simply use this code:

var AWS= require('aws-sdk'),
dyn= new AWS.DynamoDB({ endpoint: new AWS.Endpoint('http://localhost:8000') });

dyn.listTables(function (err, data)
{
   console.log('listTables',err,data);
});