diff --git a/command/013_config_upgrade.go b/command/013_config_upgrade.go index 32e8300512..81494e8f5a 100644 --- a/command/013_config_upgrade.go +++ b/command/013_config_upgrade.go @@ -240,6 +240,11 @@ command and dealing with them before running this command again. for _, file := range files { // Step 2: add missing provider requirements from provider blocks for _, p := range file.ProviderConfigs { + // Skip internal providers + if p.Name == "terraform" { + continue + } + // If no explicit provider configuration exists for the // provider configuration's local name, add one with a legacy // provider address. @@ -266,6 +271,11 @@ command and dealing with them before running this command again. localName = r.Addr().ImpliedProvider() } + // Skip internal providers + if localName == "terraform" { + continue + } + // If no explicit provider configuration exists for this local // name, add one with a legacy provider address. if _, exist := requiredProviders[localName]; !exist { diff --git a/command/testdata/013upgrade-explicit-providers/expected/main.tf b/command/testdata/013upgrade-explicit-providers/expected/main.tf index 83d1158f47..a70002e59a 100644 --- a/command/testdata/013upgrade-explicit-providers/expected/main.tf +++ b/command/testdata/013upgrade-explicit-providers/expected/main.tf @@ -1,4 +1,4 @@ -provider foo { +provider "foo" { version = "1.2.3" } @@ -17,3 +17,5 @@ terraform { } } } + +provider "terraform" {} diff --git a/command/testdata/013upgrade-explicit-providers/input/main.tf b/command/testdata/013upgrade-explicit-providers/input/main.tf index f3c982a04d..4086225275 100644 --- a/command/testdata/013upgrade-explicit-providers/input/main.tf +++ b/command/testdata/013upgrade-explicit-providers/input/main.tf @@ -1,4 +1,4 @@ -provider foo { +provider "foo" { version = "1.2.3" } @@ -10,3 +10,5 @@ terraform { } } } + +provider "terraform" { } diff --git a/command/testdata/013upgrade-implicit-providers/expected/main.tf b/command/testdata/013upgrade-implicit-providers/expected/main.tf index 109e0699c6..82c3e837ae 100644 --- a/command/testdata/013upgrade-implicit-providers/expected/main.tf +++ b/command/testdata/013upgrade-implicit-providers/expected/main.tf @@ -1,5 +1,6 @@ -resource foo_resource b {} -resource bar_resource c {} -resource bar_resource ab { +resource "foo_resource" "b" {} +resource "bar_resource" "c" {} +resource "bar_resource" "ab" { provider = baz } +resource "terraform_remote_state" "production" {} diff --git a/command/testdata/013upgrade-implicit-providers/input/main.tf b/command/testdata/013upgrade-implicit-providers/input/main.tf index 109e0699c6..82c3e837ae 100644 --- a/command/testdata/013upgrade-implicit-providers/input/main.tf +++ b/command/testdata/013upgrade-implicit-providers/input/main.tf @@ -1,5 +1,6 @@ -resource foo_resource b {} -resource bar_resource c {} -resource bar_resource ab { +resource "foo_resource" "b" {} +resource "bar_resource" "c" {} +resource "bar_resource" "ab" { provider = baz } +resource "terraform_remote_state" "production" {}