-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables wiped out #935
Comments
Hi @pmenglund 👋 Thank you for raising this and sorry you ran into trouble here. Your assessment here is correct where previously all environment variables were copied to Terraform CLI during acceptance testing. While using |
I'm using it to inject GCP credentials into the provider. Is the recommended way to templatize it and use something like this instead
|
…terraform-exec Reference: #935 When using `(tfexec.Terraform).SetEnv()`, it will no longer copy `os.Environ()`. It is also not possible for the code to call `tfexec.CleanEnv(os.Environ())` with the additional environment variable as it would strip previously accepted `TF_VAR_` environment variables. There are no plans to change this behavior in terraform-exec.
…terraform-exec Reference: #935 When using `(tfexec.Terraform).SetEnv()`, it will no longer copy `os.Environ()`. It is also not possible for the code to call `tfexec.CleanEnv(os.Environ())` with the additional environment variable as it would strip previously accepted `TF_VAR_` environment variables. There are no plans to change this behavior in terraform-exec.
…terraform-exec (#937) Reference: #935 When using `(tfexec.Terraform).SetEnv()`, it will no longer copy `os.Environ()`. It is also not possible for the code to call `tfexec.CleanEnv(os.Environ())` with the additional environment variable as it would strip previously accepted `TF_VAR_` environment variables. There are no plans to change this behavior in terraform-exec.
Reference: hashicorp/terraform-plugin-sdk#935 With github.com/hashicorp/terraform-plugin-sdk/[email protected]: ```console $ TF_ACC=1 go test -count=1 -run='TestAccFrameworkResourceUser_TF_VAR_Environment_Variable' -v ./internal/frameworkprovider/ === RUN TestAccFrameworkResourceUser_TF_VAR_Environment_Variable resource_user_test.go:117: Step 1/1 error: Error running pre-apply refresh: variable "framework_user_name" was required but not supplied --- FAIL: TestAccFrameworkResourceUser_TF_VAR_Environment_Variable (0.56s) FAIL FAIL github.com/hashicorp/terraform-provider-corner/internal/frameworkprovider 1.324s FAIL ``` Passes with hashicorp/terraform-plugin-sdk#937.
Reference: hashicorp/terraform-plugin-sdk#935 With github.com/hashicorp/terraform-plugin-sdk/[email protected]: ```console $ TF_ACC=1 go test -count=1 -run='TestAccFrameworkResourceUser_TF_VAR_Environment_Variable' -v ./internal/frameworkprovider/ === RUN TestAccFrameworkResourceUser_TF_VAR_Environment_Variable resource_user_test.go:117: Step 1/1 error: Error running pre-apply refresh: variable "framework_user_name" was required but not supplied --- FAIL: TestAccFrameworkResourceUser_TF_VAR_Environment_Variable (0.56s) FAIL FAIL github.com/hashicorp/terraform-provider-corner/internal/frameworkprovider 1.324s FAIL ``` Passes with hashicorp/terraform-plugin-sdk#937.
Reference: hashicorp/terraform-plugin-sdk#935 With github.com/hashicorp/terraform-plugin-sdk/[email protected]: ```console $ TF_ACC=1 go test -count=1 -run='TestAccFrameworkResourceUser_TF_VAR_Environment_Variable' -v ./internal/frameworkprovider/ === RUN TestAccFrameworkResourceUser_TF_VAR_Environment_Variable resource_user_test.go:117: Step 1/1 error: Error running pre-apply refresh: variable "framework_user_name" was required but not supplied --- FAIL: TestAccFrameworkResourceUser_TF_VAR_Environment_Variable (0.56s) FAIL FAIL github.com/hashicorp/terraform-provider-corner/internal/frameworkprovider 1.324s FAIL ```
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
In 1c932cf this change was made:
internal/plugintest/helper.go
:Which now causes the environment to be wiped, as once
tf.SetEnv()
is called it no longer copiesos.Environ
Reverting back to v2.12.0 fixes the issue.
SDK version
Relevant provider source code
n/a
Terraform Configuration Files
Set the environment variable
TF_VAR_TESTING
and useDebug Output
Expected Behavior
The environment variable
TF_VAR_TESTING
should be availableActual Behavior
Steps to Reproduce
References
Introduced in 1c932cf
The text was updated successfully, but these errors were encountered: