AWS VPC & Subnets For Beginners

3 min read 2 months ago
Published on Apr 03, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Introduction

In this tutorial, you will learn how to set up a custom Virtual Private Cloud (VPC) on Amazon Web Services (AWS) that includes both public and private subnets. This guide is designed for beginners, providing straightforward steps to enhance your understanding of AWS networking.

Step 1: Understanding VPC

  • A Virtual Private Cloud (VPC) is a virtual network dedicated to your AWS account.
  • It allows you to define your own network topology, including subnets, IP address ranges, and security settings.
  • It is important for isolating resources and controlling access to them.

Step 2: Setting Up a VPC

  1. Log in to AWS Management Console:

    • Navigate to the VPC dashboard.
  2. Create a new VPC:

    • Click on "Your VPCs".
    • Select "Create VPC".
    • Enter a name, choose an IPv4 CIDR block (e.g., 10.0.0.0/16), and select options for IPv6 if needed.
    • Click "Create".
  3. Configure the VPC:

    • Review and note down your VPC ID for later use.

Step 3: Creating Subnets

  1. Go to Subnets:

    • In the VPC dashboard, select "Subnets".
  2. Create a Public Subnet:

    • Click on "Create Subnet".
    • Choose the VPC you created.
    • Specify a name, select an Availability Zone, and input a CIDR block (e.g., 10.0.1.0/24).
    • Check the box to create a public subnet.
  3. Create a Private Subnet:

    • Repeat the previous steps, using a different CIDR block (e.g., 10.0.2.0/24) for the private subnet.

Step 4: Setting Up an Internet Gateway

  1. Add an Internet Gateway:

    • In the VPC dashboard, click on "Internet Gateways".
    • Select "Create Internet Gateway".
    • Name the gateway and attach it to your VPC.
  2. Update Route Tables:

    • Navigate to "Route Tables" in your VPC dashboard.
    • Select the route table associated with your public subnet.
    • Edit the routes to add a rule that directs traffic to the Internet Gateway (0.0.0.0/0).

Step 5: Launching an EC2 Instance in the Custom VPC

  1. Go to EC2 Dashboard:

    • Select "Instances" and click "Launch Instance".
  2. Select an AMI and Instance Type:

    • Choose an Amazon Machine Image (AMI) and instance type as per your requirements.
  3. Configure Instance Settings:

    • Under "Network", select your newly created VPC.
    • Choose the public subnet for public access or the private subnet for internal access.
    • Configure other settings as needed.
  4. Launch the Instance:

    • Review your settings and click "Launch".

Step 6: Deploying to the Private Subnet

  • If deploying applications that do not require direct internet access, ensure they are launched in the private subnet.
  • Use a NAT Gateway or NAT Instance if you want instances in the private subnet to access the internet for updates or downloads.

Step 7: Setting Up Reverse Proxy

  • If you need to route requests to different instances or services
    • Consider using a reverse proxy setup.
    • This can typically be done with software like Nginx or HAProxy, which can be installed on an EC2 instance in your public subnet.

Conclusion

In this tutorial, you learned how to create a custom VPC with public and private subnets on AWS, configure an Internet Gateway, and launch EC2 instances. This foundational knowledge will help you in deploying secure and isolated applications on AWS. For further exploration, consider looking into additional AWS networking features or more advanced setups like Load Balancing.