diff --git a/changelogs/fragments/7535-terraform-fix-multiline-string-handling-in-complex-variables.yml b/changelogs/fragments/7535-terraform-fix-multiline-string-handling-in-complex-variables.yml new file mode 100644 index 0000000000..b991522dd6 --- /dev/null +++ b/changelogs/fragments/7535-terraform-fix-multiline-string-handling-in-complex-variables.yml @@ -0,0 +1,2 @@ +bugfixes: + - "terraform - fix multiline string handling in complex variables (https://github.com/ansible-collections/community.general/pull/7535)." diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index 27870b5b7c..cb6755efb8 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -514,7 +514,7 @@ def main(): def format_args(vars): if isinstance(vars, str): - return '"{string}"'.format(string=vars.replace('\\', '\\\\').replace('"', '\\"')) + return '"{string}"'.format(string=vars.replace('\\', '\\\\').replace('"', '\\"')).replace('\n', '\\n') elif isinstance(vars, bool): if vars: return 'true'