-
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
v0.12: TF_VAR_ environment not being used to override default values #153
Comments
Hi @alexng-canuck! My initial instinct was to flag this as a CLI bug, but on re-read I think it may actually be a testing-specific issue, but I'd like to learn a bit more about what you are doing so I can confirm: Are you setting this environment variable and then running the acceptance tests, expecting the acctests to pick it up? This is not something we ever intentionally supported, and I guess it was working before only because that bit of logic happened to be inside the We don't have any reasonable way to reinstate the previous unintended behavior of supporting these environment variables during testing. Moving this back to where it was in 0.11 would prevent the improved error messages that motivated this change, and I think the only other option would be to duplicate a bunch of that behavior into the test harness itself, which would risk it drifting in behavior from the main mechanism over time. Rather than relying on |
Thanks @apparentlymart
That is precisely what we are doing. While we can introduce a workaround in test code to use |
The handling of environment variables is a Terraform Core feature and thus Terraform Core's responsibility to test, so provider developers shouldn't feel compelled to repeat those same tests. With that said, one of the ideas we are exploring for the forthcoming SDK revamp is to run acceptance tests through a real build of the Terraform CLI rather than by using Terraform as a library. The main motivation for that is to allow the same provider code to be tested against multiple different Terraform versions without modification, but depending on how it is implemented it may also permit configuring the environment for a specific test to test how Terraform behaves. I think the goal would still be for the test to explicitly choose the |
v0.12 introduced new behavior where test framework no longer applies TF_VAR environment variables automatically. This is a workaround for this issue: https://github.com/hashicorp/terraform/issues/21162
I am possibly also seeing this error after updating to terraform Here is my failed build and the diff. https://travis-ci.org/nukosuke/terraform-provider-zendesk/jobs/537885423 Diff is here. nukosuke/terraform-provider-zendesk@c417e18...efe8126. |
I imagine this regression is breaking a bunch of integration tests all over the place... |
As noted before, I'm not sure what you mean by "integration tests all over the place", though. The codepath we're discussing here is only for provider acceptance tests, so it should not be affecting anything except those. |
Something like that could be used outside provider acceptance test, right?
But before all that was working fine, the fact that on latest is not working makes it a regression. |
Indeed, the Go packages inside the Terraform repository are for provider use only and are not intended as a general framework for integration tests. Third-party solutions like terratest are a better answer for testing Terraform modules, because they are built around the full Terraform lifecycle rather than supporting only a single config file given inline. |
So what exactly is our recommendation here if we have an acceptance test that is relying on environment variables at this point? |
This is fixed in #262, the new binary acceptance test driver, which can be enabled from v1.7.0 onwards. Environment variables in the acceptance test environment are now passed transparently to the |
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. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Along with this configuration, we set an environment variable called
TF_VAR_identity_provider_metadata_file
and set it to/usr/blahblahblah/sampleFederationMetadata.xml
.Debug Output
Expected Behavior
In v0.11, the
TF_VAR_
prefixed environment variable would have overridden the default value of the configuration.Actual Behavior
In v0.12, the default value is still being used, resulting in errors when passing an invalid file path to the
file()
Steps to Reproduce
terraform apply
Additional Context
This was caught via a test case that had previously worked with v0.11 plugin SDKs. In v0.12, the same test fails.
The text was updated successfully, but these errors were encountered: