https://pulumi.com logo
#aws
Title
# aws
c

chilly-thailand-69363

02/03/2024, 11:44 PM
Hi all, Just started using Pulumi and playing with it to create a simple nginx in EKS. I tried simple tutorials but I keep seeing the following error and not sure how to resolve it: creating EC2 Subnet: InvalidSubnet.Conflict: The CIDR '10.0.1.0/24' conflicts with another subnet This is my (partial) code: vpc_network_cidr = "10.0.0.0/16" # Create a VPC for the EKS cluster eks_vpc = awsx.ec2.Vpc("eks-vpc", _enable_dns_hostnames_=True, _enable_dns_support_=True, _cidr_block_=vpc_network_cidr) subnet1 = aws.ec2.Subnet("my-subnet-1", _vpc_id_=eks_vpc.vpc_id, _cidr_block_="10.0.1.0/24", _availability_zone_="us-east-1c") I checked my aws console and find a default VPC and subnets with addresses that falls in the range 172.31.0.0. Not sure where the conflict is coming from. Some tutorials don't mention subnets at all while creating EKS cluster, but if I do that, Pulumi tries to create the cluster in a zone that does not have the capacity, so it fails. I thought one way I can fix this is to specify the subnet in a different region and use that during cluster creation. Am I right? What am I missing here? Any help appreciated 🙂
c

cuddly-journalist-77210

02/04/2024, 4:37 AM
awsx.Vpc will automatically create subnets for you with sane default configurations. use aws.Vpc if you just want empty VPC with no subnets.
Also for using specific availability zones, you can use this argument with awsx.Vpc: https://www.pulumi.com/registry/packages/awsx/api-docs/ec2/vpc/#availabilityzonenames_nodejs
c

chilly-thailand-69363

02/04/2024, 11:27 AM
Thanks Mahesh, it is working now with this solution.