Hi all - What’s the correct way to delete resource...
# sst
c
Hi all - What’s the correct way to delete resources when you rename them? (Detail in thread...)
I’ve started working through the new guide and ran into an issue when I tried to rename a stack in
lib/index.js
(the ‘StorageStack’ from [this step](https://serverless-stack.com/chapters/create-a-dynamodb-table-in-sst.html)). I renamed it initially to the same value in lowercase, and then tried again with a different name altogether and in both cases the re-deploy error-ed out that the Table already exists. see 1st error message in below I then ran
npx sst remove
to try and reset things, to re-deploy with the current values. This also errored at the end of the deploy process with a similar Table already exists error. see 2nd error message in below So, a couple questions I guess - * is there another method that needs to be used to remove all resources beyond
sst remove
? * is there a better approach then remove/redeploy when resources need to be renamed? Thanks for any help on this
1st error message
2nd error message
a
@Clayton remove the whole stack with
sst remove
and redeploy it or go to aws dashboard and manually delete those resources
c
Thanks @Aram. I did try
sst remove
and still hit that 2nd error on redeploy. Are there times when that doesn’t get rid of everything and you have to manually hit things in the aws console?
a
yep, a lot, I was struggling to remove a role today, and it didn't work from the first time even from aws console. There are time when it tells you that it got removed but it actually takes longer to go away, so if you are redeploying wight away you might still get that error.
all of that is a little bit weird but sometimes you have to remove that really "hard" to be able to redeploy again))
c
Thanks Aram, I’ve give that a shot
f
@Clayton the DynamoDB table issue specifically is that certain type of AWS resources are retained when you remove the stack. Things like S3 bucket, DynamoDB table, User Pool, etc, mostly things that contain data that you might want to keep around.
You can configure it to NOT retain on remove like this https://docs.serverless-stack.com/constructs/Table#configuring-the-dynamodb-table
c
Ah, gotcha, thanks @Frank. Is this normally only a concern when you’re renaming / redeploying stacks or something you need to keep an eye out for when redeploying in general?
f
Yeah whenever you rename or remove stuff from ur stacks. A rename is often a remove and an add.
So for non-production stages where you are interested to keep the data around after removing, you can just set all resources in your stacks NOT retain like this https://docs.serverless-stack.com/constructs/App#setting-a-default-removal-policy
c
Perfect, thanks @Frank