PropertyDefinition is incompatible

I have the following template that I use in the cloudformation user interface to create a dynamoDB table. I want to create a table with PrimaryKey as ID and sortKey as 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"
    }
  }
}

In the CF interface, I click on the new stack, point to the file templatefrom my local computer, give the stack a name and click next. After some time, I get the error Property AttributeDefinitions is incompatible with KeySchema tables and secondary indexes

+47
source share
2 answers

, Resources.Properties.AttributeDefinitions , . , Resources.Properties.AttributeDefinitions , Resources.Properties.KeySchema.

AWS:

AttributeDefinitions: AttributeName AttributeType, .

:

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

DynamoDB, , " AttributeDefinitions KeySchema ". - , .

{
"DDBTable": {
      "Type": "AWS::DynamoDB::Table",
      "Properties": {
    "AttributeDefinitions": [
        {
            "AttributeName": "SchoolId",
            "AttributeType": "N"
        },
        {
            "AttributeName": "Name",
            "AttributeType": "S"
        },
        {
            "AttributeName": "Address",
            "AttributeType": "S"
        },
        {
            "AttributeName": "City",
            "AttributeType": "S"
        }
    ],
    "TableName": "School",
    "KeySchema": [
        {
            "AttributeName": "SchoolId",
            "KeyType": "HASH"
        },
        {
            "AttributeName": "Name",
            "KeyType": "RANGE"
        }
    ],
    "LocalSecondaryIndexes": [
        {
            "IndexName": "LastPostIndex",
            "KeySchema": [
                {
                    "AttributeName": "SchoolId",
                    "KeyType": "HASH"
                },
                {
                    "AttributeName": "City",
                    "KeyType": "RANGE"
                }
            ],
            "Projection": {
                "ProjectionType": "KEYS_ONLY"
            }
        }
    ],
    "ProvisionedThroughput": {
        "ReadCapacityUnits": 5,
        "WriteCapacityUnits": 5
    },
    "Tags": [ 
      { 
         "Key": "Owner",
         "Value": "BlueTeam"
      }
   ]
}
0

Source: https://habr.com/ru/post/1014525/


All Articles