2

I'm trying to set up a local DynamoDB, for testing my lambda functions, in WSL. The serverless.yml file is like this:

service: my-service

provider:
  name: aws
  runtime: nodejs10.x

  stage: dev
  region: eu-west-1

  environment:
    STAGE: ${opt:stage, self:provider.stage}
    DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}

functions:
  helloWorld:
    handler: ./api/handler.helloWorld
    events:
      - http:
          path: hello
          method: get
          cors: true

plugins:
  - serverless-dynamodb-local
  - serverless-offline

custom:
  dynamodb:
    start:
      port: 8000
      inMemory: false
      migrate: false
      dbPath: .
    stages:
      - dev

resources:
  Resources:
    ItemsDynamoDbTable:
      Type: 'AWS::DynamoDB::Table'
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          -
            AttributeName: id
            AttributeType: S
        KeySchema:
          -
            AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: ${self:provider.environment.DYNAMODB_TABLE}

To start the local server, I execute:

sls offline start

The DynaboDB local server is started, as I can see the following message in the console:

Dynamodb Local Started, Visit: http://localhost:8000/shell

I can navigate to the web browser shell. The problem is that I cannot execute any command there. For example, if I execute:

dynamodb.createTable(params, function(err, data) {
    console.log("Response")
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

I don't get any response.

If I try to migrate the data, using sls dynamodb migrate, or doing the same but in the serverless.yml file, I get the following message:

  NetworkingError: socket hang up
    at connResetException (internal/errors.js:559:14)
    at Socket.socketOnEnd (_http_client.js:440:23)
    at Socket.emit (events.js:214:15)
    at Socket.EventEmitter.emit (domain.js:476:20)
    at endReadableNT (_stream_readable.js:1178:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

Any idea about the origin of the problem?

Thank you in advance

jmatamoros
  • 514
  • 1
  • 5
  • 14

0 Answers0