当我尝试加载此cloudformation模板以创建dynamo db表时,我收到以下错误
属性AttributeDefinitions与表的KeySchema和辅助索引
不一致{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"TableName": {
"Description": "Table name to use",
"Type": "String",
"Default": "test-user-unique-ids"
},
"ReadCapacityUnits": {
"Description": "Provisioned read throughput",
"Type": "Number",
"Default": "100",
"MinValue": "1",
"MaxValue": "10000",
"ConstraintDescription": "must be between 1 and 10000"
},
"WriteCapacityUnits": {
"Description": "Provisioned write throughput",
"Type": "Number",
"Default": "100",
"MinValue": "1",
"MaxValue": "10000",
"ConstraintDescription": "must be between 1 and 10000"
}
},
"Resources": {
"testUserUniqueIds": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": {
"Ref": "TableName"
},
"AttributeDefinitions": [
{
"AttributeName": "unique_id",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "guid",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": {
"Ref": "ReadCapacityUnits"
},
"WriteCapacityUnits": {
"Ref": "WriteCapacityUnits"
}
}
}
}
}
}
答案 0 :(得分:0)
属性名称定义为unique_id
。但是,已为属性guid
定义了哈希键。
在AttributeDefinitions
上定义的属性名称应该在KeySchema
上使用。它们应该是一致的。
在unique_id
和guid
上保留AttributeDefinitions
或KeySchema
。
修改强>
在创建Dynamodb表时,您只能包含关键属性,如分区键和排序键(如果可用)。 nosql数据库的整个概念是每个项目I.e.记录可以有不同的属性。创建表时,无需定义非键属性。 NoSQL是一种架构较少的数据库。
如果在创建表时指定任何非键属性,则会获得验证异常。