Repository: ansible-collections/amazon.aws

Issue:
ec2_eni: parameter device_index expects integer from user, but further in the code it is expected string but passed the integer
### Summary

When I try to create second interface and attach it to EC2 instance using `ec2_eni` module it fails with python traceback:

```console
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_eni.py", line 792, in uniquely_find_eni
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 336, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 125, in _retry_wrapper
    base_class=cls.base_class,
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 68, in _retry_func
    return func()
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 649, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 697, in _convert_to_request_dict
    api_params, operation_model)
  File "/usr/lib/python3.6/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter Filters[1].Values[0], value: 1, type: <class 'int'>, valid types: <class 'str'>
[WARNING]: botocore < 1.19.0 is not supported or tested.  Some features may not work.
[WARNING]: boto3 < 1.16.0 is not supported or tested.  Some features may not work.
fatal: [localhost]: FAILED! => {
    "boto3_version": "1.15.15",
    "botocore_version": "1.18.15",
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_reassignment": false,
            "attached": null,
            "aws_access_key": "...",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": false,
            "delete_on_termination": null,
            "description": "second-interface",
            "device_index": 1,
            "ec2_url": null,
            "eni_id": null,
            "force_detach": false,
            "instance_id": "i-...",
            "name": "second-interface",
            "private_ip_address": null,
            "profile": null,
            "purge_secondary_private_ip_addresses": false,
            "purge_tags": true,
            "region": "us-east-1",
            "secondary_private_ip_address_count": null,
            "secondary_private_ip_addresses": null,
            "security_groups": [],
            "security_token": null,
            "source_dest_check": null,
            "state": "present",
            "subnet_id": "subnet-...",
            "tags": null,
            "validate_certs": true
        }
    },
    "msg": "Failed to find unique eni with filters: [{'Name': 'attachment.instance-id', 'Values': ['i-...']}, {'Name': 'attachment.device-index', 'Values': [1]}]: Parameter validation failed:\nInvalid type for parameter Filters[1].Values[0], value: 1, type: <class 'int'>, valid types: <class 'str'>"
```

I tried it also with different version of Python (3.7, 3.10), but if fails with the same error.

If I tried to define the `device_index` as string (`device_index: 1 | str`), it fails with error:
```console
    "msg": "argument device_index is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"
```

### Issue Type

Bug Report

### Component Name

ec2_eni

### Ansible Version

```console (paste below)
$ ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/test/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Jan 19 2022, 23:28:49) [GCC 8.5.0 20210514 (Red Hat 8.5.0-7)]
```

```console
$ ansible --version
ansible [core 2.12.3]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/dahorak/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/dahorak/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 12.0.1 20220308 (Red Hat 12.0.1-0)]
  jinja version = 3.0.3
  libyaml = True
```

### Collection Versions

```console (paste below)
$ ansible-galaxy collection list

Collection        Version
----------------- -------
amazon.aws        3.3.0  
ansible.posix     1.3.0  
community.general 4.6.1  
```


### AWS SDK versions

```console (paste below)
$ pip show boto boto3 botocore
Name: boto3
Version: 1.15.15
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /usr/lib/python3.6/site-packages
Requires: botocore, jmespath, s3transfer
---
Name: botocore
Version: 1.18.15
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /usr/lib/python3.6/site-packages
Requires: jmespath, python-dateutil, urllib3
```
```console (paste below)
$ pip show boto boto3 botocore
Name: boto3
Version: 1.21.8
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: /usr/lib/python3.10/site-packages
Requires: botocore, jmespath, s3transfer
Required-by: 
---
Name: botocore
Version: 1.24.8
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: /usr/lib/python3.10/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: awscli, boto3, s3transfer
```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
```


### OS / Environment

CentOS Stream release 8
Fedora release 36 (Thirty Six)

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml (paste below)
---
- name: "Create second interface"
  hosts: "localhost"
    
  vars:
    aws_access_key: "..."
    aws_secret_key: "..."
    aws_region: "us-east-1"
    aws_instance_id: "i-..."
    aws_second_subnet: "subnet-..."

  tasks:
    - name: Create second interface
      amazon.aws.ec2_eni:
        aws_access_key: "{{ aws_access_key }}"
        aws_secret_key: "{{ aws_secret_key }}"
        region: "{{ aws_region }}"
        name: "second-interface"
        description: "second-interface"
        instance_id: "{{ aws_instance_id }}"
        device_index: 1
        subnet_id: "{{ aws_second_subnet }}"
        state: present
```


### Expected Results

It should create interface and attach it to instance.

### Actual Results

```console (paste below)
$ ansible-playbook -i inventory.yml  playbook-test.yml -vvvvvv
ansible-playbook 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/test/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Jan 19 2022, 23:28:49) [GCC 8.5.0 20210514 (Red Hat 8.5.0-7)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/test/test/inventory.yml as it did not pass its verify_file() method
script declined parsing /home/test/test/inventory.yml as it did not pass its verify_file() method
Parsed /home/test/test/inventory.yml inventory source with yaml plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit
localhost does not match 'all'
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.6/site-packages/ansible/plugins/callback/default.py
Attempting to use 'actionable' callback.
Skipping callback 'actionable', as we already have a stdout callback.
Attempting to use 'aws_resource_actions' callback.
Attempting to use 'cgroup_memory_recap' callback.
Attempting to use 'cgroup_perf_recap' callback.
Attempting to use 'context_demo' callback.
Attempting to use 'counter_enabled' callback.
Skipping callback 'counter_enabled', as we already have a stdout callback.
Attempting to use 'debug' callback.
Skipping callback 'debug', as we already have a stdout callback.
Attempting to use 'dense' callback.
Skipping callback 'dense', as we already have a stdout callback.
Attempting to use 'dense' callback.
Skipping callback 'dense', as we already have a stdout callback.
Attempting to use 'foreman' callback.
Attempting to use 'full_skip' callback.
Skipping callback 'full_skip', as we already have a stdout callback.
Attempting to use 'grafana_annotations' callback.
Attempting to use 'hipchat' callback.
Attempting to use 'jabber' callback.
Attempting to use 'json' callback.
Skipping callback 'json', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'log_plays' callback.
Attempting to use 'logdna' callback.
Attempting to use 'logentries' callback.
Attempting to use 'logstash' callback.
Attempting to use 'mail' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'nrdp' callback.
Attempting to use 'null' callback.
Skipping callback 'null', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'osx_say' callback.
Attempting to use 'profile_roles' callback.
Attempting to use 'profile_tasks' callback.
Attempting to use 'say' callback.
Attempting to use 'selective' callback.
Skipping callback 'selective', as we already have a stdout callback.
Attempting to use 'skippy' callback.
Skipping callback 'skippy', as we already have a stdout callback.
Attempting to use 'slack' callback.
Attempting to use 'splunk' callback.
Attempting to use 'stderr' callback.
Skipping callback 'stderr', as we already have a stdout callback.
Attempting to use 'sumologic' callback.
Attempting to use 'syslog_json' callback.
Attempting to use 'timer' callback.
Attempting to use 'tree' callback.
Attempting to use 'unixy' callback.
Skipping callback 'unixy', as we already have a stdout callback.
Attempting to use 'yaml' callback.
Skipping callback 'yaml', as we already have a stdout callback.

PLAYBOOK: playbook-test.yml ************************************************************************
Positional arguments: playbook-test.yml
verbosity: 6
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/home/test/test/inventory.yml',)
forks: 5
1 plays in playbook-test.yml

PLAY [Create second interface] *********************************************************************

TASK [Gathering Facts] *****************************************************************************
task path: /home/test/test/playbook-test.yml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: test
<127.0.0.1> EXEC /bin/sh -c 'echo ~test && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/test/.ansible/tmp `"&& mkdir "` echo /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491 `" && echo ansible-tmp-1654691154.2020857-245441-121728147229491="` echo /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491 `" ) && sleep 0'
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/ansible_collector.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/default_collectors.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/namespace.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/selectors.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/formatters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/file.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/parameters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_json_compat.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/process.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_collections_compat.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_utils.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/converters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/validation.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/six/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/sys_info.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/_selectors2.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/collections.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/distro/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/distro/_distro.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/compat.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/collector.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/timeout.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/openbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/darwin.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/selinux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/distribution.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/linux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/openbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/date_time.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/hurd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/darwin.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/ssh_pub_keys.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/python.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/sunos.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/iscsi.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/fc_wwn.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/pkg_mgr.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/other/facter.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/other/ohai.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/dns.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/base.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/netbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/hpux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/platform.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/other/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/user.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/caps.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/hpux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/netbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/sunos.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/cmdline.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/dragonfly.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/fips.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/base.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/base.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/linux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/hurd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/dragonfly.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/linux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/sunos.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/hpux.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/lsb.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/service_mgr.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/dragonfly.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/openbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/local.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/netbsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/chroot.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/freebsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/freebsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/hardware/aix.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/aix.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/freebsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/nvme.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/env.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/system/apparmor.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/network/generic_bsd.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/sysctl.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/utils.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/facts/virtual/sysctl.py
Using module file /usr/lib/python3.6/site-packages/ansible/modules/system/setup.py
<127.0.0.1> PUT /home/test/.ansible/tmp/ansible-local-245435r_cw7lqi/tmpdgb1scmp TO /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491/AnsiballZ_setup.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491/ /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.6 /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491/AnsiballZ_setup.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/test/.ansible/tmp/ansible-tmp-1654691154.2020857-245441-121728147229491/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [Create second interface] *********************************************************************
task path: /home/test/test/playbook-test.yml:13
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: test
<127.0.0.1> EXEC /bin/sh -c 'echo ~test && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/test/.ansible/tmp `"&& mkdir "` echo /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356 `" && echo ansible-tmp-1654691155.052014-245487-199583058355356="` echo /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356 `" ) && sleep 0'
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/ec2
Using module_utils file ansible_collections/amazon/aws
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/core
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/tagging
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/basic.py
Using module_utils file ansible_collections/amazon
Using module_utils file ansible_collections
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/waiters
Using module_utils file ansible_collections/amazon/aws/plugins
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/dict_transformations.py
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/cloud
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/_text.py
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/policy
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/ansible_release.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/six/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/__init__.py
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/version
Using module_utils file ansible_collections/amazon/aws/plugins/module_utils/_version
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/selectors.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/formatters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/file.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_json_compat.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/parameters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/process.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_collections_compat.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/_utils.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/text/converters.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/validation.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/sys_info.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/compat/_selectors2.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/common/collections.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/distro/__init__.py
Using module_utils file /usr/lib/python3.6/site-packages/ansible/module_utils/distro/_distro.py
Using module file /home/test/.ansible/collections/ansible_collections/amazon/aws/plugins/modules/ec2_eni.py
<127.0.0.1> PUT /home/test/.ansible/tmp/ansible-local-245435r_cw7lqi/tmp4motjjb9 TO /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356/AnsiballZ_ec2_eni.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356/ /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356/AnsiballZ_ec2_eni.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.6 /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356/AnsiballZ_ec2_eni.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/test/.ansible/tmp/ansible-tmp-1654691155.052014-245487-199583058355356/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_eni.py", line 792, in uniquely_find_eni
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/core.py", line 336, in deciding_wrapper
    return retrying_wrapper(*args, **kwargs)
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 125, in _retry_wrapper
    base_class=cls.base_class,
  File "/tmp/ansible_amazon.aws.ec2_eni_payload_8w5xc_go/ansible_amazon.aws.ec2_eni_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/cloud.py", line 68, in _retry_func
    return func()
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 649, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/usr/lib/python3.6/site-packages/botocore/client.py", line 697, in _convert_to_request_dict
    api_params, operation_model)
  File "/usr/lib/python3.6/site-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter Filters[1].Values[0], value: 1, type: <class 'int'>, valid types: <class 'str'>
[WARNING]: botocore < 1.19.0 is not supported or tested.  Some features may not work.
[WARNING]: boto3 < 1.16.0 is not supported or tested.  Some features may not work.
fatal: [localhost]: FAILED! => {
    "boto3_version": "1.15.15",
    "botocore_version": "1.18.15",
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_reassignment": false,
            "attached": null,
            "aws_access_key": "...",
            "aws_ca_bundle": null,
            "aws_config": null,
            "aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "debug_botocore_endpoint_logs": false,
            "delete_on_termination": null,
            "description": "second-interface",
            "device_index": 1,
            "ec2_url": null,
            "eni_id": null,
            "force_detach": false,
            "instance_id": "i-...",
            "name": "second-interface",
            "private_ip_address": null,
            "profile": null,
            "purge_secondary_private_ip_addresses": false,
            "purge_tags": true,
            "region": "us-east-1",
            "secondary_private_ip_address_count": null,
            "secondary_private_ip_addresses": null,
            "security_groups": [],
            "security_token": null,
            "source_dest_check": null,
            "state": "present",
            "subnet_id": "subnet-...",
            "tags": null,
            "validate_certs": true
        }
    },
    "msg": "Failed to find unique eni with filters: [{'Name': 'attachment.instance-id', 'Values': ['i-...']}, {'Name': 'attachment.device-index', 'Values': [1]}]: Parameter validation failed:\nInvalid type for parameter Filters[1].Values[0], value: 1, type: <class 'int'>, valid types: <class 'str'>"
}

PLAY RECAP *****************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
```

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/ec2_eni.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_eni.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @healem @jillr @s-hertel @tremble
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/ec2_eni.py b/plugins/modules/ec2_eni.py
--- a/plugins/modules/ec2_eni.py
+++ b/plugins/modules/ec2_eni.py
@@ -761,7 +761,7 @@ def uniquely_find_eni(connection, module, eni=None):
         filters.append({'Name': 'attachment.instance-id',
                         'Values': [instance_id]})
         filters.append({'Name': 'attachment.device-index',
-                        'Values': [device_index]})
+                        'Values': [str(device_index)]})
 
     if name and subnet_id and not filters:
         filters.append({'Name': 'tag:Name',


Test patch:
diff --git a/tests/integration/targets/ec2_eni/tasks/main.yaml b/tests/integration/targets/ec2_eni/tasks/main.yaml
--- a/tests/integration/targets/ec2_eni/tasks/main.yaml
+++ b/tests/integration/targets/ec2_eni/tasks/main.yaml
@@ -83,6 +83,9 @@
   - name: test attaching and detaching network interfaces
     include_tasks: ./test_attachment.yaml
 
+  - name: test attaching and detaching multiple network interfaces
+    include_tasks: ./test_create_attached_multiple.yml
+
   - name: test modifying source_dest_check
     include_tasks: ./test_modifying_source_dest_check.yaml
 
diff --git a/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml
new file mode 100644
--- /dev/null
+++ b/tests/integration/targets/ec2_eni/tasks/test_create_attached_multiple.yml
@@ -0,0 +1,121 @@
+---
+  - name: Create instance to test attaching and detaching network interfaces for this test
+    ec2_instance:
+      name: "{{ resource_prefix }}-instance"
+      image_id: "{{ ec2_ami_id }}"
+      vpc_subnet_id: "{{ vpc_subnet_id }}"
+      instance_type: t2.micro
+    register: ec2_instances
+
+  - name: set variable for the instance ID
+    set_fact:
+      instance_id_3: "{{ ec2_instances.instances[0].instance_id }}"
+
+#=================================================================
+
+  - name: Create and attach another interface to above instance - check_mode
+    amazon.aws.ec2_eni:
+      name: "{{ resource_prefix }}-eni"
+      instance_id: "{{ instance_id_3 }}"
+      device_index: 1
+      subnet_id: "{{ vpc_subnet_id }}"
+      state: present
+      attached: true
+      delete_on_termination: true
+    check_mode: true
+    register: result
+
+  # Get the instance info and ENI info to verify attachment of second eni
+  - ec2_instance_info:
+      instance_ids:
+        - "{{ instance_id_3 }}"
+    register: instance_info_result
+
+  - assert:
+      that:
+        - result is changed
+        - result is not failed
+        - instance_info_result.instances[0].network_interfaces | length == 1
+        - '"Would have created ENI if not in check mode." in result.msg'
+        - "'ec2:CreateNetworkInterface' not in {{ result.resource_actions }}"
+
+  - name: Create and attach another interface to above instance
+    amazon.aws.ec2_eni:
+      name: "{{ resource_prefix }}-eni"
+      instance_id: "{{ instance_id_3 }}"
+      device_index: 1
+      subnet_id: "{{ vpc_subnet_id }}"
+      state: present
+      attached: true
+      delete_on_termination: true
+    register: result
+
+  - name: Set variable for the ENI ID
+    set_fact:
+      eni_id_attached_multiple: "{{ result.interface.id }}"
+
+  # Get the instance info and ENI info to verify attachment of second eni
+  - ec2_instance_info:
+      instance_ids:
+        - "{{ instance_id_3 }}"
+    register: instance_info_result
+  - ec2_eni_info:
+      eni_id: "{{ eni_id_attached_multiple }}"
+    register: eni_info
+
+  - name: Assert that the interface attachment was successful
+    assert:
+      that:
+        - result is changed
+        - result is not failed
+        - instance_info_result.instances[0].network_interfaces | length == 2
+        - eni_info.network_interfaces[0].attachment.instance_id == instance_id_3
+        - eni_info.network_interfaces[0].attachment.device_index == 1
+
+  - name: Create and attach another interface to above instance - check_mode - idempotent
+    amazon.aws.ec2_eni:
+      name: "{{ resource_prefix }}-eni"
+      instance_id: "{{ instance_id_3 }}"
+      device_index: 1
+      subnet_id: "{{ vpc_subnet_id }}"
+      state: present
+      attached: true
+      delete_on_termination: true
+    check_mode: true
+    register: result
+
+  # Get the instance info and ENI info to verify attachment of second eni
+  - ec2_instance_info:
+      instance_ids:
+        - "{{ instance_id_3 }}"
+    register: instance_info_result
+
+  - name: Assert that the interface would have been modified if not in check_mode
+    assert:
+      that:
+        - result is changed
+        - result is not failed
+        - instance_info_result.instances[0].network_interfaces | length == 2
+        - '"Would have modified ENI: {{ eni_id_attached_multiple }} if not in check mode" in result.msg'
+        - "'ec2:CreateNetworkInterface' not in {{ result.resource_actions }}"
+        - "'ec2:ModifyNetworkInterfaceAttribute' not in {{ result.resource_actions }}"
+
+#=================================================================
+
+  - name: remove the network interface created in this test
+    ec2_eni:
+      eni_id: "{{ eni_id_attached_multiple }}"
+      force_detach: True
+      state: absent
+    ignore_errors: true
+    retries: 5
+
+  - name: terminate the instance created in this test
+    ec2_instance:
+      state: absent
+      instance_ids:
+        - "{{ instance_id_3 }}"
+      wait: True
+    ignore_errors: true
+    retries: 5
+    when: instance_id_3 is defined