-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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 -var-file not working for file present in the same directory #11112
Comments
Hi @Snehac! Sorry for the silence here. Usually this error message reflects the entire filename provided, so it's strange that for you it is showing just "cert" rather than "cert.tf". For example, here's the error message I got when I intentionally ran with a missing cert.tf:
So this suggests either that the command line was somehow parsed incorrectly or that there was an extra space or other separator character before the Note also that files passed to Can you confirm that this issue is still occurring for you? |
Hi @apparentlymart . Thanks for getting back to me. i created a cert.tfvars file and tried apply it . but same results.
|
Hi @Snehac! This latest message seems to be different than the one you shared before. In this case it looks like Terraform did indeed succeed in opening the file, but it failed to process it. From the name it sounds like it'll have sensitive information in it, but if you could share an example of that file with all of the string values removed (still showing as much of the structure as possible) that would help understand what Terraform is complaining about. |
Hello @apparentlymart , So i finally had a conclusive observation. When i am running the command on powershell we hit the first issue: POWERSHELL OUTPUT:
I tried the same on git bash i see this : $ terraform apply -var-file=cert.tf |
Thanks for that, @Snehac. Just to confirm: I see you using |
It looks like PowerShell parses command lines in a different way that causes it to, for some reason, truncate the file extension from the filename: I'm going to look deeper into why that is, but for now the workaround is to type the filename in quotes to help PowerShell's parser understand that it should be treated as a single, literal unit. |
After some more investigation, I've learned that PowerShell parses the unquoted command line into elements like this:
It doesn't seem like there's anything we can do to change how PowerShell interprets this command line. Powershell users must just always enclose arguments in quotes to avoid PowerShell breaking them. Since this seems to be standard PowerShell behavior and there's nothing we can do about it, I'm going to close this. Thanks for your patience working through this with me, @Snehac! |
Hello @apparentlymart, Putting the value in double quotes worked for me today, thanks!
Onwards! |
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. |
I am trying to pass file name as command Line argument and following the examples i found on internet. following is the command i am using :
terraform plan -var-file=cert.tf
and get the following error:
invalid value "cert" for flag -var-file: Error reading cert: open cert: The system cannot find the file specified
Cert.tf is present in the same path where i am executing the command. I am using Windows machine and terraform --version is 0.8.2.
This might not be the right place to ask this .. But i am not getting help from anywhere else
The text was updated successfully, but these errors were encountered: