From 7d07f208930495b3675e5ee9952ece0f3423efca Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 16 Sep 2016 00:05:57 -0700 Subject: [PATCH] terraform: fix references to module outputs --- terraform/node_output.go | 3 ++- terraform/transform_output.go | 7 ++++--- terraform/transform_reference.go | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/terraform/node_output.go b/terraform/node_output.go index 517a795af0..08bb892d64 100644 --- a/terraform/node_output.go +++ b/terraform/node_output.go @@ -29,7 +29,8 @@ func (n *NodeApplyableOutput) Path() []string { // GraphNodeReferenceable func (n *NodeApplyableOutput) ReferenceableName() []string { - return []string{n.Name()} + name := fmt.Sprintf("output.%s", n.Config.Name) + return []string{name} } // GraphNodeReferencer diff --git a/terraform/transform_output.go b/terraform/transform_output.go index 3e5f33986e..b163860aeb 100644 --- a/terraform/transform_output.go +++ b/terraform/transform_output.go @@ -4,6 +4,7 @@ import ( "log" "github.com/hashicorp/terraform/config/module" + "github.com/hashicorp/terraform/dag" ) // OutputTransformer is a GraphTransformer that adds all the outputs @@ -48,7 +49,7 @@ func (t *OutputTransformer) transform(g *Graph, m *module.Tree) error { for _, o := range os { // Build the node node := &NodeApplyableOutput{ - PathValue: m.Path(), + PathValue: normalizeModulePath(m.Path()), Config: o, } @@ -59,10 +60,10 @@ func (t *OutputTransformer) transform(g *Graph, m *module.Tree) error { // If the node references nothing, we always include it since there // is no other clear time to compute it. matches, missing := refMap.References(node) - if len(matches) == 0 || len(missing) > 0 { + if len(missing) > 0 { log.Printf( "[INFO] Not including %q in graph, matches: %v, missing: %s", - node, matches, missing) + dag.VertexName(node), matches, missing) continue } diff --git a/terraform/transform_reference.go b/terraform/transform_reference.go index 0f061dda6f..c678091b04 100644 --- a/terraform/transform_reference.go +++ b/terraform/transform_reference.go @@ -101,7 +101,7 @@ func NewReferenceMap(vs []dag.Vertex) *ReferenceMap { var prefix string if pn, ok := v.(GraphNodeSubPath); ok { if path := normalizeModulePath(pn.Path()); len(path) > 1 { - prefix = modulePrefixStr(path[1:]) + "." + prefix = modulePrefixStr(path) + "." } }