- Newest
- Most votes
- Most comments
The error "Cannot perform more than one GSI creation or deletion in a single update" is a known limitation with AWS CloudFormation when updating DynamoDB tables with Global Secondary Indexes (GSIs).
The issue you're facing is likely due to the way CloudFormation handles DynamoDB table updates. When you update a DynamoDB table with multiple GSI changes (create, update, or delete), CloudFormation tries to perform all the changes in a single update operation, which is not allowed by the DynamoDB service.
Here are some steps you can follow to work around this issue:
-
Break down the changes: Instead of making all the GSI changes in a single CloudFormation update, try to break down the changes into multiple updates, each addressing only one GSI change at a time.
-
Use a separate CloudFormation stack for DynamoDB table updates: Consider creating a separate CloudFormation stack just for managing your DynamoDB table and its GSIs. This way, you can update the DynamoDB table independently from the rest of your Amplify application stack.
-
Use AWS CLI or AWS SDK: Instead of relying solely on CloudFormation, you can use the AWS CLI or AWS SDK to update your DynamoDB table with GSI changes. This allows you to have more control over the update process and avoid the CloudFormation limitation.
Here's an example of how you can update a DynamoDB table with a new GSI using the AWS CLI:
bash
aws dynamodb update-table
--table-name your-table-name
--attribute-definitions AttributeName=new-gsi-attribute,AttributeType=S
--global-secondary-index-updates file://gsi-update.json
The gsi-update.json
file would contain the GSI definition, for example:
json [ { "Create": { "IndexName": "new-gsi-name", "KeySchema": [ { "AttributeName": "new-gsi-attribute", "KeyType": "HASH" } ], "Projection": { "ProjectionType": "ALL" }, "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5 } } } ]
Alternatively, you can use the AWS SDK for your preferred programming language to update the DynamoDB table with GSI changes.
It's worth noting that the DynamoDB service has a hard limit of 20 GSIs per table. If you're reaching that limit, you may need to consider restructuring your data model or using alternative approaches, such as partitioning your data across multiple tables.
If you have any further questions or need more specific guidance, please provide more details about your CloudFormation template, the specific changes you're trying to make, and any other relevant information that could help us better understand your issue.
Relevant content
- asked 2 years ago
- asked a year ago
- asked 7 months ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Thank you very much for the guidance. I will try the suggested approaches.