How do you deal with that cannot delete export bec...
# help
t
How do you deal with that cannot delete export because it is in use thing again
I never seem to be able to predict when it's going to happen and then I get stuck
o
Last time that happened, I had to manually trace together the stack dependency tree, delete each stack manually (including clearing the S3 buckets for each one…), leaf first
t
That's what I'm doing which is ok because it's in dev...but what happens when this happens in prod
o
yeah…that experience taught me to never delete anything 😬
t
I hate cloudformation 😢
o
I’m paying for empty VPCs all over the place right now because of this, taking baby steps to remove them bit by bit
t
Yeah it's like if you don't get everything right all the time you're screwed
a
Removing all and deploy all again.
@thdxr can SST predict this maybe?
Like during build?
Or maybe this is visible with diff already?
t
I think sst can help diagnose this better than the confusing error you get from cdk
a
I would like to.
s
@Frank told me to just manually add the export to my code, then deploy.. so since the export is there, it won’t delete it. then after deploy, remove that manual export and deploy again
d
Oh boy we're not the only ones then. We get this issue whenever we want to change a bucket name, (trashing an old bucket from CDK for a new one).
f
@thdxr I gave this some thoughts. I think there might be a way for SST to detect this early. Imagine 2 stacks, stackA exports
tableArn
and stackB imports it. And now we remove the reference to
tableArn
in stackB, and stackA’s export will automatically be removed.
Now if you were to deploy, CFN will complain
Copy code
❌  dev-stackA failed: Export dev-stackA:ExportsOutputRefTableArn30B25837ED330C0 cannot be deleted as it is in use by dev-stackB
t
yeah
I'm starting to understand it now. I feel like CF should be smarter and realize it can deploy the stacks in a different order
f
So what we could do is, on `sst deploy`: 1. get currently deployed exports for each stacks, and find out which stacks are currently importing each 2. check if exports have changed 3. if exports are changed and will cause an issue, we automatically add the export 4. deploy
Starting v0.60.8, SST will handle this automatically by temporarily adding the exports.