No history yet

VPC Basics

Your Private Corner of the Cloud

Think of the AWS cloud as a massive, bustling city. It has public spaces, infrastructure, and countless other tenants. A Virtual Private Cloud, or VPC, is like getting your own private, fenced-off estate within that city. You control who comes in and out, where the roads go, and how everything inside is arranged.

Amazon Virtual Private Cloud (VPC) lets you provision a logically isolated section of the AWS Cloud where you can launch AWS resources in a virtual network that you define.

This logical isolation is the key. It gives you a secure, private space to run your applications and store your data, completely separate from other AWS customers. You get to define your own virtual network, mimicking a traditional network that you might operate in your own data center, but with the benefits of using AWS's scalable infrastructure.

The Building Blocks

A VPC isn't just an empty box; it's made up of several key components that work together to manage your network traffic.

Subnet

noun

A range of IP addresses in your VPC. Think of a subnet as a smaller, segmented network within your larger VPC network.

You can have different types of subnets for different purposes. A public subnet is one whose traffic can be routed to an internet gateway, meaning resources within it can directly access the internet. A private subnet, on the other hand, does not have a direct route to the internet. This is ideal for things like databases that you want to shield from public access.

Every VPC needs a range of private IP addresses. You define this using Classless Inter-Domain Routing (CIDR) notation. It looks something like this:

10.0.0.0/16

This notation defines the starting IP address and the size of the network. A /16 block provides 65,536 private IP addresses for your resources. Each subnet you create then gets a smaller slice of this main address block.

To direct traffic, a VPC uses route tables. A route table is like a traffic cop for your network. It contains a set of rules, called routes, that determine where network traffic from your subnet is directed. For instance, a route table for a public subnet will have a route that points internet-bound traffic to an Internet Gateway (IGW). The IGW is the component that allows communication between your VPC and the internet.

But what if a resource in a private subnet, like a server, needs to download a software update from the internet? It can't go through an IGW directly. For this, you use a NAT (Network Address Translation) Gateway. A NAT gateway sits in a public subnet and allows resources in your private subnets to initiate outbound traffic to the internet, but prevents the internet from initiating a connection with those resources. It's like a one-way door to the outside world.

Securing Your Network

A VPC provides two main layers of security: security groups and network access control lists (ACLs).

Security Groups act as a virtual firewall for your EC2 instances to control inbound and outbound traffic. When you launch an instance, you associate one or more security groups with it. They are stateful, which means if you allow an incoming request, the corresponding outgoing response is automatically allowed, regardless of outbound rules.

Network ACLs, on the other hand, are an optional layer of security for your VPC that acts as a firewall for controlling traffic in and out of one or more subnets. They are stateless, which means you must explicitly define rules for both inbound and outbound traffic. Responses to allowed inbound traffic are subject to the rules for outbound traffic (and vice versa).

FeatureSecurity GroupNetwork ACL
LevelInstance levelSubnet level
StateStatefulStateless
RulesAllow rules onlyAllow and deny rules
DefaultAllows all outbound, denies all inboundAllows all traffic in and out

Think of a security group as the bouncer at the door of a single club (your instance). A network ACL is like the guard at the entrance to the entire neighborhood (your subnet).

Sometimes, you need to connect two VPCs. For instance, different departments in your company might have their own VPCs. A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 or IPv6 addresses. It's like creating a private, direct hallway between two separate estates. Instances in either VPC can communicate with each other as if they are within the same network.

Quiz Questions 1/5

What is the primary purpose of an Amazon Virtual Private Cloud (VPC)?

Quiz Questions 2/5

You need to place a database in your VPC. For security reasons, it should not be directly accessible from the internet, but it must be able to download software patches. Which setup should you use?

Understanding VPCs is fundamental to building secure and scalable applications on AWS. By controlling your own virtual network, you gain fine-grained control over your cloud environment.