From fc7871c5ee25de2519bd2d0af422d2e71542c06d Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 8 May 2018 11:19:02 -0700 Subject: [PATCH] command/import: default provider config in same module Previously we were defaulting the provider configuration selection to a provider in the root module inferred from the resource type name. This is close, but not quite right: we need to _start_ with a provider configuration in the same module as we're importing into, and then our provider resolution steps during import graph construction will use that as a starting point for a walk up the tree to find the nearest matching configuration (which might eventually still be in the root, but not necessarily). --- command/import.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/command/import.go b/command/import.go index 700006900..8480c91ee 100644 --- a/command/import.go +++ b/command/import.go @@ -174,7 +174,10 @@ func (c *ImportCommand) Run(args []string) int { providerAddr = relAddr.Absolute(addrs.RootModuleInstance) } else { // Use a default address inferred from the resource type. - providerAddr = resourceRelAddr.DefaultProviderConfig().Absolute(addrs.RootModuleInstance) + // We assume the same module as the resource address here, which + // may get resolved to an inherited provider when we construct the + // import graph inside ctx.Import, called below. + providerAddr = resourceRelAddr.DefaultProviderConfig().Absolute(addr.Module) } // Check for user-supplied plugin path