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_execute doesn't work with function_arn instead of name #1268

Closed
1 task done
mdavis-xyz opened this issue Nov 15, 2022 · 2 comments · Fixed by #1275
Closed
1 task done

lambda_execute doesn't work with function_arn instead of name #1268

mdavis-xyz opened this issue Nov 15, 2022 · 2 comments · Fixed by #1275
Labels
bug This issue/PR relates to a bug python3 traceback

Comments

@mdavis-xyz
Copy link
Contributor

mdavis-xyz commented Nov 15, 2022

Summary

The documentation says that I can use either name or function_arn for execute_lambda. This is not the case currently, because only the name (possibly None) is passed to the waiter.

I found the line of code in my local installation of this module that's causing the issue.

wait_for_lambda(client, module, name)

Changing it to:

wait_for_lambda(client, module, name or function_arn)

fixes the issue.

But I can't see that line here in the git repo.
It's not just that this bug has been possibly fixed, but that the whole function waiting for the lambda to be updated is missing from the latest commit.
Was this functionality removed? (That would be surprising.)

The docs say version 3.6.0, which is what I'm using.

Issue Type

Bug Report

Component Name

execute_lambda

Ansible Version

$ ansible --version  -e ansible_python_interpreter=$(which python3)                                                                                                                    
ansible [core 2.13.6]
  config file = /home/ec2-user/.ansible.cfg
  configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ec2-user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ec2-user/.pyenv/versions/3.8.11/bin/ansible
  python version = 3.8.11 (default, Sep  7 2022, 04:17:12) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
  jinja version = 3.1.2
  libyaml = True

Collection Versions

# /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages/ansible_collections
Collection                    Version
----------------------------- -------
amazon.aws                    3.5.0  
ansible.netcommon             3.1.3  
ansible.posix                 1.4.0  
ansible.utils                 2.7.0  
ansible.windows               1.12.0 
arista.eos                    5.0.1  
awx.awx                       21.8.0 
azure.azcollection            1.14.0 
check_point.mgmt              2.3.0  
chocolatey.chocolatey         1.3.1  
cisco.aci                     2.3.0  
cisco.asa                     3.1.0  
cisco.dnac                    6.6.0  
cisco.intersight              1.0.20 
cisco.ios                     3.3.2  
cisco.iosxr                   3.3.1  
cisco.ise                     2.5.8  
cisco.meraki                  2.11.0 
cisco.mso                     2.1.0  
cisco.nso                     1.0.3  
cisco.nxos                    3.2.0  
cisco.ucs                     1.8.0  
cloud.common                  2.1.2  
cloudscale_ch.cloud           2.2.2  
community.aws                 3.6.0  
community.azure               1.1.0  
community.ciscosmb            1.0.5  
community.crypto              2.8.1  
community.digitalocean        1.22.0 
community.dns                 2.4.0  
community.docker              2.7.1  
community.fortios             1.0.0  
community.general             5.8.0  
community.google              1.0.0  
community.grafana             1.5.3  
community.hashi_vault         3.4.0  
community.hrobot              1.6.0  
community.libvirt             1.2.0  
community.mongodb             1.4.2  
community.mysql               3.5.1  
community.network             4.0.1  
community.okd                 2.2.0  
community.postgresql          2.3.0  
community.proxysql            1.4.0  
community.rabbitmq            1.2.3  
community.routeros            2.3.1  
community.sap                 1.0.0  
community.sap_libs            1.3.0  
community.skydive             1.0.0  
community.sops                1.4.1  
community.vmware              2.10.1 
community.windows             1.11.1 
community.zabbix              1.8.0  
containers.podman             1.9.4  
cyberark.conjur               1.2.0  
cyberark.pas                  1.0.14 
dellemc.enterprise_sonic      1.1.2  
dellemc.openmanage            5.5.0  
dellemc.os10                  1.1.1  
dellemc.os6                   1.0.7  
dellemc.os9                   1.0.4  
f5networks.f5_modules         1.20.0 
fortinet.fortimanager         2.1.6  
fortinet.fortios              2.1.7  
frr.frr                       2.0.0  
gluster.gluster               1.0.2  
google.cloud                  1.0.2  
hetzner.hcloud                1.8.2  
hpe.nimble                    1.1.4  
ibm.qradar                    2.1.0  
ibm.spectrum_virtualize       1.10.0 
infinidat.infinibox           1.3.7  
infoblox.nios_modules         1.4.0  
inspur.ispim                  1.2.0  
inspur.sm                     2.3.0  
junipernetworks.junos         3.1.0  
kubernetes.core               2.3.2  
lowlydba.sqlserver            1.0.4  
mellanox.onyx                 1.0.0  
netapp.aws                    21.7.0 
netapp.azure                  21.10.0
netapp.cloudmanager           21.21.0
netapp.elementsw              21.7.0 
netapp.ontap                  21.24.1
netapp.storagegrid            21.11.1
netapp.um_info                21.8.0 
netapp_eseries.santricity     1.3.1  
netbox.netbox                 3.8.1  
ngine_io.cloudstack           2.2.4  
ngine_io.exoscale             1.0.0  
ngine_io.vultr                1.1.2  
openstack.cloud               1.10.0 
openvswitch.openvswitch       2.1.0  
ovirt.ovirt                   2.3.1  
purestorage.flasharray        1.14.0 
purestorage.flashblade        1.10.0 
purestorage.fusion            1.1.1  
sensu.sensu_go                1.13.1 
servicenow.servicenow         1.0.6  
splunk.es                     2.1.0  
t_systems_mms.icinga_director 1.31.4 
theforeman.foreman            3.7.0  
vmware.vmware_rest            2.2.0  
vultr.cloud                   1.3.0  
vyos.vyos                     3.0.1  
wti.remote                    1.0.4  

AWS SDK versions

$ pip show boto boto3 botocore
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.24.82
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages
Requires: jmespath, botocore, s3transfer
Required-by: credstash, aws-sam-translator, redshift-connector, moto, awswrangler
---
Name: botocore
Version: 1.27.82
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages
Requires: jmespath, urllib3, python-dateutil
Required-by: s3transfer, aws-xray-sdk, redshift-connector, moto, boto3, awswrangler
╭╴~/environment/repo/MWE (srcclr_docker)
╰ $ pip3 show boto boto3 botocore                                                                                                                                                        
WARNING: Package(s) not found: boto
Name: boto3
Version: 1.24.82
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages
Requires: jmespath, botocore, s3transfer
Required-by: credstash, aws-sam-translator, redshift-connector, moto, awswrangler
---
Name: botocore
Version: 1.27.82
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: None
License: Apache License 2.0
Location: /home/ec2-user/.pyenv/versions/3.8.11/lib/python3.8/site-packages
Requires: jmespath, urllib3, python-dateutil
Required-by: s3transfer, aws-xray-sdk, redshift-connector, moto, boto3, awswrangler

(Unsure how meaningful this is because I specify the interpreter on each run with -e ansible_python_interpreter=$(which python3))

Configuration

$ ansible-config dump --only-changed
ANSIBLE_PIPELINING(/home/ec2-user/.ansible.cfg) = True
DEFAULT_LOCAL_TMP(/home/ec2-user/.ansible.cfg) = /dev/shm/ansible/tmp_local/ansible-local-14524dud79jcc
DEFAULT_STDOUT_CALLBACK(/home/ec2-user/.ansible.cfg) = yaml
INTERPRETER_PYTHON(/home/ec2-user/.ansible.cfg) = /usr/bin/python3

OS / Environment

Amazon Linux 2

Steps to Reproduce

Create a Lambda function named mylambda. Update the vars for your AWS account.

---
- hosts: localhost
  connection: local
  vars:
    lambda_name: mylambda
    account_number: 1234
    region: ap-southeast-2
  tasks:
  - name: with name
    community.aws.execute_lambda:
      name: "{{ lambda_name }}"
  - name: with ARN as name
    community.aws.execute_lambda:
      name: "arn:aws:lambda:{{ region }}:{{ account_number }}:function:{{ lambda_name }}"
  - name: with ARN as ARN
    community.aws.execute_lambda:
      function_arn: "arn:aws:lambda:{{ region }}:{{ account_number }}:function:{{ lambda_name }}"

Expected Results

The lambda is invoked 3 times.

Actual Results

PLAY [localhost] ************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [with name] ************************************************************************************************************************************************************************
changed: [127.0.0.1]

TASK [with ARN as name] *****************************************************************************************************************************************************************
changed: [127.0.0.1]

TASK [with ARN as ARN] ******************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Invalid type for parameter FunctionName, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
fatal: [127.0.0.1]: FAILED! => changed=false 
  boto3_version: 1.24.82
  botocore_version: 1.27.82
  msg: |-
    Failed while waiting on lambda to be Active: Parameter validation failed:
    Invalid type for parameter FunctionName, value: None, type: <class 'NoneType'>, valid types: <class 'str'>

PLAY RECAP ******************************************************************************************************************************************************************************
127.0.0.1                  : ok=3    changed=2    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@mdavis-xyz
Copy link
Contributor Author

Note that passing the ARN into the name field does seem to work. Even though the docs say not to do it.

@ansibullbot ansibullbot added bug This issue/PR relates to a bug needs_triage python3 traceback labels Nov 15, 2022
@tremble tremble changed the title execute_lambda doesn't work with function_arn instead of name lambda_execute doesn't work with function_arn instead of name Nov 15, 2022
@tremble tremble transferred this issue from ansible-collections/community.aws Nov 15, 2022
@tremble
Copy link
Contributor

tremble commented Nov 15, 2022

Hi @mdavis-xyz,

Thanks for taking the time to open this issue, the module was actually moved to the amazon.aws collection with release 5.0.0 (the ansible.com "latest" docs are tied to the latest version of Ansible rather than the collection)

The best place to look for the 'latest' version of the community.aws and amazon.aws collections is Ansible Galaxy: https://galaxy.ansible.com/amazon/aws and https://galaxy.ansible.com/community/aws, with the docs being available on github.io https://ansible-collections.github.io/amazon.aws/branch/stable-5/collections/amazon/aws/index.html https://ansible-collections.github.io/community.aws/branch/stable-5/collections/community/aws/index.html

It looks like waiter is still there:

def wait_for_lambda(client, module, name):
and I suspect the bug will still be there too.

The module's been renamed from execute_lambda to lambda_execute, as part of a mass-rename in 5.0.0 to try and make our module names more consistent and (hopefully) make modules easier to find in the medium/long term.

softwarefactory-project-zuul bot pushed a commit that referenced this issue Nov 18, 2022
lambda_execute: allow function arn instead of name

SUMMARY
Fixes #1268
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
lambda_execute
ADDITIONAL INFORMATION

Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug python3 traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants