Hi all, I am nearing conversion of my application...
# sst
f
Hi all, I am nearing conversion of my application to SST, but have the following question: I have a deployment pipeline which invokes
sst deploy
at the end (once the code is tested etc). Now the issue I run into is the following:
Integration-api-integration-MyTable already exists
so
Failed to deploy the app
Is it not possible to continually deploy the application? What would be best practice here? Apologies if this has been covered somewhere but I couldn't find it in the docs under the deployment section (or perhaps I misunderstood).
t
Certain resources have a removal policy of retain by default. This is for things like databases so they're not automatically deleted on stack destruction
If this is for production I'd suggest keeping it that way. Otherwise we have this https://docs.serverless-stack.com/constructs/App
app.setDefaultRemovalPolicy
But you should only set this in development environments
f
Thanks @thdxr, just so I am clear: Suppose I have had the app running for some time in development. I have databases that are populated already. I want to make updates to the deployment (perhaps I add another lambda function), but retain this table with live data. Would setDefaultRemovalPolicy still apply? Because I am not looking to destroy resources, simply add another lambda function (or indeed remove some code). Apologies if the question is basic I am pretty new to AWS/Serverless Stack.
Actually I think I may understand - this clash must be being caused by a resource name clash somewhere. I'll try to recreate and then redeploy, hopefully that will fix the issue. I can then continually deploy
@thdxr Seem to get this error if I try to follow the docs:
Property 'setDefaultRemovalPolicy' does not exist on type 'App'.ts(2339)
t
What version of sst are you on?
I think you're right about name clash
f
I am on the latest version. Things seem to be working now, but the gist I get is: If I try and deploy a stack, if for any reason it fails, then redeploying a new stack runs into the "already exists" issue, rather than over-writing.
f
@Fazi yeah, when creating a new stack fails half way, the deployment is automatically rolled back, and the created resources gets removed.
So if the removal policy is set to RETAIN, the table doesn’t get removed. And when you redeploy, you will get this “already exists” issue.
Let me know if that makes sense.