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