From 67279e7ca157f41f9a01a64206722afe460c8eed Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 24 Nov 2023 21:47:58 +0100 Subject: [PATCH] [PR #7535/af5da7d4 backport][stable-7] fix(modules/terraform): handle multiline strings correctly in complex variables (#7598) fix(modules/terraform): handle multiline strings correctly in complex variables (#7535) (cherry picked from commit af5da7d412a6d1e262715a05d40e091d8ed6b08b) Co-authored-by: Yann Soubeyrand --- ...aform-fix-multiline-string-handling-in-complex-variables.yml | 2 ++ plugins/modules/terraform.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/7535-terraform-fix-multiline-string-handling-in-complex-variables.yml 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'