在Cloudformation中创建DynamoDB表失败

时间:2018-06-24 17:24:34

标签: amazon-dynamodb amazon-cloudformation

我遇到以下错误:

  

属性AttributeDefinitions与表的KeySchema和辅助索引不一致

但是我不确定这是怎么回事。

  FeedbackTable: 
    Type: "AWS::DynamoDB::Table"
    Properties: 
      AttributeDefinitions: 
        - 
          AttributeName: "uuid"
          AttributeType: "S"
        - 
          AttributeName: "timestamp"
          AttributeType: "N"
        - 
          AttributeName: "pros"
          AttributeType: "S"
        - 
          AttributeName: "cons"
          AttributeType: "S"
        - 
          AttributeName: "comments"
          AttributeType: "S"
        - 
          AttributeName: "options"
          AttributeType: "S"
        - 
          AttributeName: "luaA"
          AttributeType: "S"
        - 
          AttributeName: "luaB"
          AttributeType: "S"
        - 
          AttributeName: "luaC"
          AttributeType: "S"
      KeySchema: 
        - 
          AttributeName: "uuid"
          KeyType: "HASH"
        - 
          AttributeName: "timestamp"
          KeyType: "RANGE"
      ProvisionedThroughput: 
        ReadCapacityUnits: "1"
        WriteCapacityUnits: "1"
      TableName: "BD_Feedback"

1 个答案:

答案 0 :(得分:1)

您无需在此处为DynamoDB表指定所有属性。 cloudformation所需的只是键和索引属性的定义。

因此,如果将AttributeDefinition缩减为uuidtimestamp,那应该没问题(只要您没有二级索引)。

这是CloudFormation文档中有关此主题的部分:

  

描述表和表的关键架构的属性列表   索引。允许重复。

CloudFormation docs