I am trying to spawn EKS Cluster using AWS CDK. The problem is the following:
when I define a VPC for the EKS Cluster, which does not contain private subnets, cdk synth
throws the error below.
Vpc definition and usage:
cluster = eks.Cluster(self, "airflow-eks",
endpoint_access=eks.EndpointAccess.PUBLIC,
vpc=ec2.Vpc(self, "airflow-eks-vpc", cidr="172.16.0.0/22", max_azs=2,
subnet_configuration=[
ec2.SubnetConfiguration(
name="subnet-1",
cidr_mask=27,
subnet_type=ec2.SubnetType.PUBLIC
),
ec2.SubnetConfiguration(
name="subnet-2",
cidr_mask=27,
subnet_type=ec2.SubnetType.PUBLIC
)
]
),
The error is:
jsii.errors.JSIIError: There are no 'Private' subnet groups in this VPC. Available types: Public
When I add extra private subnet to the cluster definition, like
ec2.SubnetConfiguration(
name="subnet-3",
cidr_mask=27,
subnet_type=ec2.SubnetType.PRIVATE
)
cdk synth
works well.
I would like to know if it is possible to spawn a EKS Cluster without creating private subnets, as I do not need them at all, and there are extra costs for using private subnets. In Terraform it can be done for sure, what about AWS CDK?