A module to make dynamodb client creation environment agnostic.
- Use the same DynamoDB client code for local development and on AWS Lambda.
- Pass options to DynamoDB or DocumentClient
- Use a custom endpoint for dynamodb-local
- serverless-offline - Required to detect offline/online status
- serverless-dynamodb-local - Required to run dynamodb locally during development
npm install --save sls-dynamodb-client
const ddb = require('sls-dynamodb-client')();
// Get a DocumentClient - AWS.DynamoDB.DocumentClient()
let docClient = ddb.getDocumentClient();
// Get the low level client - AWS.DynamoDB()
let dynamodb = ddb.getClient();
const ddb = require('sls-dynamodb-client')("customregion", "http://customhost:customport/");
// DocumentClient requests will go to "customhost:customport"
let docClient = ddb.getDocumentClient();
// DynamoDB client requests will go to "customhost:customport"
let dynamodb = ddb.getClient();
const ddb = require('sls-dynamodb-client')("customregion", "http://customhost:customport/");
let options = {"convertEmptyValues": true};
let docClient = ddb.getDocumentClient(options);