Created
March 10, 2020 13:57
-
-
Save mtimbs/36697ee55c56c35bd9c0f1d8060415f2 to your computer and use it in GitHub Desktop.
example base DynamoDB Client that will work for offline testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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