From a2cbd40f84adae95c9606bce30030bcc887169f6 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 9 Jan 2020 14:00:45 -0500 Subject: [PATCH] NodeDestroyResource needs to be referencable The change in #23696 removed the NodeAbstractResource methods from the NodeDestroyResource type, in order to prevent other resource behaviors, like requesting a provider. While this node type is not directly referenced, it was implicitly ordered against the module cleanup by virtue of being a resource node. The ReferenceTransformer uses the GraphNodeReferenceable and GraphNodeSubPath interfaces to add nodes to the reference map, so we need to re-add the relevant methods. Since there's no good entry point to test this ordering at the moment, --- terraform/node_resource_destroy.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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