DynamoDB, serverless.yml

HI all,

Is it possible to create two or more tables in dynamoDB using single serverless.yml.
I tried but unsuccessfully, if yes please simple example.

Thank you

Hi Jonsmirl
It works, thank you very much for your time and help

I made three tables in one YAML file with this:

eventsDynamoDbTable:
  Type: 'AWS::DynamoDB::Table'
  Properties:
    AttributeDefinitions:
      - AttributeName: Serial
        AttributeType: S
      - AttributeName: Timestamp
        AttributeType: N
    KeySchema:
      - AttributeName: Serial
        KeyType: HASH
      - AttributeName: Timestamp
        KeyType: RANGE
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1
    TableName: $<self:provider.environment.EVENT_TABLE>

ownerDynamoDbTable:
  Type: 'AWS::DynamoDB::Table'
  Properties:
    AttributeDefinitions:
      - AttributeName: Serial
        AttributeType: S
      - AttributeName: CogID
        AttributeType: S
    KeySchema:
      - AttributeName: Serial
        KeyType: HASH
      - AttributeName: CogID
        KeyType: RANGE
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1
    TableName: $<self:provider.environment.OWNER_TABLE>

userDynamoDbTable:
  Type: 'AWS::DynamoDB::Table'
  Properties:
    AttributeDefinitions:
      - AttributeName: CogID
        AttributeType: S
    KeySchema:
      - AttributeName: CogID
        KeyType: HASH
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1
    TableName: $<self:provider.environment.USER_TABLE>
3 Likes

Already managed to do it.