Setting Up VPC with Public and Private Subnets in AWS

Prepared by: Anwer Sadath Abdhul Muttaliff

Project Overview

This project demonstrates how to create a Virtual Private Cloud (VPC) with one public and one private subnet, configure an Internet Gateway and a NAT Gateway, and launch EC2 instances in both subnets. The setup ensures secure and functional network architecture.

Network Architecture Overview

Network Architecture Diagram

Steps and Explanations

Step 1: Create a VPC

Go to the VPC Dashboard and create a VPC with the following settings:

Create VPC
Step 2: Create Subnets

Create a public and private subnet within the VPC:

Create Public Subnet Create Private Subnet
Step 3: Launch EC2 Instance in Public Subnet

Launch an EC2 instance in the public subnet with the following settings:

Network Settings
Step 4: Create and Attach Internet Gateway

Create an Internet Gateway and attach it to the VPC to enable internet access for the public subnet.

Step 5: Create Route Tables

Create separate route tables for the public and private subnets.

Create Public Route Table Create Private Route Table
Step 6: Associate Route Tables with Subnets

Associate the public route table with the public subnet and the private route table with the private subnet.

Step 7: Add Routes to Route Tables

Add a route to the public route table to allow internet access via the Internet Gateway.

Step 8: Launch EC2 Instance in Private Subnet

Launch an EC2 instance in the private subnet with the following settings:

Step 9: Create NAT Gateway

Create a NAT Gateway in the public subnet to allow private subnet instances to access the internet.

Step 10: Update Route Table for Private Subnet

Add a route to the private route table to allow internet access via the NAT Gateway.

Step 11: Test Connectivity

SSH into the public instance and use it to access the private instance. Verify that the private instance can access the internet for updates.

sudo yum update -y

Conclusion

By following these steps, you have successfully set up a VPC with public and private subnets, configured Internet and NAT gateways, and tested connectivity. This setup ensures secure and functional network architecture in AWS.

Back to Top Back to Home