cloudformation 模板更新 dynamodb 资源中的 GSI 新的非关键属性,而无需删除 GSI 并将其重新添加回去

cloudformation template to update with new nonkeyattributes to GSI in dynamodb resource without removing GSI and adding it back again

我想通过 cloudformation 使用新的非关键属性将 GSI 更新为现有的非关键属性。目前,当我想添加新的非键属性时,我需要取消配置 GSI 并使用新的和现有的非键属性重新配置它。有没有办法在每次都取消配置 GSI 的情况下添加非关键属性?

资源:

DynamoDB 表:

Type: "AWS::DynamoDB::Table"
Properties:
  TableName: "employee table"
  AttributeDefinitions:
    - AttributeName: "CustomerId"
      AttributeType: "S"
    - AttributeName: "empId"
      AttributeType: "S"
    - AttributeName: "Date"
      AttributeType: "N"
  KeySchema:
    - AttributeName: "CustomerId"
      KeyType: "HASH"
  ProvisionedThroughput:
    ReadCapacityUnits: 20
    WriteCapacityUnits: 20
  GlobalSecondaryIndexes:
    - IndexName: "ByempId"
      KeySchema:
      - AttributeName: "empId"
        KeyType: "HASH"
      - AttributeName: "Date"
        KeyType: "RANGE"
      Projection:
        NonKeyAttributes:
          - "status1"
          - "status2"
          - "status3"
        ProjectionType: INCLUDE
      ProvisionedThroughput:
        ReadCapacityUnits: "20"
        WriteCapacityUnits: "20"
        

如果我想添加新的 NonKeyAttributes status4,我需要注释掉从 GlobalSecondaryIndexes 到模板末尾的行,并提供所有 NonKeyAttributes (status1,2,3,4)

不支持 对 GSI 的更新,如 docs:

中所述

Updates are not supported. The following are exceptions:

If you update only the provisioned throughput values of global secondary indexes, you can update the table without interruption.

You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails.

如您所见,您可以删除和创建新的 GSI,但不能更新现有 GSI。