Why, when I try and delete a specific resource wit...
# general
m
Why, when I try and delete a specific resource with the --target property, does Pulumi complain that it can't delete it without deleting the child resource X? If I am telling it to delete the parent resource then I want it to delete all the child resources
b
You need
--target-dependents
--target {urn}
defaults to only deleting the target for safety
l
So the interesting part is that
--target-dependents
doesn't always work. Is this a matter of explicitly naming
dependsOn
perhaps?
m
yeah, I have tried with --target-dependants but it gives the same error. I have lots of dependants so listing each one is not really feasible
b
--target-dependents
should just be a flag you shouldn't need to list your dependents.... are any of your dependents
protect: true
maybe?
m
--target-dependents
gives me the same error about child resources, the only way to get Pulumi to delete it is to list every child resource using the
--target
property. None of the resources are protected
b
ahh ok so in pulumi
children
is not necessarily the same as
dependents
. For instance a
ComponentResource
can have many children but those children don't depend on the parent
ComponentResource
. Since pulumi effectively has 2 separate resource graphs. The first graph is the parent/child graph, which is the one built from the
parent
property and is used mostly for display purposes. Unless otherwise specified, the
parent
will default to the
stack
the resource belongs to or the
provider
that was used to deploy it if one was explicitly provided. The second graph is the dependency graph, which is necessarily separate because a resource can depend on more than 1 resource - so that relationship is many:1 while a parent/child relationship is 1:many. Dependencies, unless explicitly specified via the
dependsOn
property, are inferred by all of the
Output<T>
instances being passed around. So if this is by chance a
ComponentResource
that you are trying to destroy, then it might be that in order to have the
--target-dependents
function as expected you may need to explicitly specify
dependsOn: this
on all of the children as well, which will make the children explicitly dependents of the containing
ComponentResource
. If what you are trying to delete is not a
ComponentResource
, than maybe this understanding will help you spot which of the children doesn't actually depend on the resource you're trying to delete.
m
ah ok, yes this is a component resource. I have made the resources the child of the component resource, but they are not dependent so that is probably the issue.