Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not starting DDB-local when running sls offline #256

Open
revmischa opened this issue Sep 7, 2020 · 5 comments
Open

Not starting DDB-local when running sls offline #256

revmischa opened this issue Sep 7, 2020 · 5 comments

Comments

@revmischa
Copy link

Actual Behaviour

Not starting local dynamo when running sls offline

Steps to reproduce it

plugins:
  - serverless-plugin-typescript
  - serverless-plugin-optimize
  - serverless-pseudo-parameters
  - serverless-dynamodb-local
  - serverless-offline

custom:
  serverless-offline:
    useChildProcesses: true
  dynamodb:
    start: # why doesn't this automatically start?
      port: 4455
      # inMemory: true
      migrate: true
    stages:
      - dev

LogCat for the issue

Provide logs for the crash here

❯ sls offline
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Compiling with Typescript...
Serverless: Using local tsconfig.json
Serverless: Typescript compiled.
Serverless: Watching typescript files...
offline: Starting Offline: dev/eu-west-1.
offline: Offline [http for lambda] listening on http://localhost:3002

   ┌─────────────────────────────────────────────────────────────────────────────────┐
   │                                                                                 │
   │   POST | http://localhost:3000/dev......  │                                                                                 │
   └─────────────────────────────────────────────────────────────────────────────────┘

offline: [HTTP] server ready: http://localhost:3000 🚀
offline:
offline: Enter "rp" to replay the last request

Would you like to work on the issue?

Not sure where to start

@mdepascale
Copy link

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

@kaskelotti
Copy link

kaskelotti commented Nov 25, 2020

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

@itsUnsmart
Copy link

itsUnsmart commented Feb 14, 2021

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

@coreyar
Copy link

coreyar commented May 15, 2021

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

@say8425
Copy link

say8425 commented Oct 10, 2021

# ✅ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants