diff --git a/terraform/graph_builder_apply.go b/terraform/graph_builder_apply.go index ffb4b477d..6cb2f56ec 100644 --- a/terraform/graph_builder_apply.go +++ b/terraform/graph_builder_apply.go @@ -165,7 +165,7 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer { // directly. A destroy is identical to a normal apply, except for the // fact that we also have configuration to evaluate. While the rest of // the unused nodes can be programmatically pruned (via - // pruneUnusedNodesTransformer), root module outputs only have an + // pruneUnusedNodesTransformer), root module outputs always have an // implied dependency on remote state. This means that if they exist in // the configuration, the only signal to remove them is via the destroy // command itself. diff --git a/terraform/transform_destroy_edge.go b/terraform/transform_destroy_edge.go index 5516d8413..1d28c1118 100644 --- a/terraform/transform_destroy_edge.go +++ b/terraform/transform_destroy_edge.go @@ -207,10 +207,10 @@ func (t *pruneUnusedNodesTransformer) Transform(g *Graph) error { modules = append(modules, mod) } - // Sort them by path length, longest first, so that start with the deepest - // modules. The order of modules at the same tree level doesn't matter, we - // just need to ensure that child modules are processed before parent - // modules. + // Sort them by path length, longest first, so that we start with the + // deepest modules. The order of modules at the same tree level doesn't + // matter, we just need to ensure that child modules are processed before + // parent modules. sort.Slice(modules, func(i, j int) bool { return len(modules[i].addr) > len(modules[j].addr) }) diff --git a/terraform/transform_output.go b/terraform/transform_output.go index b926b2fd1..d1b130c63 100644 --- a/terraform/transform_output.go +++ b/terraform/transform_output.go @@ -88,13 +88,14 @@ func (t *destroyRootOutputTransformer) Transform(g *Graph) error { deps := g.UpEdges(v) - // the destroy node must depend on the eval node - deps.Add(v) - for _, d := range deps { log.Printf("[TRACE] %s depends on %s", node.Name(), dag.VertexName(d)) g.Connect(dag.BasicEdge(node, d)) } + + // We no longer need the expand node, since we intend to remove this + // output from the state. + g.Remove(v) } return nil }