【发布时间】:2017-10-22 11:30:59
【问题描述】:
我正在尝试定义一个具有 3 列复合键的 dynamodb 表。这可能吗?
我见过有这样代码的示例和教程:
resources:
Resources:
TodosDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.DYNAMODB_TABLE}
但这只有一列和一个键。我的桌子是这样的:
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: N
- AttributeName: server
AttributeType: S
- AttributeName: room
AttributeType: S
- AttributeName: friendlyName
AttributeType: S
我想要id、server 和 room 上的密钥。用户可以在同一台服务器上的多个房间中,也可以在多台服务器上的多个房间中。但是,在这三个键中,它始终是唯一的。
我不知道如何定义KeySchema 部分。有什么帮助吗?
【问题讨论】:
标签: amazon-web-services amazon-dynamodb serverless-framework