Deploy table after changing key schema

This is a solution for dynamoDB's deployment issue

Issue description

After changing dynamoDB table's key schema, deploying will throw an error:

studentTable - CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename studentTable and update the stack again..

Working solution

Rename the table name in serverless.yml file from xxx to xxx2. Deploy and rename it back to xxx and deploy again and it should work.

Tried solution

Delete the table and redeploy. Same error.

Hint

If you set DeletionPolicy to Delete, this deployment process will delete the table with the old name. You can backup the table first and restore it later.

Reference

CloudFormation cannot update a stack when a custom-named resource requires replacing

Last updated