Skip to content

Commit fee773a

Browse files
branicpatchback[bot]
authored andcommitted
ec2_vpc_nacl_info - Fix failure when listing NetworkACLs (#2425) (#2429)
SUMMARY Only fail listing NetworkACLs if specific ACLs were requested and not found. Fixes: #2425 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_vpc_nacl_info ADDITIONAL INFORMATION Reviewed-by: Mark Chappell (cherry picked from commit 7b5212d)
1 parent 919666c commit fee773a

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
bugfixes:
3+
- ec2_vpc_nacl_info - Fix failure when listing NetworkACLs and no ACLs are found (https://github.com/ansible-collections/amazon.aws/issues/2425).

plugins/modules/ec2_vpc_nacl_info.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ def list_ec2_vpc_nacls(connection, module: AnsibleAWSModule) -> None:
166166

167167
try:
168168
network_acls = describe_network_acls(connection, **params)
169-
if not network_acls:
170-
module.fail_json(msg="Unable to describe ACL. NetworkAcl does not exist")
169+
if nacl_ids and not len(nacl_ids) == len(network_acls):
170+
if len(nacl_ids) == 1:
171+
module.fail_json(msg="Unable to describe ACL. NetworkAcl does not exist.")
172+
else:
173+
module.fail_json(msg="Unable to describe all ACLs. One or more NetworkAcls does not exist.")
171174
except AnsibleEC2Error as e:
172175
module.fail_json_aws_error(e)
173176

tests/integration/targets/ec2_vpc_nacl/tasks/main.yml

+26
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,33 @@
4242
that:
4343
- nacl_facts is failed
4444
- '"does not exist" in nacl_facts.msg'
45+
- '"One or more" not in nacl_facts.msg'
4546

47+
- name: Get network multiple ACLs info with invalid ID
48+
amazon.aws.ec2_vpc_nacl_info:
49+
nacl_ids:
50+
- 'acl-000000000000'
51+
- 'acl-000000000001'
52+
register: nacl_facts
53+
ignore_errors: true
54+
55+
- name: Assert message mentions missing ACLs
56+
assert:
57+
that:
58+
- nacl_facts is failed
59+
- '"does not exist" in nacl_facts.msg'
60+
- '"One or more" in nacl_facts.msg'
61+
62+
- name: Get network ACL info with filters
63+
amazon.aws.ec2_vpc_nacl_info:
64+
filters:
65+
default: false
66+
register: nacl_facts
67+
68+
- name: Assert error is not returned
69+
ansible.builtin.assert:
70+
that:
71+
- nacl_facts is succeeded
4672
# ============================================================
4773

4874
- name: Fetch AZ availability

0 commit comments

Comments
 (0)