Development Tip

PropertyDefinition이 일치하지 않습니다.

yourdevel 2020. 12. 4. 21:00
반응형

PropertyDefinition이 일치하지 않습니다.


dynamoDB 테이블을 생성하기 위해 cloudformation UI에서 사용중인 다음 템플릿이 있습니다. PrimaryKeyID로 , sortKeyValue사용하여 테이블을 만들고 싶습니다.

{
  "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에서 새 스택을 클릭하고 template로컬 컴퓨터 파일을 가리키고 스택에 이름을 지정한 후 다음을 클릭합니다. 얼마 후 Property AttributeDefinitions가 테이블 및 보조 인덱스의 KeySchema와 일치하지 않는다는 오류가 발생 합니다.


문제는 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"
    }
   }
  }
}

참고 URL : https://stackoverflow.com/questions/41915749/propertydefinition-inconsistent

반응형