From 51f7a8e801dcc5815de5436e96a5875f276f983a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:01:02 +0000 Subject: [PATCH] Remove non-UTF-8 data from module output (#2386) (#2392) This is a backport of PR #2386 as merged into main (a39b3e0). SUMMARY Fixes #2307. Ansible previously generated warning is module output contained non UTF-8 data. Starting with version 2.18, it now throws an error, which prevents successful execution of lambda module. ISSUE TYPE Bugfix Pull Request COMPONENT NAME lambda ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis --- changelogs/fragments/2386-lambda-remove-non-utf-8-output.yml | 2 ++ plugins/modules/lambda.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/2386-lambda-remove-non-utf-8-output.yml diff --git a/changelogs/fragments/2386-lambda-remove-non-utf-8-output.yml b/changelogs/fragments/2386-lambda-remove-non-utf-8-output.yml new file mode 100644 index 00000000000..14334c3939f --- /dev/null +++ b/changelogs/fragments/2386-lambda-remove-non-utf-8-output.yml @@ -0,0 +1,2 @@ +bugfixes: + - lambda - Remove non UTF-8 data (contents of Lambda ZIP file) from the module output to avoid Ansible error (https://github.com/ansible-collections/amazon.aws/issues/2386). diff --git a/plugins/modules/lambda.py b/plugins/modules/lambda.py index 3936850ca0e..fd38a3cc35a 100644 --- a/plugins/modules/lambda.py +++ b/plugins/modules/lambda.py @@ -808,6 +808,9 @@ def main(): module.fail_json(msg="Unable to get function information after updating") response = format_response(response) # We're done + # "ZipFile" attribute contains non UTF-8 data. Ansible considers it an error + # starting with version 2.18. Removing it from the output avoids the error. + code_kwargs.pop("ZipFile", None) module.exit_json(changed=changed, code_kwargs=code_kwargs, func_kwargs=func_kwargs, **response) # Function doesn't exist, create new Lambda function