Hello, How does the `parent` property of ResourceO...
# getting-started
c
Hello, How does the
parent
property of ResourceOptions relate to
depends_on
? For example, when I set the
parent
do I also have to add the same value to
depends_on
? Or when I add a component to
depends_on
, does it also imply indirect dependency on its children (for creation and destruction of the resource)?
l
They don't relate.
depends_on
adds a resource-level dependency: if the dependent resource is being deleted, then the dependency resource is deleted first.
parent
adds hierarchy to the resource graph. Lines in
pulumi preview
output, and in the Pulumi webapp, show parent-child relationships. By default, opts of parents are inherited by children, unless opts are explicitly provided to children (which I strongly recommend, as implicit opts cause all sorts of hard-to-debug problems).
c
Thanks. Is there a way to visualise the hierarchy defined by the
depends_on
property in the web app in a similar way to how I view the "parent" hierarchy? It's often the dependency defined by
depends_on
that matters and I missed deps, which cost me time to realise.
l
Not easily. You can export the state and look at the property in there. In addition to explicit dependencies via that opt, there's all the dependencies through properties (all the Inputs you pass into a resource's constructor), plus it's not a tree-style graph (it allows fan-in and fan-out, as opposed to parent-child, which is fan-out only), so it's pretty messy to visualize. Generally you don't need to though, as Pulumi takes care of that for you. If you delete X that's dependent on Y, then Pulumi will delete Y first. If it can't, it won't delete X (and it'll report an error).