From e417d796a0dc4c7206abeefd6c29ab615da9470f Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 18 Feb 2021 10:17:56 -0500 Subject: [PATCH] don't add duplicate proxy provider nodes Fix the logic to add proxy provider nodes for implicitly passed in providers. The missing continue allowed multiple nodes satisfying the same provider address to be added to the graph. When attaching the providers to resources, the fist one encountered would be used, which could change each time the graph was built. --- terraform/transform_provider.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/terraform/transform_provider.go b/terraform/transform_provider.go index f8f390b0ab..ce8ac120e7 100644 --- a/terraform/transform_provider.go +++ b/terraform/transform_provider.go @@ -227,7 +227,7 @@ func (t *ProviderTransformer) Transform(g *Graph) error { break } - // see if this in an inherited provider + // see if this is a proxy provider pointing to another concrete config if p, ok := target.(*graphNodeProxyProvider); ok { g.Remove(p) target = p.Target() @@ -708,10 +708,13 @@ func (t *ProviderConfigTransformer) addProxyProviders(g *Graph, c *configs.Confi concreteProvider := t.providers[fullName] - // replace the concrete node with the provider passed in - if concreteProvider != nil && t.proxiable[fullName] { - g.Replace(concreteProvider, proxy) - t.providers[fullName] = proxy + // replace the concrete node with the provider passed in only if it is + // proxyable + if concreteProvider != nil { + if t.proxiable[fullName] { + g.Replace(concreteProvider, proxy) + t.providers[fullName] = proxy + } continue }