Description
public_access_cidrs controls which outbound addresses can reach the EKS public API. 0.0.0.0/0 allows every IPv4 address. The list applies only to the public endpoint.
Potential impact
A wide range lets unnecessary sources attempt sign-in. A range that excludes a node or administrator can also interrupt API access.
Remediation
Allow the actual egress addresses of approved management networks and clients. If nodes use the public endpoint, include their egress addresses or those of their NAT gateways. Verify node and administrator connectivity and retain authentication and Kubernetes authorization. If public access is unnecessary, verify private connectivity before setting endpoint_public_access = false.
Examples
Both examples keep the public endpoint enabled. Supply the referenced role and subnets and replace 203.0.113.10/32 with your approved source addresses.
Before
resource "aws_eks_cluster" "example" {
name = "example"
role_arn = aws_iam_role.example.arn
vpc_config {
subnet_ids = [aws_subnet.example1.id, aws_subnet.example2.id]
endpoint_public_access = true
public_access_cidrs = ["0.0.0.0/0"]
}
}
After
resource "aws_eks_cluster" "example" {
name = "example"
role_arn = aws_iam_role.example.arn
vpc_config {
subnet_ids = [aws_subnet.example1.id, aws_subnet.example2.id]
endpoint_public_access = true
public_access_cidrs = ["203.0.113.10/32"]
}
}