Skip to content

Commit

Permalink
ec2_eni: Fix idempotency when security_groups is specified (#337)
Browse files Browse the repository at this point in the history
ec2_eni: Fix idempotency when security_groups is specified

SUMMARY

If security_groups attribute is specified - module always returns Changed = True.
Fixes #255.

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ec2_eni
ADDITIONAL INFORMATION



Example:
- amazon.aws.ec2_eni:
    name: my-eni
    security_groups:
      - my-sg
    subnet_id: subnet-123456

Will always return Changed = True.

Reviewed-by: Jill R <None>
  • Loading branch information
ichekaldin authored Jul 8, 2021
1 parent ea4fd33 commit 922514a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- ec2_eni - fix idempotency when ``security_groups`` attribute is specified (https://github.com/ansible-collections/amazon.aws/pull/337).
2 changes: 1 addition & 1 deletion plugins/modules/ec2_eni.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/ec2_eni/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
region: "{{ aws_region }}"

collections:
- ansible.netcommon
- community.aws

block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 922514a

Please sign in to comment.