无论是从命令行还是在线API中,我都可以轻松创建“复合主键”,但是当我尝试使用CloudFormation来完成这项工作时,我没有看到任何JSON / YAML可以让我设置所谓的“复合主键”。语言完全不同,因此我希望有人能指导我如何使用Cloudformation创建这样的密钥。
我最好的猜测是以下内容,其中我希望复合密钥由userId和noteId组成:
Resources:
usersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: notes_serverless
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
- AttributeName: noteId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
- AttributeName: noteId
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1