From b0435cd5333bf48279bc8a99ebbb479307bdaae2 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 3 May 2018 10:54:20 -0700 Subject: [PATCH] core: ProviderConfigTransformer properly locates parent module Due to a logic error here we were trying to find our our module's parent as a descendent of itself, rather than as a descendent of the root. It turns out that we can do this even more simply by just accessing the Parent field on the given config, avoiding the need to traverse the tree down from the root at all. While here, this also switches to using the path.Call helper method rather than manually slicing the path array, since this better communicates our intent. --- terraform/transform_provider.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/terraform/transform_provider.go b/terraform/transform_provider.go index 3b02791fb..97fd38ac5 100644 --- a/terraform/transform_provider.go +++ b/terraform/transform_provider.go @@ -510,12 +510,13 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi return nil } - parentPath, callName := path[:len(path)-1], path[len(path)-1] - parent := c.Descendent(parentPath) + parentPath, callAddr := path.Call() + parent := c.Parent if parent == nil { return nil } + callName := callAddr.Name var parentCfg *configs.ModuleCall for name, mod := range parent.Module.ModuleCalls { if name == callName {