Creating two dynamoDB tables in serverless.ym

Having a single dynamoDB resource in serverless.yml works fine. But Having more than one table, gives an error. error states that “Cannot read property ‘LogicalResourceId’ of null”. Here is the resource section of serverless.yml:

 DynamoDbTableTask:
      Type: "AWS::DynamoDB::Table"
      Properties:
        AttributeDefinitions:
          - AttributeName: "taskId"
            AttributeType: "S"
          - AttributeName: "userId"
            AttributeType: "S"
        GlobalSecondaryIndexes:
          - IndexName "userId-index"
            KeySchema:
              - AttributeName: userId
                KeyType: "HASH"
            Projection:
              ProjectionType: "ALL"
            ProvisionedThroughput:
              ReadCapacityUnits: 2
              WriteCapacityUnits 2
        KeySchema:
          - AttributeName: "taskId"
            KeyType: "HASH"
        ProvisionedThroughput:
          ReadCapacityUnits: 5
          WriteCapacityUnits 5
        TableName: "lakshman-task"
    DynamoDbTableThing:
      Type: "AWS::DynamoDB::Table"
      Properties:
        AttributeDefinitions:
          - AttributeName: "thingId"
            AttributeType: "S"
          - AttributeName: "userId"
            AttributeType: "S"
        GlobalSecondaryIndexes:
          - IndexName "userId-index"
            KeySchema:
              - AttributeName: userId
                KeyType: "HASH"
            Projection:
              ProjectionType: "ALL"
            ProvisionedThroughput:
              ReadCapacityUnits: 2
              WriteCapacityUnits 2
        KeySchema:
          - AttributeName: "thingId"
            KeyType: "HASH"
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits 2
        TableName: "lakshman-thing"

I made sure that the name of the resources are different. Any Idea what could be the problem ?
Using serverless v1.7.0

It was my mistake. I didnt name the resource name in yml correctly.

1 Like