Hello everyone, I am new to SST. I had to add a ra...
# help
s
Hello everyone, I am new to SST. I had to add a range key to one of the DynamoDB tables in my app. Now, I am getting the following error while deploying:
Copy code
Export dev-storage:ExportsOutputFn.... cannot be deleted as it is in use by dev-api
I tried renaming the table. But, that did not work either. Please suggest.
a
when running a stage where you don’t want to persist the table on destroying the stage add this to the
Table
construct’s config :-
Copy code
dynamodbTable: {
        removalPolicy: RemovalPolicy.DESTROY,
      },
by default some constructs don’t get deleted to prevent data loss.
Table
,
Bucket
and
Auth
constructs and many others have this fail-safe and it can be overridden by the above config change. Add the config change, deploy it and then remove the table, that should solve it.
BTW, if you add a range key the table needs to be recreated, this is the reason why sst is trying to delete the table. I realised I missed explaining why the table was being deleted. You can define the key type only during table creation and that can’t be modified later.
s
Thanks for the response. I tried to add the config and deploy. But, I got the following error:
Copy code
Error: CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename dev-Referrals and update the stack again.
Then I tried to rename the table. But, ended up with the original error:
Copy code
cannot be deleted as it is in use by dev-api
a
oh, haven’t seen this one lol.
r
This might be to do with the CDK name rather than the dynamodb table name
s
I tried to remove the table and any api that was using it from code. But, I am getting the following error:
Copy code
...cannot be deleted as it is in use by dev-api
So, I guess my question is - how to delete an unused table?
j
@Frank have a look at this?
f
Hi @Shah Hossain, which version of SST are you using?
Can you try updating to v0.63.0 and try deploying again?
To add some context, you can read more about this issue here and SST is able to auto-fix this starting v0.60.8 https://docs.serverless-stack.com/advanced/cross-stack-references#removing-a-reference
@Shah Hossain just checking in and see if you managed to get around this issue.
s
Frank, Thanks for checking. Yes, I got around the issue by manually updating the template in the AWS console. There were some references to the table in the API even after removing it in code.
f
Ah nice 👍