Skip to content

Commit

Permalink
ec2_vpc_nacl_info - Fix failure when listing NetworkACLs (ansible-col…
Browse files Browse the repository at this point in the history
  • Loading branch information
branic committed Dec 20, 2024
1 parent 6712ec6 commit 2063870
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ec2_vpc_nacl_info - Fix failure when listing NetworkACLs and no ACLs are found (https://github.com/ansible-collections/amazon.aws/issues/2425).
7 changes: 5 additions & 2 deletions plugins/modules/ec2_vpc_nacl_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@ def list_ec2_vpc_nacls(connection, module: AnsibleAWSModule) -> None:

try:
network_acls = describe_network_acls(connection, **params)
if not network_acls:
module.fail_json(msg="Unable to describe ACL. NetworkAcl does not exist")
if nacl_ids and not len(nacl_ids) == len(network_acls):
if len(nacl_ids) == 1:
module.fail_json(msg="Unable to describe ACL. NetworkAcl does not exist.")
else:
module.fail_json(msg="Unable to describe all ACLs. One or more NetworkAcls does not exist.")
except AnsibleEC2Error as e:
module.fail_json_aws_error(e)

Expand Down
26 changes: 26 additions & 0 deletions tests/integration/targets/ec2_vpc_nacl/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,33 @@
that:
- nacl_facts is failed
- '"does not exist" in nacl_facts.msg'
- '"One or more" not in nacl_facts.msg'

- name: Get network multiple ACLs info with invalid ID
amazon.aws.ec2_vpc_nacl_info:
nacl_ids:
- 'acl-000000000000'
- 'acl-000000000001'
register: nacl_facts
ignore_errors: true

- name: Assert message mentions missing ACLs
assert:
that:
- nacl_facts is failed
- '"does not exist" in nacl_facts.msg'
- '"One or more" in nacl_facts.msg'

- name: Get network ACL info with filters
amazon.aws.ec2_vpc_nacl_info:
filters:
default: false
register: nacl_facts

- name: Assert error is not returned
ansible.builtin.assert:
that:
- nacl_facts is succeeded
# ============================================================

- name: Fetch AZ availability
Expand Down

0 comments on commit 2063870

Please sign in to comment.