In my current serverless.yml
I have the following resource declaration:
resources:
Resources:
stocksTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.stocksTableName}
AttributeDefinitions:
-
AttributeName: symbol
AttributeType: S
-
AttributeName: dateiso
AttributeType: S
-
AttributeName: monthIdx
AttributeType: S
KeySchema:
-
AttributeName: symbol
KeyType: HASH
-
AttributeName: dateiso
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
-
IndexName: monthIdx
KeySchema:
-
AttributeName: monthIdx
KeyType: HASH
-
AttributeName: dateiso
KeyType: RANGE
Projection:
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
Now, I need to add a second table with exactly the same structure and indexes.
Do I need to duplicate the entire entry for the new resource?
Option1
resources:
Resources:
stocksTable:
{declarations}
stocks2Table:
{declarations copied}
Or can I do something like this:
Option2:
resources:
Resources:
stocksTable:
stocks2Table:
{declarations}
But the TableName
will be a problem with option 2.
resources:
Resources:
stocksTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.stocksTableName}