diff --git a/terraform/node_resource_destroy.go b/terraform/node_resource_destroy.go index c5042436dde4..e8d2fe39f09c 100644 --- a/terraform/node_resource_destroy.go +++ b/terraform/node_resource_destroy.go @@ -282,12 +282,29 @@ type NodeDestroyResource struct { var ( _ GraphNodeEvalable = (*NodeDestroyResource)(nil) + // TransformReferences looks for indirect references as well, and relies + // on these two interfaces to connect them. This ensures the node is + // evaluated before the corresponding NodeModuleRemoved. + _ GraphNodeReferenceable = (*NodeDestroyResource)(nil) + _ GraphNodeSubPath = (*NodeDestroyResource)(nil) ) func (n *NodeDestroyResource) Name() string { return n.NodeAbstractResource.ResourceAddr().String() + " (clean up state)" } +// NodeDestroyResource still needs to be a GraphNodeReferenceable so that a +// NodeModuleRemoved can reference it for cleanup. +func (n *NodeDestroyResource) ReferenceableAddrs() []addrs.Referenceable { + return n.NodeAbstractResource.ReferenceableAddrs() +} + +// NodeDestroyResource still needs to be a GraphNodeSubPath so that a +// NodeModuleRemoved can reference it for cleanup. +func (n *NodeDestroyResource) Path() addrs.ModuleInstance { + return n.NodeAbstractResource.Path() +} + // GraphNodeEvalable func (n *NodeDestroyResource) EvalTree() EvalNode { // This EvalNode will produce an error if the resource isn't already