DEV Community

Chidi
Chidi

Posted on

# How to Create a VPC and Subnets on AWS

🚀 Beginner’s Guide: How to Create a VPC and Subnets on AWS (Step-by-Step)

If you’re just getting started with AWS networking, creating your first VPC and subnets might sound complicated — but trust me, it’s easier than it looks.

In this guide, you’ll learn step by step how to set up your Virtual Private Cloud (VPC) and subnets on AWS.


🧠 What’s a VPC?

A VPC (Virtual Private Cloud) is your own private network inside AWS.

Think of it as a virtual data center — you decide the IP ranges, subnets, and how resources talk to each other securely.
Let’s dive in! 👇


🧭 Step 1: Log in to AWS Console

Go to AWS Console and sign in. Once logged in, search for VPC in the search bar and open the VPC Dashboard.


🏗️ Step 2: Create a New VPC

  1. In the VPC Dashboard, click “Create VPC.”
  2. Under Resources to create, select VPC only.
  3. Fill in the details:
    • Name tag: MyFirstVPC
    • IPv4 CIDR block: 10.0.0.0/16
    • Tenancy: Default
  4. Click Create VPC.

Create a New VPC

Create a New VPC

Create a New VPC

Create a New VPC
Boom! You’ve created your first VPC.


🌍 Step 3: Create Subnets

Subnets divide your VPC into smaller sections — typically one per Availability Zone (AZ) for high availability.

Let’s create three subnets.

  1. On the left panel, click Subnets → Create subnet.
  2. Under VPC ID, select your MyFirstVPC.
  3. Add the following subnets:
Subnet Name Availability Zone IPv4 CIDR Block
Public-Subnet-A us-east-1a 10.0.0.0/24
Public-Subnet-B us-east-1b 10.0.1.0/24
Private-Subnet-A us-east-1a 10.0.2.0/24

Create Subnets

Create Subnets

Create Subnets

Create Subnets

Create Subnets
Click Create subnet.


🌐 Step 4: Enable Auto-Assign Public IP for Public Subnets

This ensures instances in your public subnets can connect to the internet.

  1. Select Public-Subnet-A.
  2. Click Actions → Edit subnet settings.
  3. Enable Auto-assign IP settings → check Auto-assign IPv4.
  4. Save changes.
  5. Repeat for Public-Subnet-B.

Step 4: Enable Auto-Assign Public IP for Public Subnets

for private subnet

for public subnet


🛣️ Step 5: Create and Attach an Internet Gateway

An Internet Gateway (IGW) allows your VPC to communicate with the internet.

  1. In the VPC Dashboard, go to Internet Gateways.
  2. Click Create Internet Gateway.
    • Name: MyVPC-IGW
  3. Click Create Internet Gateway, then Attach to VPC → select your MyFirstVPC.

Internet gateway

Internet gateway

Internet gateway

Internet gateway

🗺️ Step 6: Update Route Tables

We’ll connect our public subnets to the internet through the Internet Gateway.

  1. Go to Route Tables in the VPC Dashboard.
  2. Select the route table linked to MyFirstVPC.
  3. Under Routes, click Edit routesAdd route:
    • Destination: 0.0.0.0/0
    • Target: Internet Gateway (MyVPC-IGW)
  4. Click Save changes.
  5. Under Subnet Associations, associate your Public Subnets (A & B) with this route table.

✅ Step 7: Verify Everything

Head back to your VPC → Subnets, and confirm:

  • You have 3 subnets (2 public, 1 private).
  • Public subnets have auto-assign IPs enabled.
  • Your route table connects to the Internet Gateway.

🎉 Congratulations — you’ve successfully created a VPC with subnets on AWS!


Top comments (0)