From b1ed146931877882f3f60449432ffcd9abd5ec96 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 7 Dec 2018 15:38:11 -0800 Subject: [PATCH] core: Attach schemas to nodes created by ResourceCountTransformer Previously we were only doing this in the case where count wasn't set at all. --- terraform/node_resource_abstract.go | 9 ++++++++- terraform/transform_resource_count.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/terraform/node_resource_abstract.go b/terraform/node_resource_abstract.go index 613e1b4c8b..3a0570c5b6 100644 --- a/terraform/node_resource_abstract.go +++ b/terraform/node_resource_abstract.go @@ -182,7 +182,7 @@ func (n *NodeAbstractResource) References() []*addrs.Reference { if n.Schema == nil { // Should never happens, but we'll log if it does so that we can // see this easily when debugging. - log.Printf("[WARN] no schema is attached to %s, so references cannot be detected", n.Name()) + log.Printf("[WARN] no schema is attached to %s, so config references cannot be detected", n.Name()) } refs, _ := lang.ReferencesInExpr(c.Count) @@ -220,6 +220,13 @@ func (n *NodeAbstractResourceInstance) References() []*addrs.Reference { // embedded abstract resource, which knows how to extract dependencies // from configuration. if n.Config != nil { + if n.Schema == nil { + // We'll produce a log message about this out here so that + // we can include the full instance address, since the equivalent + // message in NodeAbstractResource.References cannot see it. + log.Printf("[WARN] no schema is attached to %s, so config references cannot be detected", n.Name()) + return nil + } return n.NodeAbstractResource.References() } diff --git a/terraform/transform_resource_count.go b/terraform/transform_resource_count.go index f886ed6ef5..11237909f3 100644 --- a/terraform/transform_resource_count.go +++ b/terraform/transform_resource_count.go @@ -43,6 +43,7 @@ func (t *ResourceCountTransformer) Transform(g *Graph) error { addr := t.Addr.Instance(key) abstract := NewNodeAbstractResourceInstance(addr) + abstract.Schema = t.Schema var node dag.Vertex = abstract if f := t.Concrete; f != nil { node = f(abstract)