发电机数据库云形成模板错误



当我尝试加载此云形成模板以创建发电机数据库表时,我收到以下错误

属性

属性定义与表和二级索引的键架构不一致

{
  "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"
          }
        }
      }
    }
  }
}

属性名称定义为 unique_id 。但是,已为属性 guid 定义了哈希键。

AttributeDefinitions上定义的属性名称以及相同的

属性名称应在 KeySchema 上使用。它们应该是一致的。

要么保持unique_id,要么guid AttributeDefinitionsKeySchema

编辑:

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

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

最新更新