0Pricing
Terraform Infrastructure as Code · Lesson

Configuring VPC and Networking

Provision an AWS Virtual Private Cloud, subnets, and security groups with Terraform to give your infrastructure a secure, isolated network foundation.

Why a Custom VPC?

Every AWS account ships with a default VPC, but production infrastructure deserves a network you design yourself. A VPC (Virtual Private Cloud) is an isolated section of the AWS cloud where you control IP ranges, subnets, routing, and firewalls.

With Terraform you describe the entire network as code, so it is reproducible across regions and accounts.

Declaring the VPC Resource

The aws_vpc resource is the root of your network. The CIDR block defines the private IP range. A /16 block gives you roughly 65,000 addresses to carve into subnets.

resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_support   = true
  enable_dns_hostnames = true

  tags = {
    Name = "main-vpc"
  }
}

All lessons in this course

  1. AWS Provider Configuration
  2. Provisioning EC2 Instances
  3. Managing S3 Buckets and IAM
  4. Configuring VPC and Networking
← Back to Terraform Infrastructure as Code