【发布时间】:2017-12-13 17:32:33
【问题描述】:
通过命令行或在线 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
【问题讨论】:
-
你能显示你用来创建具有复合主键的表的命令吗?
-
我只需要正确的 YAML 语法。我实际上是使用无服务器框架来部署云形成代码。在 Web API 上有一个简单的复选框供您选中。
标签: amazon-dynamodb amazon-cloudformation