`lambda` can return invalid binary data
flowerysong opened this issue · 0 comments
flowerysong commented
Summary
amazon.aws/plugins/modules/lambda.py
Line 811 in 8592624
code_kwargs
, which contains the raw binary zip file when this module is invoked with zip_file
and code changes are made. Modules are only supposed to return text data encoded with UTF-8, so this can generate a warning in recent versions of ansible-core
that will become a hard error in 2.18.
This doesn't seem like a particularly useful thing to return, but if you want to continue returning it you should encode the binary data as base64.
Issue Type
Bug Report
Component Name
lambda
Ansible Version
$ ansible --version
ansible [core 2.17.4]
config file = /home/ec2-user/ansible-aws/ansible/ansible.cfg
configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ansible
ansible collection location = /home/ec2-user/ansible-aws/ansible/collections
executable location = /home/ec2-user/ansible-aws/.venv/bin/ansible
python version = 3.12.1 (main, Feb 19 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/home/ec2-user/ansible-aws/.venv/bin/python)
jinja version = 3.1.4
libyaml = True
Collection Versions
$ ansible-galaxy collection list
Collection Version
------------------- -------
amazon.aws 8.2.1
ansible.netcommon 7.1.0
ansible.posix 1.6.0
ansible.utils 5.1.1
community.aws 8.0.0
community.crypto 2.22.0
community.general 9.4.0
community.zabbix 3.1.2
flowerysong.hvault 0.3.0
flowerysong.melange 1.1.0
sensu.sensu_go 1.12.0
AWS SDK versions
$ pip show boto boto3 botocore
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: mitch@garnaat.com
License: MIT
Location: /home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.35.25
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.35.25
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: awscli, boto3, s3transfer
Configuration
$ ansible-config dump --only-changed
ANSIBLE_PIPELINING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
COLLECTIONS_PATHS(env: ANSIBLE_COLLECTIONS_PATH) = ['/home/ec2-user/ansible-aws/ansible/collections']
CONFIG_FILE() = /home/ec2-user/ansible-aws/ansible/ansible.cfg
DEFAULT_ACTION_PLUGIN_PATH(env: ANSIBLE_ACTION_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/action']
DEFAULT_BECOME(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = sudo
DEFAULT_CALLBACK_PLUGIN_PATH(env: ANSIBLE_CALLBACK_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/callback']
DEFAULT_GATHERING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = explicit
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = ['/home/ec2-user/ansible-aws/ansible/inventory_nonprod']
DEFAULT_JINJA2_NATIVE(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_LOOKUP_PLUGIN_PATH(env: ANSIBLE_LOOKUP_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/lookup']
DEFAULT_REMOTE_USER(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = ec2-user
DEVEL_WARNING(env: ANSIBLE_DEVEL_WARNING) = False
EDITOR(env: EDITOR) = vim
HOST_KEY_CHECKING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
INJECT_FACTS_AS_VARS(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = /usr/local/venv/system/bin/python3
INVENTORY_ENABLED(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = ['auto', 'yaml', 'ini']
RETRY_FILES_ENABLED(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
OS / Environment
No response
Steps to Reproduce
- hosts: localhost
tasks:
- name: Create zip archive
community.general.archive:
dest: /var/tmp/lambda.zip
path: /etc/services
format: zip
- name: Create lambda function
amazon.aws.lambda:
region: us-east-2
profile: vdc-nonprod
name: umcollab_test
role: umcollab_lambda_basic
src: /var/tmp/lambda.zip
runtime: python3.12
handler: helloworld
- name: Create zip archive
community.general.archive:
dest: /var/tmp/lambda_update.zip
path: /etc/protocols
format: zip
- name: Update lambda function
amazon.aws.lambda:
region: us-east-2
profile: vdc-nonprod
name: umcollab_test
role: umcollab_lambda_basic
src: /var/tmp/lambda_update.zip
runtime: python3.12
handler: helloworld
Expected Results
No warnings.
Actual Results
PLAY [localhost] ***************************************************************
TASK [Create zip archive] ******************************************************
changed: [localhost]
TASK [Create lambda function] **************************************************
changed: [localhost]
TASK [Create zip archive] ******************************************************
changed: [localhost]
TASK [Update lambda function] **************************************************
[DEPRECATION WARNING]: Module "amazon.aws.lambda" returned non UTF-8 data in
the JSON response. This will become an error in the future. This feature will
be removed in version 2.18. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
changed: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=4 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Code of Conduct
- I agree to follow the Ansible Code of Conduct