Hi There, Thank you in advance for taking a look ...
# help
Hi There, Thank you in advance for taking a look at this – I’m probably missing something very obvious, but what is the best pattern for adding / editing resources? Say for example we create a resource (say a dynamo table, or app sync api), and then modify. Does the CDK recognize that item already exists, or does it try to re-deploy it? The reason I ask is I’ve gotten this error:
already exists in stack
, and i’m 99% certain it’s just an incorrect workflow on my part. Any advice is helpful. For a more specific explanation, here is a demo:
Copy code
// Does CDK / SST recognize that this has already been deployed if I make a change or re-deploy? 

const notesTable = new sst.Table(this, "Notes", {
      fields: {
        id: sst.TableFieldType.STRING,
      primaryIndex: { partitionKey: "id" },
Hey @William Kasel, as long as the id (ie. “Notes”) remain the same, CloudFormation would try to update it.
Cool. That is what I needed to know. Last question - in -the case it’s not (for whatever reason) what is the best practice to remove it and ensure no orphans?
May I see the before and after version of the code?
Do you mean removing the table from the stack? Or removing the entire stack?
The table
This is more of a hypothetical.
Just want to ensure my mental model of this is correct.
Ah I see the confusion.
For most resources, if you remove the code in ur stack, the underlying resource is removed from AWS.
But some resources are by-default retained, ie. S3 Bucket, DyanmoDB Tables, etc
b/c they contain data
So the default behavior is “retain on deletion”
Makes sense. So to remove them specifically?
Perfect. And what if I need to go back and retroactively delete. Is it ok to just do manually?
Or is there a better way
Yeah, once they are orphaned, u’d need to remove them manually.
Or use the AWS CLI if there a lot of them
Makes sense. Very helpful. Thank you for your time & help.