I have two Pulumi resources, call them `pA` and `p...
# general
f
I have two Pulumi resources, call them
pA
and
pB
, that need to be deployed. Before
pB
can be deployed, I have some custom CLI stuff that needs to be run that depends on
pA
outputs. Is it possible to do this with Pulumi?
i
It is possible, but in general we don’t have a good solution for this. The main problem is that Pulumi currently doesn’t have a way to “hook in” to another resource’s lifecycle and only run something when a resource is created or replaced. It’s definitely something that we want to do, though, since it’s a killer feature.
m
FWIW, if the CLI bits you need to run are idempotent, you can work around this limitation using an
apply
i
^ true.
m
you can avoid running the code during a preview by early-returning from the
apply
if
pulumi.runtime.isDryRun()
is
true
f
Hmm, it's not idempotent by default but it might be possible to make it that way. Thanks for the pointers. This feature would indeed be killer.
If I throw an exception in an
apply
, will the update be cancelled?
m
Yes
Any uncaught exception will kill the update
👌 1
f
How would I ensure that my CLI stuff in the
apply
completes before the
pB
?