Create your own VPC, subnet and Internet Gateway

Published: (December 23, 2025 at 06:00 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

What I built

  • A VPC (Virtual Private Cloud)
  • A public subnet within the VPC
  • An Internet Gateway (IGW) attached to the VPC

These components together create a functional and secure network inside AWS.

How the components connect

VPC creation

  1. Assigned a name to the VPC.
  2. Defined an IPv4 CIDR block (e.g., 10.0.0.0/16).
    • The CIDR block defines the IP address range available inside the VPC.
    • Think of the VPC as a boundary where all networking rules apply.

Public subnet creation

  1. Created a subnet inside the VPC and assigned it a CIDR block that falls within the VPC’s range.
  2. Enabled Auto‑assign Public IPv4 Address in the subnet settings.
  3. Selected an Availability Zone (AZ) for the subnet, improving fault tolerance and availability.

Why a public subnet?

  • It is accessible from the internet.

Internet Gateway (IGW)

  1. Created an Internet Gateway.
  2. Attached the IGW to the VPC.

The IGW acts as a bridge between the VPC and the external internet. Without an IGW, even a “public” subnet cannot send or receive internet traffic.

Core networking concepts

VPC overview

  • An isolated virtual network within AWS.
  • Allows you to:
    • Secure resources
    • Control inbound and outbound traffic
    • Design custom network architectures

Analogy: A VPC is like Google Drive; a subnet is a logical subdivision used to group similar resources.

Subnet types

  • Public Subnet: Can communicate with the internet.
  • Private Subnet: No direct internet access (ideal for databases, backend services).

A single VPC can contain multiple subnets, each belonging to one Availability Zone.

CIDR (Classless Inter-Domain Routing)

  • Defines the IP address range for a network.
  • Example: 10.0.0.0/8
    • 10.0.0.0 → Network address
    • /8 → Number of bits used for the network portion

Key takeaway:

  • Smaller slash number = larger IP range
  • Larger slash number = smaller IP range

Planning tip: You cannot change a VPC CIDR block later, so careful planning is essential to avoid scaling issues.

Key takeaways

  • VPCs exist to provide isolated, secure networking environments in AWS.
  • Subnets organize resources and can be public or private depending on required internet access.
  • An Internet Gateway is mandatory for any internet‑facing architecture.
  • Proper CIDR planning is crucial for future scalability.

Conclusion

This hands‑on project clarified AWS networking fundamentals by showing how VPCs, subnets, and Internet Gateways work together. Understanding these concepts makes it easier to design secure and scalable cloud architectures.

Part 1 of the AWS Networking series.

Back to Blog

Related posts

Read more »

Terraform Data Source (AWS)

What Are Terraform Data Sources? A data source in Terraform is a read‑only lookup to an existing resource. Instead of creating something new, Terraform queries...

Day-13: Data sources in Terraform

What are Data Sources? You can use data sources to fetch information about existing VPCs, subnets, AMIs, security groups, etc. hcl data 'data_source_type' 'dat...