Repository: ansible-collections/amazon.aws

Issue:
ec2_eni idempotence bug
<!--- Verify first that your issue is not already reported on GitHub -->
<!--- Also test if the latest release and devel branch are affected too -->
<!--- Complete *all* sections as described, this form is processed automatically -->

##### SUMMARY
The encoding of groups causes a bytes type does not equal a string type so idempotence fails. This is the line at fault I belive: https://github.com/ansible-collections/amazon.aws/blame/ac6b2cd478773befdde43bfadc0de40969ad4d0b/plugins/modules/ec2_eni.py#L772

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
ec2_eni

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.10.5
python version = 3.9.1 (default, Jan  8 2021, 17:17:17) [Clang 12.0.0 (clang-1200.0.32.28)]
```

##### STEPS TO REPRODUCE
Pass security group names to the ec2_eni module & it will always report a change.

##### EXPECTED RESULTS
It should not report a change.


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 @wimnat
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Hi, thank you for the bug report. Do you have an example of a problematical playbook? And would you like to submit a Pull Request?

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
@@ -769,7 +769,7 @@ def get_sec_group_list(groups):
     # Build list of remote security groups
     remote_security_groups = []
     for group in groups:
-        remote_security_groups.append(group["GroupId"].encode())
+        remote_security_groups.append(group["GroupId"])
 
     return remote_security_groups
 


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
@@ -7,6 +7,7 @@
       region: "{{ aws_region }}"
 
   collections:
+  - ansible.netcommon
   - community.aws
 
   block:
diff --git a/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml b/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml
--- a/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml
+++ b/tests/integration/targets/ec2_eni/tasks/test_eni_basic_creation.yaml
@@ -57,7 +57,7 @@
       - _interface_0.private_dns_name is string
       - _interface_0.private_dns_name.endswith("ec2.internal")
       - '"private_ip_address" in _interface_0'
-      - _interface_0.private_ip_address | ipaddr()
+      - _interface_0.private_ip_address | ansible.netcommon.ipaddr
       - _interface_0.private_ip_address == ip_1
       - '"private_ip_addresses" in _interface_0'
       - _interface_0.private_ip_addresses | length == 1
@@ -152,7 +152,7 @@
       - _interface_0.private_dns_name is string
       - _interface_0.private_dns_name.endswith("ec2.internal")
       - '"private_ip_address" in _interface_0'
-      - _interface_0.private_ip_address | ipaddr()
+      - _interface_0.private_ip_address | ansible.netcommon.ipaddr
       - _interface_0.private_ip_address == ip_5
       - '"private_ip_addresses" in _interface_0'
       - _interface_0.private_ip_addresses | length == 1