Init vars escape issue
See original GitHub issueWhen backend-config is passed to a subprocess with init_vars it is not properly escaped. Example
import tftest
import logging
logging.basicConfig(level=logging.DEBUG)
if __name__ == "__main__":
tf = tftest.TerraformTest('.', None, "terraform")
backend_config = {
"bucket": "bucket_name",
"key": "dummy.tfstate",
"region": "us-east-1",
}
tf.setup(init_vars=backend_config, cleanup_on_exit=False)
Output
DEBUG:tftest:['init', ('-no-color', '-input=false', "-backend-config='bucket=bucket_name'", "-backend-config='key=dummy.tfstate'", "-backend-config='region=us-east-1'")]
CRITICAL:tftest:Error running command init: 1 Initializing modules...
Downloading git::ssh://...
...
Initializing the backend...
Error: Invalid backend configuration argument
The backend configuration argument "'bucket" given on the command line is not
expected for the selected backend type.
Error: Invalid backend configuration argument
The backend configuration argument "'key" given on the command line is not
expected for the selected backend type.
Error: Invalid backend configuration argument
The backend configuration argument "'region" given on the command line is not
expected for the selected backend type.
Traceback (most recent call last):
File "pr.py", line 14, in <module>
tf.setup(init_vars=backend_config, cleanup_on_exit=False)
File "/Users/vtk/.virtualenvs/qa/lib/python3.7/site-packages/tftest.py", line 309, in setup
return self.init(plugin_dir=plugin_dir, init_vars=init_vars, backend=backend)
File "/Users/vtk/.virtualenvs/qa/lib/python3.7/site-packages/tftest.py", line 317, in init
return self.execute_command('init', *cmd_args).out
File "/Users/vtk/.virtualenvs/qa/lib/python3.7/site-packages/tftest.py", line 397, in execute_command
raise TerraformTestError(message)
tftest.TerraformTestError: Error running command init: 1 Initializing modules...
Downloading git::ssh://...
...
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Issue with escaping variables - Terraform - HashiCorp Discuss
I am using vRA provider in my TF code and passing several variables via bash command line, these variables will then be passed...
Read more >escaping closure captures mutating 'self' parameter" in init()?
As the error said, in the escaping closure, you're capturing and mutating self (actually self.toggle ). This is not allowed. Even if you...
Read more >bash - Escape a variable for use as content of another script
I couldn't find any related question that isn't about how to escape variables for direct consumption within a script or by other programs....
Read more >Cannot use $ character in build variables (#17069) - GitLab
Having users aware that they need to escape the $ with static warning message, or some dynamic way only if $ is detected...
Read more >Do not escape > within a bash variable - Stack Overflow
Storing Bash code in variables is a recipe for (un)escaping bugs. Not to mention how dramatically the script's behavior can change due to ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released as v1.5.4 can you test it and see if the issue is fixed?
https://pypi.org/project/tftest/1.5.4/
You mean we should reopen this? Can you provide a simple repro?