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 90948cd50b..f6190493d1 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -513,7 +513,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'