Skip to main content
HIGHEKSSecurity

EKS Public Endpoint Unrestricted

eks-public-endpoint-unrestricted

What this rule checks

Detects EKS clusters with the API endpoint reachable from 0.0.0.0/0 or only via the public network.

How to fix it

  1. 1Enable EndpointPrivateAccess for in-VPC node communication
  2. 2Restrict PublicAccessCidrs to known administrative IP ranges
FlaggedThe cluster API endpoint is public with PublicAccessCidrs of 0.0.0.0/0 and no private access, exposing the Kubernetes API to the entire internet.
import { aws_ec2 as ec2, aws_eks as eks, aws_iam as iam } from 'aws-cdk-lib';

const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 2 });
const role = new iam.Role(this, 'EksRole', { assumedBy: new iam.ServicePrincipal('eks.amazonaws.com') });
new eks.CfnCluster(this, 'Cluster', {
  roleArn: role.roleArn,
  resourcesVpcConfig: {
    subnetIds: vpc.publicSubnets.map((s) => s.subnetId),
    endpointPublicAccess: true,
    endpointPrivateAccess: false,
    publicAccessCidrs: ['0.0.0.0/0'],
  },
});
FixedEnabling private access and restricting public CIDRs to a known admin range keeps node traffic in-VPC and limits API exposure.
import { aws_ec2 as ec2, aws_eks as eks, aws_iam as iam } from 'aws-cdk-lib';

const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 2 });
const role = new iam.Role(this, 'EksRole', { assumedBy: new iam.ServicePrincipal('eks.amazonaws.com') });
new eks.CfnCluster(this, 'Cluster', {
  roleArn: role.roleArn,
  resourcesVpcConfig: {
    subnetIds: vpc.privateSubnets.map((s) => s.subnetId),
    endpointPublicAccess: true,
    endpointPrivateAccess: true,
    publicAccessCidrs: ['203.0.113.0/24'],
  },
});

CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.

Affected resource types

AWS::EKS::Cluster

Compliance frameworks

SOC2HIPAAPCI-DSSNIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

Sometimes a flag is deliberate β€” a genuinely public endpoint, say. You can dismiss eks-public-endpoint-unrestricted and the reason is kept in the report, not silently hidden.

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "eks-public-endpoint-unrestricted", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::eks-public-endpoint-unrestricted',
  reason: 'Why this is intentional',
});

Use the rule ID eks-public-endpoint-unrestricted shown above β€” not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs β†’

Catch this in your stack

$ npx cdk-insights scan

CDK Insights runs this and 118+ other rules locally against your synthesised CDK app β€” free, no account, your code never leaves your machine.

More EKS rules