From b9fa724273d4627c29d0c41850c6c1b558b30864 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Tue, 13 Aug 2019 10:24:26 -0400 Subject: [PATCH] Add edge --- terraform/transform_orphan_count.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/terraform/transform_orphan_count.go b/terraform/transform_orphan_count.go index ab268ff38..029fa9a92 100644 --- a/terraform/transform_orphan_count.go +++ b/terraform/transform_orphan_count.go @@ -51,7 +51,8 @@ func (t *OrphanResourceCountTransformer) Transform(g *Graph) error { func (t *OrphanResourceCountTransformer) transformForEach(haveKeys map[addrs.InstanceKey]struct{}, g *Graph) error { // If there is a no-key node, add this to the graph first, - // because the last item determines the resource mode for the whole resource, + // so that we can create edges to it in subsequent (StringKey) nodes. + // This is because the last item determines the resource mode for the whole resource, // so if this (non-deterministically) happens to end up as the last one, // that will change the resource's EachMode and our addressing for our instances // will not work as expected @@ -79,6 +80,11 @@ func (t *OrphanResourceCountTransformer) transformForEach(haveKeys map[addrs.Ins } log.Printf("[TRACE] OrphanResourceCount(non-zero): adding %s as %T", t.Addr, node) g.Add(node) + + // Add edge to noKeyNode if it exists + if hasNoKeyNode { + g.Connect(dag.BasicEdge(node, noKeyNode)) + } } return nil }