gpt4 book ai didi

amazon-web-services - 属性定义不一致

转载 作者:行者123 更新时间:2023-12-03 05:32:19 25 4
gpt4 key购买 nike

我有以下模板,我在 cloudformation UI 中使用它来创建 dynamoDB 表。我想创建一个表,其中 PrimaryKey 作为 IDsortKey 作为 Value

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "DB Description",

"Resources" : {
"TableName" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions": [ {
"AttributeName" : "ID",
"AttributeType" : "S"
}, {
"AttributeName" : "Value",
"AttributeType" : "S"
} ],
"KeySchema": [
{
"AttributeName": "ID",
"KeyType": "HASH"
}
]
},
"TableName": "TableName"
}
}
}

在 CF UI 上,我单击“新堆栈”,指向本地计算机中的模板 文件,为堆栈指定名称,然后单击“下一步”。一段时间后,我收到错误消息:Property AttributeDefinitions 与表和二级索引的 KeySchema 不一致

最佳答案

问题在于,Resources.Properties.AttributeDefinitions 键必须定义用于索引或键的列。换句话说,Resources.Properties.AttributeDefinitions 中的键必须与 Resources.Properties.KeySchema 中定义的相同键匹配。

AWS 文档:

AttributeDefinitions: A list of AttributeName and AttributeType objects that describe the key schema for the table and indexes.

因此生成的模板将如下所示:

{
"AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "DB Description",

"Resources" : {
"TableName" : {
"Type" : "AWS::DynamoDB::Table",
"Properties" : {
"AttributeDefinitions": [ {
"AttributeName" : "ID",
"AttributeType" : "S"
} ],
"ProvisionedThroughput":{
"ReadCapacityUnits" : 1,
"WriteCapacityUnits" : 1
},
"KeySchema": [
{
"AttributeName": "ID",
"KeyType": "HASH"
}
] ,
"TableName": "table5"
}
}
}
}

关于amazon-web-services - 属性定义不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41915749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com