diff --git a/changelogs/fragments/1348-remove-unreachable-code.yml b/changelogs/fragments/1348-remove-unreachable-code.yml new file mode 100644 index 00000000000..467520ba4bd --- /dev/null +++ b/changelogs/fragments/1348-remove-unreachable-code.yml @@ -0,0 +1,2 @@ +bugfixes: +- ec2_security_group - file included unreachable code. Fix now removes unreachable code by removing an inapproproate logic (https://github.com/ansible-collections/amazon.aws/pull/1348). diff --git a/plugins/modules/ec2_security_group.py b/plugins/modules/ec2_security_group.py index 28b4ca78adb..c8bc251d9b2 100644 --- a/plugins/modules/ec2_security_group.py +++ b/plugins/modules/ec2_security_group.py @@ -1450,16 +1450,10 @@ def ensure_present(module, client, group, groups): revoke_ingress = [] if purge_rules_egress and module.params.get('rules_egress') is not None: - if module.params.get('rules_egress') is []: - revoke_egress = [ - to_permission(r) for r in set(present_egress) - set(named_tuple_egress_list) - if r != Rule((None, None), '-1', '0.0.0.0/0', 'ipv4', None) - ] - else: - revoke_egress = [] - for p in present_egress: - if not any(rule_cmp(p, b) for b in named_tuple_egress_list): - revoke_egress.append(to_permission(p)) + revoke_egress = [] + for p in present_egress: + if not any(rule_cmp(p, b) for b in named_tuple_egress_list): + revoke_egress.append(to_permission(p)) else: revoke_egress = []