serverless-dynamodb-local icon indicating copy to clipboard operation
serverless-dynamodb-local copied to clipboard

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

Open MartijnCaprica opened this issue 5 years ago • 5 comments

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:

  • MissingRequiredParameter: Missing required key 'ProvisionedThroughput' in params

  • UnexpectedParameter: Unexpected key 'BillingMode' found in params

    For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

    Get Support -------------------------------------------- Docs: docs.serverless.com Bugs: github.com/serverless/serverless/issues Issues: forum.serverless.com

    Your Environment Information ----------------------------- OS: darwin Node Version: 8.9.4 Serverless Version: 1.34.1

$

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

MartijnCaprica avatar Dec 13 '18 11:12 MartijnCaprica

See #189

jonaswitt avatar Dec 17 '18 13:12 jonaswitt

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

vdanniel avatar Jan 08 '19 03:01 vdanniel

We're also seeing this issue.

EwanValentine avatar Jan 14 '19 11:01 EwanValentine

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.

vdanniel avatar Jan 14 '19 18:01 vdanniel

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

ameenaliu avatar Mar 30 '19 18:03 ameenaliu