Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda can return invalid binary data #2307

Open
1 task done
flowerysong opened this issue Sep 24, 2024 · 0 comments · May be fixed by #2386
Open
1 task done

lambda can return invalid binary data #2307

flowerysong opened this issue Sep 24, 2024 · 0 comments · May be fixed by #2386
Labels

Comments

@flowerysong
Copy link
Contributor

flowerysong commented Sep 24, 2024

Summary

module.exit_json(changed=changed, code_kwargs=code_kwargs, func_kwargs=func_kwargs, **response)
returns 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: [email protected]
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants