diff --git a/terraform/graph_builder_apply.go b/terraform/graph_builder_apply.go index 292e8414a7..a9aba06bb9 100644 --- a/terraform/graph_builder_apply.go +++ b/terraform/graph_builder_apply.go @@ -168,16 +168,10 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer { Config: b.Config, State: b.State, Schemas: b.Schemas, - Destroy: b.Destroy, }, - GraphTransformIf( - func() bool { return b.Destroy }, - GraphTransformMulti( - // Create a destroy node for outputs to remove them from the state. - &DestroyOutputTransformer{}, - ), - ), + // Create a destroy node for outputs to remove them from the state. + &DestroyOutputTransformer{Destroy: b.Destroy}, // Prune unreferenced values, which may have interpolations that can't // be resolved. diff --git a/terraform/transform_destroy_cbd.go b/terraform/transform_destroy_cbd.go index 40474a0b4d..0bfcda96ee 100644 --- a/terraform/transform_destroy_cbd.go +++ b/terraform/transform_destroy_cbd.go @@ -134,16 +134,9 @@ type CBDEdgeTransformer struct { // obtain schema information from providers and provisioners so we can // properly resolve implicit dependencies. Schemas *Schemas - - // If the operation is a simple destroy, no transformation is done. - Destroy bool } func (t *CBDEdgeTransformer) Transform(g *Graph) error { - if t.Destroy { - return nil - } - // Go through and reverse any destroy edges for _, v := range g.Vertices() { dn, ok := v.(GraphNodeDestroyerCBD) diff --git a/terraform/transform_output.go b/terraform/transform_output.go index ed93cdb873..f68228b384 100644 --- a/terraform/transform_output.go +++ b/terraform/transform_output.go @@ -60,9 +60,15 @@ func (t *OutputTransformer) transform(g *Graph, c *configs.Config) error { // outputs during destroy. We need to do this to ensure that no stale outputs // are ever left in the state. type DestroyOutputTransformer struct { + Destroy bool } func (t *DestroyOutputTransformer) Transform(g *Graph) error { + // Only clean root outputs on a full destroy + if !t.Destroy { + return nil + } + for _, v := range g.Vertices() { output, ok := v.(*NodeApplyableOutput) if !ok {