dynamodb
dynamodb copied to clipboard
DynamoDB Local
Does this use Dynamodb local? If so, how can I configure it to use it because, currently I'm getting a bunch of issues using this plugin:
{ ConfigError: Missing region in config
at Request.VALIDATE_REGION (/home/vagrant/api/node_modules/aws-sdk/lib/event_listeners.js:92:45)
at Request.callListeners (/home/vagrant/api/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at callNextListener (/home/vagrant/api/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
at /home/vagrant/api/node_modules/aws-sdk/lib/event_listeners.js:86:9
at finish (/home/vagrant/api/node_modules/aws-sdk/lib/config.js:341:7)
at /home/vagrant/api/node_modules/aws-sdk/lib/config.js:359:9
at EnvironmentCredentials.get (/home/vagrant/api/node_modules/aws-sdk/lib/credentials.js:126:7)
at getAsyncCredentials (/home/vagrant/api/node_modules/aws-sdk/lib/config.js:353:24)
at Config.getCredentials (/home/vagrant/api/node_modules/aws-sdk/lib/config.js:373:9)
at Request.VALIDATE_CREDENTIALS (/home/vagrant/api/node_modules/aws-sdk/lib/event_listeners.js:81:26)
at Request.callListeners (/home/vagrant/api/node_modules/aws-sdk/lib/sequential_executor.js:102:18)
at Request.emit (/home/vagrant/api/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/home/vagrant/api/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/home/vagrant/api/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/home/vagrant/api/node_modules/aws-sdk/lib/state_machine.js:14:12)
at Request.runTo (/home/vagrant/api/node_modules/aws-sdk/lib/request.js:403:15)
at Request.send (/home/vagrant/api/node_modules/aws-sdk/lib/request.js:367:10)
at DocumentClient.put (/home/vagrant/api/node_modules/aws-sdk/lib/dynamodb/document_client.js:309:15)
at module.exports.Table.sendRequest (/home/vagrant/api/node_modules/dynamodb/lib/table.js:64:18)
at /home/vagrant/api/node_modules/dynamodb/lib/table.js:191:10
at /home/vagrant/api/node_modules/dynamodb/node_modules/async/lib/async.js:52:16
at Immediate.<anonymous> (/home/vagrant/api/node_modules/dynamodb/node_modules/async/lib/async.js:1206:34)
at runCallback (timers.js:794:20)
at tryOnImmediate (timers.js:752:5)
at processImmediate [as _immediateCallback] (timers.js:729:5)
message: 'Missing region in config',
code: 'ConfigError',
time: 2018-12-01T05:24:30.994Z }
This is a common dynamodb-local
misunderstanding - even though it's not live AWS, you still need to pass a region key, the value just gets ignored:
When configured directly with dynamodb-local
:
console.log("[*] Pointing at DynamoDB Local");
dynamoDbClient = new AWS.DynamoDB.DocumentClient({
region: 'localhost',
endpoint: 'http://localhost:8000'
});
This works great for running tests:
const dynamo = require('dynamodb');
const { DocumentClient } = require('aws-sdk/clients/dynamodb');
const isTest = process.env.JEST_WORKER_ID;
var docClient = new DocumentClient({
convertEmptyValues: true,
...(isTest && {
endpoint: 'localhost:8000',
sslEnabled: false,
region: 'local-env'
}),
})
dynamo.documentClient(docClient)