【发布时间】:2019-11-13 15:43:37
【问题描述】:
我正在尝试使用 AWS CloudFormation 创建一个 AWS DynamoDB 表,
创建相同内容时出现错误。
之前我已经指定了我想要的表的所有列,
但似乎 AttributeDefinitions 和 KeySchema Properties 需要以某种方式匹配,但不确定。
我缩小到只有 2 列必须在我的表中,
IE。 user_id and expiry,
user_id 是主键,expiry 是用于 TTL 目的的列。
我仍然收到以下错误 -
属性AttributeDefinitions与表的KeySchema和二级索引不一致
以下是我的模板的 sn-p,根据 CloudFormation StatusReason,我遇到了问题 -
userExpiry:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: !Join ['_', [!Ref "prefix",'user_expiry'] ]
AttributeDefinitions:
-
AttributeName: 'expiry'
AttributeType: 'N'
-
AttributeName: 'user_id'
AttributeType: 'S'
KeySchema:
- AttributeName: "user_id"
KeyType: "HASH"
TimeToLiveSpecification:
AttributeName: "expiry"
Enabled: true
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
Tags:
-
Key: 'Project'
Value: !Ref "ProjectName"
-
Key: 'Environment'
Value: !Ref "ResourceEnvironment"
我正在关注这个参考文档 -
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html
【问题讨论】:
标签: amazon-web-services amazon-dynamodb amazon-cloudformation