https://pulumi.com logo
#general
Title
# general
s

steep-toddler-94095

08/12/2022, 2:50 AM
I'm sort of confused on how in this example the
Command
knows only to run when the EKS cluster is being deleted. Is it because
environment
depends on
cluster
? I.e. if the
KUBECONFIG
was a hardcoded string then this
Command
would just never run under any circumstances? https://www.pulumi.com/registry/packages/command/#graceful-cleanup-of-workloads-in-a-kubernetes-cluster What if this Command depends on multiple pulumi resources? Would it run if just one of the resources is being deleted?
l

little-cartoon-10569

08/12/2022, 3:06 AM
delete: "kubectl delete --all namespaces",
seems to capture the intention
s

steep-toddler-94095

08/12/2022, 3:07 AM
But how does it know only to run that command when the right cluster is deleted?
Actually i think i found the answer in another example:
Note that implicit and explicit (
dependsOn
) dependencies can be used to control the order that these
Command
and
CopyFile
resources are constructed relative to each other and to the cloud resources they depend on. This ensures that the
create
operations run after all dependencies are created, and the
delete
operations run before all dependencies are deleted.
so the Command is only run if all implicit or explicit dependencies fulfill the create/delete/etc event. So if a Command has two dependencies, but only 1 is being deleted, it will not run
l

little-cartoon-10569

08/12/2022, 3:13 AM
That's good to know alright, but in that example, there's only one dependency.
When the cluster is deleted, the command has to be deleted first (dependency in
environment
).
s

steep-toddler-94095

08/12/2022, 3:17 AM
Yeah. Not knowing what would happen if there are multiple dependencies, for some reason, totally derailed me train of thought. Thanks for helping out 🙂
👍 1