-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Cant pass a list as a command line argument #17032
Comments
Hi @red8888, Your last example is correct (and works) for most unix shells. Does it work if you escape the double quotes with backticks? (though IIRC, PowerShell should preserve double quotes within single quote, so I'm not sure where the quotes are going in this case)
|
nope: btw this doesn't work for cmd either. PS has a literal escape thing that should work but this doesn't work either: for some reason it keeps putting the quotes on the outside of the brackets it seems |
could this be a bug with the windows exe? |
Can you run the command with |
ok!
|
well this is horrid, but using that niffy trace seems like this actually works: |
I guess that solves it but I still think the exe itself is doing something funky. |
Hi @red8888, I'm sure there's some special escaping logic to deal with windows execution, but that is entirely outside Teraform. There might not be anything we can do about it, but I did just think of one last thing we can check to narrow down the scope. Can you try setting Thanks! |
This reminds me of #11112, which was another issue where PowerShell was not parsing the command line in the way we expected. Unfortunately when the Terraform team tests on Windows we tend to use When working on #11112 I referred to Solve Problems with External Command Lines in PowerShell, which includes some different ways to figure out how PowerShell is parsing a particular command line. I think @red8888 is correct that there's some additional weirdness here due to the fact that command lines on Windows are not usually pre-tokenized by the shell (when PowerShell isn't in use) and so Go does some extra work on Windows to try to create a "Unix-like" I found some useful guidance in PowerShell and external commands done right, which includes an explanation of why the quotes vanished in the original command line described here, and some techniques to mitigate it. Unfortunately I don't have a lot of hope for a great answer here, since we're at the mercy of PowerShell's logic for re-serializing the parsed command line. 😖 For now, it's probably best to use Perhaps there is some possibility to write a PowerShell cmdlet than can wrap Terraform and make it more PowerShell-friendly, but this isn't something we (the Terraform Team at HashiCorp) have the expertise to do, so unfortunately we'd need to delegate that to the community. 😞 |
I'm having a similar issue with Linux cli.
Is there a reason for that?
and transforms into What are your thoughts on that @apparentlymart ? The only workaround I could come up is to create a temporarily tfvar file. |
Hi @thalesac! In Unix shells, quotes are interpreted by the shell to override the default behavior of splitting arguments with whitespace, and so the first "level" of quotes is consumed by the shell and thus isn't passed to Terraform at all. The first example works because the Unfortunately all of these behaviors are built into the shell and Terraform cannot do anything to disable or customize them. Placing the whole argument in single quotes as in your first example is the most robust method. (Note that Terraform doesn't support single quotes as string delimiters in its expression language, so the quotes passes literally to Terraform must always be double quotes.) |
I used this ways and works well with latest version of Terraform |
this still does not work for me.. any hints? |
I had a similar issue when running terraform 0.11 on my Mac. |
Well, that worked for me. Windows 10, version 2004 - PS version 7.0.3 Ugly, but it works.. |
Still not working in 0.14.3, no way to pass a list of strings from command line.
|
Testing SSH access depending on the CIDR block configuration. Nevertheless due to a bug in the terraform CLI: - hashicorp/terraform#17032 test execution is not possible until the bug is solved.
I want to apologize for the slow response time on this issue, and also let you know that I am bulk-closing all issues exclusively reported against Terraform 0.11.x, including this issue, because we are no longer investigating issues reported against Terraform 0.11.x. In most cases, when we try to reproduce issues reported against 0.11, we either can't reproduce them anymore, or the reporter has moved on, so we believe we can better support the Terraform user community by prioritizing more recent issues. Terraform 0.12 has been available since May of 2019, and there are really significant benefits to adopting it. I know that migrating from 0.11 to versions past 0.12 can require a bit of effort, but it really is worth it, and the upgrade path is pretty well understood in the community by now. 0.14 is available and stable, and we are quickly approaching an 0.15 release. We have made a significant effort in the last year to stay on top of bug reports; we have triaged almost all new bug reports within 1-2 weeks for 6+ months now. If you are still experiencing this problem, please submit a new bug report with a reproduction case that works on 0.14.x, link this old issue for context, and we will triage it. |
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
various command line attempts (powershell)
The text was updated successfully, but these errors were encountered: