Amazon dynamodb dynamo db cloudformation模板错误

Amazon dynamodb dynamo db cloudformation模板错误,amazon-dynamodb,amazon-cloudformation,Amazon Dynamodb,Amazon Cloudformation,当我尝试加载此cloudformation模板以创建dynamo db表时,出现以下错误 属性AttributeDefinitions与表和二级索引的KeySchema不一致 { "AWSTemplateFormatVersion": "2010-09-09", "Parameters": { "TableName": { "Description": "Table name to use", "Type": "String", "Defaul

当我尝试加载此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"
          }
        }
      }
    }
  }
}

属性名称定义为
唯一\u id
。但是,已为属性
guid
定义了哈希键

AttributeDefinitions
上定义的属性名称以及在
KeySchema
上使用的属性名称。它们应该是一致的

AttributeDefinitions
KeySchema
上保持
unique\u id
guid

编辑:

在创建Dynamodb表时,如果可用,则只能包含诸如分区键和排序键之类的键属性。nosql数据库的整体概念是,每个项目(即记录)可以具有不同的属性。创建表时不需要定义非键属性。NoSQL是一个无模式的数据库


如果在创建表时指定任何非键属性,则会出现验证异常。

如何向表中添加其他列?我想为unique_id、guid和services添加列,而您说没有办法使主键和对象或数组,甚至连secondary keyComment都不清楚。我只是在添加更多信息。简单地说,创建表时只能定义键属性。如果您有任何GSI(全局二级索引),也可以在创建表时定义GSI的关键属性。创建表时不能定义任何不属于键(主表或索引)的属性。我们可以将键或辅助索引设置为数组或对象吗?不,DynamoDB不支持。不能对文档数据类型(如集合、映射、列表、数组等)创建索引。