AWS:无法在一次更新中执行多个 GSI 创建或删除

AWS: Cannot perform more than one GSI creation or deletion in a single update

所以我在无服务器部署过程中遇到了这个问题:

ServerlessError: An error occurred: MyDdbTable - Cannot perform more than one GSI creation or deletion in a single update.

我的DDB table配置是这样的: 配置在serverless.yml

      AttributeDefinitions:
          - AttributeName: externalId
            AttributeType: S
          - AttributeName: code
            AttributeType: S
          - AttributeName: accountId
            AttributeType: S
        KeySchema:
          - AttributeName: externalId
            KeyType: HASH
          - AttributeName: code
            KeyType: RANGE
        GlobalSecondaryIndexes:
          - IndexName: gsi-account-id
            KeySchema:
              - AttributeName: accountId
                KeyType: HASH
              - AttributeName: code
                KeyType: RANGE
            Projection:
              ProjectionType: ALL
          - IndexName: externalId
            KeySchema:
              - AttributeName: externalId
                KeyType: HASH
            Projection:
              ProjectionType: ALL
          - IndexName: code
            KeySchema:
              - AttributeName: code
                KeyType: RANGE
            Projection:
              ProjectionType: ALL

附加信息:

Objective/s:

我的目标是添加那两 (2) 个额外的索引(externalIdcode),但是在进行无服务器部署时,我总是遇到上述问题。

问题:

  1. 我遇到这个问题是因为代码已经存在于第一个的 keySchema (gsi-account-id) 中吗?
  2. 如果 #1 不是答案,你有什么 idea/suggestion 为什么我会遇到这个问题?

感谢那些在这方面帮助我的人。 ❤️

根据文档 Adding a Global Secondary Index to an Existing Table

You can only create one global secondary index per UpdateTable operation.

您需要添加一个 GSI,部署该更改,然后添加第二个 GSI 并进行部署。