diff --git a/.changelog/pending.txt b/.changelog/pending.txt new file mode 100644 index 0000000000..2f2e7bb891 --- /dev/null +++ b/.changelog/pending.txt @@ -0,0 +1,3 @@ +```release-note:bug +helper/resource: Prevented regression since 2.13.0 with the removal of environment variables, including `TF_VAR_*`, when calling Terraform CLI commands +``` diff --git a/helper/resource/plugin.go b/helper/resource/plugin.go index 013adbe9e3..b1c26d11e0 100644 --- a/helper/resource/plugin.go +++ b/helper/resource/plugin.go @@ -43,6 +43,14 @@ func runProviderCommand(ctx context.Context, t testing.T, f func() error, wd *pl // plugins. os.Setenv("PLUGIN_PROTOCOL_VERSIONS", "5") + // Acceptance testing does not need to call checkpoint as the output + // is not accessible, nor desirable if explicitly using + // TF_ACC_TERRAFORM_PATH or TF_ACC_TERRAFORM_VERSION environment variables. + // + // Avoid calling (tfexec.Terraform).SetEnv() as it will stop copying + // os.Environ() and prevents TF_VAR_ environment variable usage. + os.Setenv("CHECKPOINT_DISABLE", "1") + // Terraform 0.12.X and 0.13.X+ treat namespaceless providers // differently in terms of what namespace they default to. So we're // going to set both variations, as we don't know which version of diff --git a/internal/plugintest/environment_variables.go b/internal/plugintest/environment_variables.go index e3eb626202..4aa7c57c69 100644 --- a/internal/plugintest/environment_variables.go +++ b/internal/plugintest/environment_variables.go @@ -2,9 +2,6 @@ package plugintest // Environment variables const ( - // Disables checkpoint.hashicorp.com calls in Terraform CLI. - EnvCheckpointDisable = "CHECKPOINT_DISABLE" - // Environment variable with acceptance testing temporary directory for // testing files and Terraform CLI installation, if installation is // required. By default, the operating system temporary directory is used. diff --git a/internal/plugintest/helper.go b/internal/plugintest/helper.go index d9e620f33f..a1d358c6cd 100644 --- a/internal/plugintest/helper.go +++ b/internal/plugintest/helper.go @@ -124,14 +124,6 @@ func (h *Helper) NewWorkingDir(ctx context.Context) (*WorkingDir, error) { return nil, fmt.Errorf("unable to create terraform-exec instance: %w", err) } - err = tf.SetEnv(map[string]string{ - EnvCheckpointDisable: "1", - }) - - if err != nil { - return nil, fmt.Errorf("unable to set terraform-exec environment variables: %w", err) - } - return &WorkingDir{ h: h, tf: tf,