Open revmischa opened 4 years ago
Alright finally I found out a method (it's very raw) to locally test dynamodb
I have this version:
"serverless-dynamodb-local": "^0.2.37"
serverless.yml custom parameters:
dynamodb:
stages:
- ${self:provider.stage}
start:
port: 8000
inMemory: true
migrate: true
#noStart: true
migration:
dir: offline/migrations
My lambda runs this configuration:
let options = {};
if (process.env.IS_OFFLINE) {
options = {
endpoint: 'http://localhost:8000',
region: 'localhost'
}
}
const dynamodb = new DynamoDB.DocumentClient(options);
after that I run serverless dynamodb start --stage local
in one shell
and sls offline --stage local
in the other one
This works, it's the first solution that worked for me, I will try to improve it in the meantime you could use this one
I've had some issue similar to this that were fixed by setting the correct order of plugins in serverless.yml file. Put serverless-offline before dynamodb, i.e. like below
plugins:
- ...
- serverless-offline
- serverless-dynamodb-local
Yeah, same issue here... you can start it with sls dynamodb start
but really needs to auto start with serverless-offline.
Edit: it seems I have found the solution... run serverless offline with the command: serverless offline start
I've had some issue similar to this that were fixed by setting the correct order of plugins in serverless.yml file. Put serverless-offline before dynamodb, i.e. like below
plugins: - ... - serverless-offline - serverless-dynamodb-local
According to the docs serverless-offline
should be last
https://github.com/dherault/serverless-offline#usage-with-serverless-dynamodb-local-and-serverless-webpack-plugin
# ✅ works
sls offline start
serverless offline start
# ❌ not work
sls offline
serverless offline
sls offline
and serverless offline
dose not start dynamodb-local automatically.
But sls offline start
and serverless offline start
dose start dynamodb-local automatically.
Because serverless-dynamodb-local has hook with before:offline:start
.
So you need to add start
.
Actual Behaviour
Not starting local dynamo when running
sls offline
Steps to reproduce it
LogCat for the issue
Provide logs for the crash here
Would you like to work on the issue?
Not sure where to start