Description
Resources created without a specific security group may receive the VPC default group. Its initial inbound rule permits traffic from resources in that same group.
Potential impact
An unnecessary rule can link unrelated workloads and can apply to any new resource assigned to the group.
Remediation
Move dependent workloads to explicit service groups and test the connections they need. On first adoption, aws_default_security_group removes existing rules before applying the declared ones. Check every attached resource before applying, then verify allowed and blocked connections.
Examples
Both examples manage the default group of aws_vpc.mainvpc. Define that VPC separately.
Before
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.mainvpc.id
ingress {
protocol = "-1"
self = true
from_port = 0
to_port = 0
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
self = true allows every protocol from group members. Egress allows every IPv4 destination.
After
resource "aws_default_security_group" "default" {
vpc_id = aws_vpc.mainvpc.id
}
Without ingress or egress, the default group permits no new connections. Define required permissions on the workloads’ other attached groups.