-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Terraform not loading auto.tfvars when executed with a directory #25558
Comments
Hi @mkielar, In cases where you run Terraform against a configuration somewhere other than the current working directory, Terraform still looks in the current working directory for non-configuration files like the For that reason, it seems like Terraform is working as intended here: I expect Terraform would still read the We're not intending to change this behavior because the capability to select a different configuration directory than the current working directory is already largely a legacy capability, which has a number of limitations. The main supported way to run Terraform is to switch current working directory to the root module directory first and then run |
Legacy. Hm. That's bad news, but let me explain the use case anyway. We're running multiple validations of Terraform code in our CICD Pipeline (terraform validate, tflint, tfsec). Then they report errors, relative to the directory they are called from. An example with
versus
Note in the second output, the path to
For This is just awkward, and considering your "legacy" comment, I'm wondering if the |
I agree with the above, we also have a use case where being able to say "look in the directory passed for the var files instead of the working directory" would be very valuable. It is also what I, at least, intuitively thought the behaviour would be without digging through the docs and interpreting them very literally. |
#26087 looks very promising for this issue, assuming that it the If someone can confirm that |
For anyone else arriving here 4 years too late: is the issue here as simple as |
Terraform Version
Terraform Configuration Files
See terraform_test_case.zip
Expected Behavior
Terraform should load the
dev.auto.tfvars
file from specified path when ran with directory argument.Actual Behavior
When I run
terraform apply <dir>
, terraform does not automatically loadauto.tfvars
in that dir and instead asks me to provide values for variables:Steps to Reproduce
The text was updated successfully, but these errors were encountered: