The Exact Error
The CIDR '10.0.1.0/24' conflicts with another subnet
Or in Terraform:
Error: creating EC2 Subnet: InvalidSubnet.Conflict: The CIDR '10.0.0.0/24' conflicts with another subnet.
Or for VPC peering:
InvalidVpcPeeringConnectionState: Cannot create a peering connection between VPCs with overlapping CIDR blocks
Quick summary: Two subnets (or two peered VPCs) share an overlapping IP address range. AWS requires all subnets within a VPC to have non-overlapping CIDRs.
Why This Error Happens
CIDR notation defines a range of IP addresses. 10.0.0.0/24 means all IPs from 10.0.0.0 to 10.0.0.255. If you create a subnet whose CIDR shares any IP with an existing subnet, AWS rejects it.
Four root causes:
1. Subnets in the same VPC overlap ā Creating a second subnet with a CIDR that includes addresses already claimed.
2. VPC peering with overlapping ranges ā Both VPCs use 10.0.0.0/16 ā peering is impossible.
3. On-premises network conflict ā VPC connected to corporate network via VPN when both use the same RFC 1918 range.
4. Copy-paste from a template ā Reusing the same Terraform template without updating CIDR blocks per environment.
Step-by-Step Diagnosis
Step 1 ā List all existing subnets and their CIDRs
aws ec2 describe-subnets --filters "Name=vpc-id,Values=vpc-xxxxxxxx" --query 'Subnets[*].[SubnetId,CidrBlock,AvailabilityZone]' --output table
Step 2 ā Calculate the address range of your new CIDR
For 10.0.1.0/24:
- Range:
10.0.1.0ā10.0.1.255 - If any existing subnet overlaps this range, you'll get the conflict.
Step 3 ā Check both VPCs' CIDRs for peering
aws ec2 describe-vpcs --vpc-ids vpc-aaa --query 'Vpcs[*].CidrBlock'
aws ec2 describe-vpcs --vpc-ids vpc-bbb --query 'Vpcs[*].CidrBlock'