An error occurred: phoneNumberTable - CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename mysite-api-phonenumber-dev and update the stack again…
I tried deleting the database to see if it could re-create it then but it still gives the same error and doesn’t remake the database? What do I do here?
I hate this error too. I think it is a security feature of AWS. You are forced to change the name of phoneNumberTable to something like phoneNumberTable1. Then the next time you get the error change it back to phoneNumberTable. Deleting the resource will not work.
Maybe someone can enlighten us on a way around it.
I wasn’t aware you could change the name then change it back, that is an interesting tactic also. This way I don’t have to delete all the others tables, just the one I messed up on. You could add this as an answer on stackoverflow also if you wanted.
Be aware that changing the name of the table creates a new table with the new name and drops the original table(unless it has DeletionPolicy: Retain). So be sure to backup your data first if you wish to keep it.
My process for these situations has been:
copy the original table and data to mysite-api-phonenumber-dev-bak
rename the table in serverless.yml to mysite-api-phonenumber-devX
2a) sls deploy
rename the table in serverless.yml to mysite-api-phonenumber-dev <== remove the X
2a) sls deploy
restore the data
drop the backup table mysite-api-phonenumber-dev-bak