Question:
So I’ve been encountering this issue during serverless deployment:
1 2 |
ServerlessError: An error occurred: MyDdbTable - Cannot perform more than one GSI creation or deletion in a single update. |
My DDB table configuration is this:
Configuration in serverless.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
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 |
Additional information:
- One (1) index is already existing which is the
gsi-account-id
where it has two (2) keySchema,accountId
and thecode
- I added two (2) additional index which are
externalId
andcode
Objective/s:
My goal is to add those two (2) additional indexes (externalId
and code
) but upon doing a serverless deployment, I always encounter the issue said above.
Questions:
- Do I encounter this issue because the code is already existing in the first’s keySchema (gsi-account-id)?
- Do you have any idea/suggestion on why do I encounter this issue if the #1 is not the answer?
Thank you for those who’ll help me on this. ❤️
Answer:
Per the documentation Adding a Global Secondary Index to an Existing Table
You can only create one global secondary index per UpdateTable operation.
You’ll need to add one GSI, deploy that change, then add the second and deploy it.