Hi :wave: , how does one 'wait' on a stack before ...
# sst
g
Hi 👋 , how does one 'wait' on a stack before the other one executes? particularly for the case of waiting for the prior stack to finish storing variables in SSM before the other pulls them instead of it throwing 'SSM parameter not available in account'
t
You should probably pass the ssm parameter to the other stack which can use it. Then CloudFormation understands there's a dependency between two stacks
Otherwise you have to manually add a dependency between them
g
you mean instead of passing the 'parameter name string' I should pass instead a ssm.StringParameter object for example?
t
yeah
g
I'll give that a try thanks!!
t
if that ends up being awkward you can do
Copy code
function StackB() {
  dependsOn(StackA)
}
d
Since I am from the camp of “never hand variables between stacks due to an undying hatred of Cloudformation exports”, I will just add that `Stack`s have a method on them called
addDependency
and it takes another
Stack
as the only param, and does exactly what you asked for initially.
g
ahh what's this hatred of Cloudformation exports about 😛 ?
d
It more or less boils down to two main things: 1. It creates hard couplings between stacks, which can make deleting stacks a very tedious process, as it gets blocked until you create “fake” dependent items, then switch back to real. This wouldnt be a big deal, except it is probably the most common troubleshooting methodology. 2. It makes moving stacks between apps a major process as opposed to copy/paste.
t
We actually patched over that scenario in 1 where we detect that problem and do the fake export on your behalf. Haven't run into it since then
But yes cfn exports are...rough
r
We actually patched over that scenario in 1
In SST v1.0 or just internally?
t
In SST v1.0
g
Hmm even in v1 I had to manually call
stack.exportValue
to clean it up
t
cc @Frank are there cases where this can happen?
f
hmm.. we wouldn’t be able to patch if you are trying to remove the stack that’s exporting the value. A bit of context, when u un-export a value, on deploy, SST first does a look up to see if other stacks are still importing the value. If it is still in use, SST adds a temporary export value (similar to calling
stack.exportValue
manually).
@Giorgio if you run into this issue again on
sst deploy
, feel free to send me the
.build/sst-debug.log
.
g
👍 will do!