Description
An ingress rule with 0.0.0.0/0 allows any IPv4 source. ::/0 allows any IPv6 source. Each applies to the ports and protocol in that rule.
Potential impact
If an internet path exists, unwanted connections can reach multiple resources that share the group.
Remediation
- Limit internal and administrative access to approved client CIDRs or supported security group references. For VPN clients, check the source address the service actually sees.
- For public services, allow only required ports and protocols and retain application authentication. Review other attached groups as well.
- By default,
purge_rulesistrueand removes inbound rules omitted from the task. List every rule you need to keep. Test both allowed and blocked connections after applying the change.
Examples
Supply the target vpc_id and AWS credentials in the execution environment. Both tasks manage the same group’s TCP port 80 rule.
Before
yaml
- name: example ec2 group
amazon.aws.ec2_security_group:
name: example
description: an example EC2 group
vpc_id: "{{ vpc_id }}"
region: eu-west-1
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
After
yaml
- name: example ec2 group
amazon.aws.ec2_security_group:
name: example
description: an example EC2 group
vpc_id: "{{ vpc_id }}"
region: eu-west-1
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 10.1.1.1/32
10.1.1.1/32 permits one IPv4 address. Replace it with the approved client’s actual source range.