CloudFormation Deployment Issue: Error with DynamoDB GSI Updates

0

I am experiencing a persistent issue with AWS CloudFormation during the deployment of my amplify application stack. I add three GSI on one of my dynamodb tables and I encounter a failure when attempting to push this. The build error I am getting is "Cannot perform more than one GSI creation or deletion in a single update". I deleted the GSI's from my schema but the issue still persists when I deploy my app. This issue is blocking further deployments and updates to our environment, affecting our development and production operations. Any guidance with detailed steps, documentation, or known issues related to this would be greatly appreciated. Also, please let me know if there are any logs or additional information you require from my end to better diagnose this issue.

asked 14 days ago186 views
1 Answer
0

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:

  1. 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.

  2. 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.

  3. 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.

AWS
answered 14 days ago
  • Thank you very much for the guidance. I will try the suggested approaches.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions