diff --git a/terraform/graph_config_node_output.go b/terraform/graph_config_node_output.go index 6a3533e37..0d84a7862 100644 --- a/terraform/graph_config_node_output.go +++ b/terraform/graph_config_node_output.go @@ -61,6 +61,11 @@ func (n *GraphNodeConfigOutput) Proxy() bool { return true } +// GraphNodeDestroyEdgeInclude impl. +func (n *GraphNodeConfigOutput) DestroyEdgeInclude() bool { + return false +} + // GraphNodeFlattenable impl. func (n *GraphNodeConfigOutput) Flatten(p []string) (dag.Vertex, error) { return &GraphNodeConfigOutputFlat{ diff --git a/terraform/transform_destroy.go b/terraform/transform_destroy.go index b64f930d6..a3fe737af 100644 --- a/terraform/transform_destroy.go +++ b/terraform/transform_destroy.go @@ -45,6 +45,13 @@ type GraphNodeDestroyPrunable interface { DestroyInclude(*ModuleDiff, *ModuleState) bool } +// GraphNodeEdgeInclude can be implemented to not include something +// as an edge within the destroy graph. This is usually done because it +// might cause unnecessary cycles. +type GraphNodeDestroyEdgeInclude interface { + DestroyEdgeInclude() bool +} + // DestroyTransformer is a GraphTransformer that creates the destruction // nodes for things that _might_ be destroyed. type DestroyTransformer struct{} @@ -102,11 +109,9 @@ func (t *DestroyTransformer) transform( // Inherit all the edges from the old node downEdges := g.DownEdges(v).List() for _, edgeRaw := range downEdges { - // Don't inherit proxies. These are currently variables and - // outputs and don't affect destroys. In the future we should - // probably make this more obvious somehow (another interface?). - // Right now I'm not sure how. - if _, ok := edgeRaw.(GraphNodeProxy); ok { + // If this thing specifically requests to not be depended on + // by destroy nodes, then don't. + if i, ok := edgeRaw.(GraphNodeDestroyEdgeInclude); ok && !i.DestroyEdgeInclude() { continue }