Interview Prep/AWS/VPC and Connectivity

`InvalidSubnet.Conflict: The CIDR '10.0.1.0/24' conflicts with another subnet` when creating a subnet.

BeginnerTroubleshootingVPC and Connectivity
Answer

Likely causes → The CIDR overlaps an existing subnet in the same VPC. A related error, InvalidSubnet.Range: The CIDR '10.1.0.0/24' is invalid, means the block is outside the VPC CIDR(s) or smaller than /28.

Diagnose →

aws ec2 describe-vpcs --vpc-ids vpc-0abc --query 'Vpcs[].CidrBlockAssociationSet[].CidrBlock'
aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0abc \
  --query 'Subnets[].[SubnetId,CidrBlock,AvailabilityZone]' --output table

Fix →

  1. Pick a free, non-overlapping range inside the VPC CIDR
  2. If the VPC is full, add a secondary CIDR: aws ec2 associate-vpc-cidr-block --vpc-id vpc-0abc --cidr-block 10.1.0.0/16
  3. Then create the subnet inside the new range

Prevent → Plan subnets with IPAM or a documented CIDR map. Calculate subnets in Terraform with cidrsubnet() rather than typing them by hand.

aws All AWS questions Roadmap: AWS core services

More on VPC and Connectivity