我正在尝试使用AWS CloudFormation创建AWS DynamoDB表,
我在创建相同时会遇到错误。
以前我指定了我想要的所有表的所有列,
但是似乎属于属性finitions和Keyschema属性需要以某种方式匹配,但是不确定。
我只缩小到我的桌子中必须有2列,
IE。user_id and expiry
,
user_id是主要键和到期是用于ttl 的列。
我仍会遇到以下错误 -
属性AttributedEfinitions与表的键和辅助索引
以下是我的模板的摘要 我正在关注此参考文档 - 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
yaml对文件使用固定的凹痕模式/方案,这可能是获取错误的原因。我尝试了以下代码并能够创建DynameDB表。希望您可以按照您的要求进行足够的更改:
AwstemplateFormatversion:" 2010-09-09"描述:"用于创建DynamoDB表的AWS云形式模板 - userexpriry。"资源:USEREXPIROY:类型:'aws :: dynamodb :: table'属性: tableName:newtableName AttributedEfinitions: - attributeName:'user_id' attributetype:'s'
Keyschema: - attributeName:" user_id" Keytype:"哈希" 时间表规定: attributeName:"有效" 启用:true PROFISIONEDTHOUGHTUT: ReadCapacityUnits:1 WriteCapacityUnits:1 标签: - 钥匙:'mykey' 价值:" projectName"
(*(使用上述YML文件创建的表(newTableName( - 仅包含" user_id"的单列。在插入记录期间,可以放置TTL规范列"有效期"。