aws-cdk: [aws-eks] Private Cluster not getting created after specifying subnets public SubnetIDs

Reproduction Steps

  • Running the following section in CDK returns
Lambda Functions in a public subnet can NOT access the internet. If you are aware of this limitation and would still like to place the function int a public subnet, set `allowPublicSubnet` to true
  • Python script
        vpc = ec2.Vpc.from_lookup(self, "VPC",
            vpc_id = "vpc-12345678"
        )
​
        eks_cluster = eks.Cluster(self, "EKS_Cluster",
            endpoint_access=eks.EndpointAccess.PRIVATE,
            default_capacity=0,
            version=eks.KubernetesVersion.V1_17,
            cluster_name="micro-k8s-dev",
            vpc=vpc,
            vpc_subnets=[ec2.SubnetSelection(subnets=[
                ec2.Subnet.from_subnet_id(self, 'nonprod-vm-pub-a', 'subnet-2jh3j2h34jh234jhjh')],
                ec2.Subnet.from_subnet_id(self, 'nonprod-vm-pub-b', 'subnet-2jh3j2h34jh234jhjh'),
                ec2.Subnet.from_subnet_id(self, 'nonprod-k8s-pri-a', 'subnet-2jh3j2h34jh234jhjh'),
                ec2.Subnet.from_subnet_id(self, 'nonprod-k8s-pri-b', 'subnet-2jh3j2h34jh234jhjh')],
]]
            )

What did you expect to happen?

Cluster is created successfully

What actually happened?

Following error

Lambda Functions in a public subnet can NOT access the internet. If you are aware of this limitation and would still like to place the function int a public subnet, set `allowPublicSubnet` to true

Environment

  • CDK CLI Version : 1.73.0
  • OS : MacOS Catalina
  • Language (Version): Python (3.8.2)

This is 🐛 Bug Report

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Hey, you were right I was encountering the 2nd issue, the fix mentioned solved it!