From 0c4c7c5a5f51557beaad43fca96b602a70b144c9 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 11 May 2018 16:53:52 -0700 Subject: [PATCH] core: Context.InitProvider must cache providers using absolute addresses Previously InitProvider was incorrectly using only the relative address, which (due to the ambiguity in the string representation of absolute vs. relative addresses) caused it to always initialize providers in the root module. Now we use the absolute address as the key, which then agrees with the Provider method and ensures that each module gets its own separate instance of each provider if explicit configuration is present. --- terraform/eval_context_builtin.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/eval_context_builtin.go b/terraform/eval_context_builtin.go index 61f35b732..a6e6f849a 100644 --- a/terraform/eval_context_builtin.go +++ b/terraform/eval_context_builtin.go @@ -105,13 +105,14 @@ func (ctx *BuiltinEvalContext) InitProvider(typeName string, addr addrs.Provider ctx.ProviderLock.Lock() defer ctx.ProviderLock.Unlock() - key := addr.String() + key := absAddr.String() p, err := ctx.Components.ResourceProvider(typeName, key) if err != nil { return nil, err } + log.Printf("[TRACE] BuiltinEvalContext: Initialized %q provider for %s", typeName, absAddr) ctx.ProviderCache[key] = p // Also fetch and cache the provider's schema.