I would like to create a VPC in AWS with a private subnet and a public subnet. I am using Terraform.
Here is what I have so far:
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16" # <---
enable_dns_support = true
enable_dns_hostnames = true
tags = {
Name = "Main"
}
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.0.0/20" # <---
tags = {
Name = "Public"
}
}
resource "aws_subnet" "private" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.16.0/20" # <---
tags = {
Name = "Private"
}
}
The problem I am having is that I don't know how to choose appropriate CIDR blocks (3 to decide).
How do I determine what CIDR blocks to use?
A working combo might be:
- VPC:
10.16.0.0/16
- Public:
10.16.0.0/24
- Private:
10.16.128.0/24