Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Allow terraform module to specify complex variable structures #4797
Allow terraform module to specify complex variable structures #4797
Changes from 20 commits
ab08a48
921414a
50888d2
cbdad6b
760e85e
8680f57
52b1de1
0f35b78
7252ec1
85c58f5
217795c
d9d468b
5a8c29f
eefbae9
960c902
c73f2ac
0b941e4
1e13d3a
7d57fa3
267ff86
24ef92f
ed372b8
acd61bd
dc9ded7
f7b2aa7
eb3bcd6
38b104f
3dbab72
eafc630
0782937
1def1ec
980faa1
738597b
53c7887
9f3063a
ab0b1ab
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should better use
json.dumps()
here, otherwise there will be problems with properly escaping quotes and other things.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although
json.dumps()
do encode special characters, so is theshlex_quote()
. Terraform did not like the double encapsulation, although the code/commands work without fail, it did not pass the correct string from ansible to terraform. I created a test case in https://github.com/kosalaat/terrafrom-tests using terraform null_resource, which now test all the scenarios, including checking whether string are passed in intact.Is there a way we can make this part of the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the above TF workfiles, the following ansible playbooks works:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean. There is no
shlex_quote()
involved anywhere (with the variables you are touching).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if
string
happens to bea"b
here? Then terraform will get passed"a"b"
. I'm pretty sure it will not be happy with that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's not.
shlex_quote()
insiderun_command()
will sort that out. More explanation in the next comment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still wondering how strings containing
"
will be handled. Simply adding quotes around them is probably not ok?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to look at https://www.terraform.io/language/expressions/strings#escape-sequences to see how to correctly quote strings.