serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
Using dynamodb on local network with serverless offline
I have dynamodb local running on a network server with IP 192.168.0.200.
My serverless.yml file is setup as follows:
plugins:
- serverless-dynamodb-local
- serverless-offline
custom:
dynamodb:
start:
host: 192.168.0.200
noStart: true
migrate: true
When running serverless offline start I can see that the output says that the migration worked and the table was created and on a rerun it says that the table already exists.
But when I actually check the dynamodb database on the server i see no tables. Also using serverless-dynamodb-client to query the db i get "Cannot do operations on a non-existent table"
It seems to me that the migration does not actually run on the 192.168.0.200 server but locally.
I had the same issue and the fix suggested in response to #183 worked for me.
Although I used "MOCK_ACCESS_KEY_ID" and "MOCK_SECRET_ACCESS_KEY" to match the strings in the current code.
Here's the fixed connection code (referencing a docker-compose service for dynamo):
dynamoDb = new AWS.DynamoDB.DocumentClient({
region: "localhost",
accessKeyId: "MOCK_ACCESS_KEY_ID",
secretAccessKey: "MOCK_SECRET_ACCESS_KEY",
endpoint: "http://dynamo:8000"
});
@kjersten amazing!
Old ticket but I want to confirm that @kjersten is absolutely correct. We had the experience of some developers using serverless-dynamodb-local without a hitch, but I couldn't connect locally and was receiving connection errors when sls offline tried to reach an actual AWS instance. By adding mock keys, I was able to connect to the local dynamodb. Most likely my coworkers already had unused but relevant keys in their aws config directory.