99x / serverless-dynamodb-local

Serverless Dynamodb Local Plugin - Allows to run dynamodb locally for serverless
MIT License
626 stars 232 forks source link

serverless.yml support for AWS DynamoDB new On-Demand capacity mode missing #193

Open MartijnCaprica opened 5 years ago

MartijnCaprica commented 5 years ago

With the introduction of the AWS DynamoDB On-Demand capacity model at re:Invent 2018, table definitions have been changed. As a result, serverless.yml files that use the new 'BillingMode' property result in the local DynamoDB instance failing to start:

$ serverless dynamodb start Dynamodb Local Started, Visit: http://localhost:8000/shell Serverless: DynamoDB - Error -

Multiple Validation Errors -----------------------------

There were 2 validation errors:

$

Expected Behaviour The local DynamoDB instance should allow capacity properties in the serverless.yml file to be based on either 'ProvisionedThroughput' or 'BillingMode'. Since these properties should not influence DynamoDB API invocation (either local through the plugin or on AWS), allowing the changed definitions should be enough to start using it.

Steps to reproduce it Take an existing serverless.yml file that holds a ProvisionedThroughput definition, e.g.:

mytable:
  Type: AWS::DynamoDB::Table
  Properties:
    TableName: myTable
    AttributeDefinitions:
      - AttributeName: id
        AttributeType: N
    KeySchema:
      - AttributeName: id
        KeyType: HASH
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1

Change the ProvisionedThroughput part to the new BillingMode property:

mytable:
  Type: AWS::DynamoDB::Table
  Properties:
    TableName: myTable
    AttributeDefinitions:
      - AttributeName: id
        AttributeType: N
    KeySchema:
      - AttributeName: id
        KeyType: HASH
    BillingMode: PAY_PER_REQUEST

Start the local dynamodb with: serverless dynamodb start

jonaswitt commented 5 years ago

See #189

vdanniel commented 5 years ago

Has this been solved. I have the same issue and #189 is for dynamo local. I am having issues with nodejs lambda trying to create table with on demand in dynamoDb In the cloud

EwanValentine commented 5 years ago

We're also seeing this issue.

vdanniel commented 5 years ago

Reached out to AWS support. It looks to be that the AWS SDK that lambda runs by default is an older version and could take time until they are updated.

The option to fix it is to fix and package the latest version and making the code use the latest version. You would want aws-sdk 2.38 above.

I think the delay in updating the default lambda is for v3 will be out soon.

Other option is to try out the beta.

ameenaliu commented 5 years ago

@vdanniel Do you have a working solution for this. I'm on aws-sdk 2.422 but still experiencing the error.