AWS Builder Center
Building a Secure VPC: A Beginner's Guide

Building a Secure VPC: A Beginner's Guide

The core building blocks of a secure VPC explained without the networking jargon.

Series: AWS Security 30 Days, 30 Articles Challenge (31 articles)

  1. …
  2. 14
    Building a Secure VPC: A Beginner's Guide This article
Welcome to Day 13 of the 30 Days AWS Security Challenge. That wraps up week two on data and network protection. Today we bring the last few days together and walk through what a secure VPC actually looks like, piece by piece, from the ground up.

What a VPC Actually Is

A VPC, short for Virtual Private Cloud, is your own isolated network inside AWS. Think of it as a private section of the cloud reserved just for your resources, where you control the IP ranges, subnets, and traffic rules. Every EC2 instance, RDS database, and load balancer you launch lives inside a VPC, whether you set one up deliberately or used the default one AWS creates for you.
Security in a VPC comes down to a handful of core building blocks working together. Let's go through them in the order you'd typically design them.

Step One: Plan Your IP Address Range

When you create a VPC, you assign it a range of IP addresses, called a CIDR block, like  10.0.0.0/16 . This range determines how many addresses are available for everything inside the VPC. Pick a range that gives you enough room to grow without overlapping with other networks you might need to connect to later, like an office network or another VPC.

Step Two: Split Into Public and Private Subnets

A subnet is a smaller slice of your VPC's IP range, usually tied to a specific availability zone. The most important security decision here is separating public subnets from private subnets.
  • Public subnets have a route to the internet and are meant for resources that genuinely need to be reachable from outside, like a load balancer.
  • Private subnets have no direct route to the internet and are meant for resources like databases and application servers that should never be reached directly from outside your network.
A common, secure pattern is placing your load balancer in a public subnet, while your application servers and databases sit in private subnets behind it, only reachable through that load balancer.

Step Three: Control Routing Carefully

Each subnet is tied to a route table, which decides where traffic goes. A public subnet's route table includes a route to an internet gateway, allowing direct internet access. A private subnet's route table should not include that route. Instead, if resources in a private subnet need outbound internet access, like downloading software updates, they go through a NAT gateway placed in a public subnet, which allows outbound requests without exposing anything to inbound traffic from outside.

Step Four: Layer Your Security Groups and NACLs

This is where Day 12's lesson comes into play directly. Set Security Groups on each resource with the narrowest access that still works. A database's Security Group, for example, should only allow inbound traffic from your application server's Security Group, not from a broad IP range or the whole internet.
Use Network ACLs at the subnet level as an additional layer, particularly useful for blocking known bad traffic across an entire private subnet without needing to touch every individual resource.

Step Five: Limit Access Points Into the VPC

Every way into your VPC is worth reviewing deliberately. This includes internet gateways, VPN connections, and any peering connections to other VPCs. Avoid leaving unused gateways or peering connections active, since each one is a potential path in that needs its own security review.
If you need administrative access to instances in private subnets, avoid opening direct SSH access from the internet. A more secure pattern is using a bastion host in a public subnet with tightly restricted access, or better, using AWS Systems Manager Session Manager, which lets you connect to instances without opening any inbound ports at all.

Step Six: Turn On VPC Flow Logs

Flow Logs capture information about the traffic flowing through your VPC, including source, destination, port, and whether it was accepted or rejected. Without this, you have no visibility into what is actually happening on your network.
Enable Flow Logs under VPC > your VPC > Flow Logs > Create flow log, sending them to CloudWatch Logs or S3 for later review.

Putting It All Together

A solid, beginner friendly secure VPC layout looks roughly like this: a public subnet holding your load balancer and NAT gateway, private subnets holding your application servers and database, Security Groups scoped tightly between each layer, no direct SSH from the internet, and Flow Logs turned on so you can see what is actually happening.

Key Takeaways

  • Separate public and private subnets, and only put resources in public subnets if they truly need direct internet access
  • Route tables control where traffic can actually go, keep private subnets off the internet gateway
  • Scope Security Groups tightly between layers, like allowing your database to hear only from your application tier
  • Avoid direct SSH from the internet, use a bastion host or Session Manager instead
  • Turn on VPC Flow Logs so you have visibility into your network traffic
That closes out week two. Tomorrow we start week three, shifting from prevention into monitoring and detection, beginning with AWS CloudTrail and how it logs every action in your account.

Series: AWS Security 30 Days, 30 Articles Challenge (31 articles)

  1. …
  2. 14
    Building a Secure VPC: A Beginner's Guide This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article