Lesson 1 of 4 ยท AWS with Terraform
AWS VPCs and subnets
In AWS, a VPC is your network boundary and subnets divide it into workload areas. Start with a VPC, then add intentional public and private subnets before attaching application services.
Example
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
}Step by step
- Create the VPC.
- Create subnets inside its CIDR range.
- Decide which workloads belong in each subnet.
- Review routes before exposing services.
Common mistakes to avoid
- Using a subnet CIDR outside the VPC range.
- Placing databases beside public entry points by default.