-
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
Can't pass a list as a cli arg: unexpected token while parsing list: IDENT #19401
Comments
Hi @arcotek-ltd! Sorry this isn't working properly. Based on the output from Terraform it looks like the quotes around After re-acquainting myself with the command line parsing rules for Windows systems I can see that single quotes are not supported as part of this scheme and that double quotes must be escaped using backslashes. I don't have a Windows system handy to test this right now but based on the rules documented there I would expect the following to work:
The difference from #17032 is that in that issue we were discussing running Terraform from PowerShell, and PowerShell imposes its own parameter parsing rules first, then sticks the parameters it parsed back together so that it can be parsed per the rules above. Because of this, when using PowerShell it's necessary to appease both PowerShell's parser and the normal command line parser, requiring additional characters as discussed there. To avoid these complexities and cross-platform differences we usually recommend passing non-trivial (i.e. list and map) variables via |
Thanks @apparentlymart. We actually want to use PowerShell, but couldn't get it to work, so we tried to simplify things by using "DOS". I'll try your suggestion and update here. Thanks. |
Mmm, not a nice experience. @apparentlymart mentioned in #17032 that they use DOS to test. May I suggest that when testing Windows, you concentrate on PowerShell over DOS. Anyway, @apparentlymart's suggestion worked in DOS, and I was able to get it to work by using backslash PowerShell has been a little harder. Referencing the answer here, I've been able to cobble together a mess:
I prefer to run CLI stuff through
The above example was one of a number of attempts, replacing backtick (PS escape character) and double-quote with the ASCII code. I also tried using back-slash and escaping that. Thanks |
Thanks for confirming that the escaping worked in the standard Windows command interpreter, @arcotek-ltd. Since we already have #17032 open for problems with powershell usage I'd like to consolidate the discussion back over there rather than having two parallel issues. Honestly the issues there are coming from how PowerShell interacts with traditional CLI processes (as opposed to its own applets) rather than anything Terraform itself can really solve -- by the time Terraform is running, PowerShell has already parsed and re-formatted all of the CLI arguments -- and so as I mentioned in the other issue I think the only strong path forward here would be to have a special Terraform PowerShell cmdlet that can work with the PowerShell API directly to extract the arguments and pass them to Terraform in a robust way. Since the usage with the standard command interpreter is now solved, I'm going to close this out and we can continue investigating PowerShell usage over in #17032. Thanks! |
@apparentlymart, could you enlighten me as to what the "PowerShell API" is that you speak of please? Thanks |
Hi @arcotek-ltd, In the discussion in the other issue there was the idea of writing a Cmdlet that could then accept arguments as cmdlet parameters and escape them properly to pass to Terraform. |
Terraform Version
Terraform v0.11.10
Terraform Configuration Files
Debug Output
Expected Behavior
I'd expect a testOutput of "value1".
Actual Behavior
Steps to Reproduce
Please list the full steps required to reproduce the issue, for example:
terraform apply -var 'myVariable=["value1"]'
Additional Context
I am trying this from the DOS (command line) prompt on Windows 10. I have tried multiple variations of quotes and nothing works, including the confirmation that I am doing it correctly, given by @jbardin in #17032.
References
The text was updated successfully, but these errors were encountered: