Skip to content

Instantly share code, notes, and snippets.

@mtimbs
Created March 10, 2020 13:57
Show Gist options
  • Save mtimbs/36697ee55c56c35bd9c0f1d8060415f2 to your computer and use it in GitHub Desktop.
Save mtimbs/36697ee55c56c35bd9c0f1d8060415f2 to your computer and use it in GitHub Desktop.
example base DynamoDB Client that will work for offline testing
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
import DynamoDB from '@dazn/lambda-powertools-dynamodb-client';
/*
* This checks the environment and either outputs a raw DynamoDocumentClient for offline testing
* or it outputs the dazn-powertools DynamoDocumentClient that adds context and tracing
*/
export default ['test'].includes(process.env.NODE_ENV)
? new DocumentClient({
region: process.env.AWS_REGION,
accessKeyId: process.env.AWS_ACCESS_KEY,
secretAccessKey: process.env.AWS_SECRET_KEY,
endpoint: 'http://localhost:8000',
sslEnabled: false,
})
: DynamoDB;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment