Amazon VPC (Virtual Private Cloud) is the network where your resources live on AWS, and it is the first networking piece you need to understand for the exam. A network is a group of connected computers that can send data to each other. A VPC is built from its addresses, its subnets, its routes, its connection to the internet and the pieces that can be added to it.
What is a VPC?
A VPC is a virtual network isolated from the networks of other AWS customers, similar to the network of your own data center. Isolated means that nobody from another account can see or touch what is in it. In it you launch your EC2 instances, your RDS databases and your load balancers. For example, an online store puts in its VPC the servers for its website, the database with its orders and the load balancer that spreads the visits.
Each VPC lives in a Region. When you create it you choose a range of private IP addresses. An IP address is the number that identifies each resource on a network, and private ones only work inside your network, not on the internet. That range is written in CIDR notation, and it goes from a /16 (65,536 addresses) to a /28 (16 addresses), although for the exam you don't need to calculate ranges. For example, the store chooses a large range so it has enough addresses even if it adds many servers.
Creating a VPC has no additional cost, but some pieces you add to it, such as a NAT gateway, are billed. Also, every account comes with a default VPC in each Region, that is, one that AWS already created for you, ready to use, so you can launch your first EC2 instance without configuring any networking. For example, in your first lab you can launch an instance in the default VPC without creating any network.
Subnets
A subnet is a range of addresses within the VPC, that is, a part of the network where you group certain resources, and it lives entirely in a single Availability Zone. Each subnet is public or private depending on its connection to the internet. Because a subnet can't span two zones, an application that has to keep working if a zone goes down needs subnets in at least two zones, such as one public subnet and one private subnet in each zone. For example, the store puts its servers in subnets in two zones, and if one zone has a problem, customers keep shopping on the servers in the other.

What makes a subnet public?
A subnet is public or private depending on its connection to the internet: a public subnet can communicate directly with the internet, and a private one can't. That connection depends on two pieces, the internet gateway and the route table.
Internet gateway
The internet gateway is the piece that connects the VPC to the internet, so everything that comes in from the internet or goes out to the internet passes through it. AWS runs it as a redundant component, that is, with spare parts that keep working if one fails, and with high availability. AWS doesn't charge for the internet gateway, although the data transfer that goes through it is billed, that is, the data that moves across it. For example, the store doesn't pay for having its internet gateway, but it does pay for the data of the pages and photos it sends to its customers through it.
Route tables
A route table says where the traffic leaving a subnet goes. Each route has a destination, which is an IP range, and a target, which is where that traffic is sent. Each subnet uses a route table, and if you don't assign one to it, it uses the VPC's main route table. For example, a route can say that everything headed to the internet is sent through the internet gateway.

The route table of a public subnet and that of a private subnet both have the local route, which lets the subnets of the VPC communicate with each other. However, only the public subnet's table has the 0.0.0.0/0 route to the internet gateway, which means "send everything that isn't local to the internet".
That route to the internet gateway is what makes a subnet public. To communicate with the internet, an instance needs two things: to be in a subnet with that route and to have a public IP, which is an address that does work on the internet, or an Elastic IP. That is why, without the route, the instance doesn't reach the internet even if it has a public IP. For example, the store's test server is in a subnet with that route and has a public IP, so it can download programs from the internet.
cloud path tip: AWS recommends putting resources in private subnets whenever possible. In the public subnet put only what has to receive traffic from the internet, such as the load balancer.
NAT gateway
Sometimes the instances in a private subnet need to reach the internet, for example to download patches, without anyone outside being able to open a connection to them. For that case there is the NAT gateway, which goes out to the internet on behalf of the private instances.

When a private instance goes out to the internet, its route table sends 0.0.0.0/0 to the NAT gateway, which is in the public subnet of the same zone and has an Elastic IP, and from there the traffic goes out through the internet gateway. On the other hand, nobody on the internet can initiate a connection to the private instance. For example, the store's application servers are in a private subnet and download their patches through the NAT gateway, but nobody on the internet can connect to them.
Each NAT gateway lives in one zone, so if all the private subnets go out through the same NAT gateway and that zone fails, they are all left without internet. That is why AWS recommends one NAT gateway per zone. The NAT gateway is billed per hour and for each GB, that is, each gigabyte of data, it processes. For example, if the store has private subnets in two zones, it puts a NAT gateway in the public subnet of each zone and pays for both.
Other pieces of a VPC

Besides subnets, routes and gateways, on the exam you need to recognize four more pieces:
- VPC peering, which connects two VPCs so traffic can pass from one to the other. For example, the store connects the VPC of its site with the VPC where its sales team keeps its reports.
- VPC endpoint, which lets your resources reach AWS services privately, without an internet gateway or NAT, such as the gateway endpoints for S3 and DynamoDB, which are AWS services for storing files and data. For example, the store's private servers save the product photos in S3 without going over the internet.
- VPC Flow Logs, which captures information about the IP traffic of the VPC and is used to investigate problems. For example, if a server isn't receiving visits, the team checks that log to see what traffic reached it.
- AWS Transit Gateway, which is a central hub that many VPCs and on-premises networks connect to, so you don't have to connect each one with all the others. For example, a company with ten VPCs and two offices connects all of them to a single Transit Gateway instead of joining each one with every other.
On the exam
Questions on this topic ask you to recognize the piece, not to configure it. For example, if the question says that some private servers have to download updates without anyone on the internet being able to reach them, the answer is a NAT gateway. These phrases in the question point to each piece:
- "Isolated network" or "private network on AWS", which point to a VPC.
- "What makes a subnet public", which points to the route to the internet gateway.
- "Private instances that must reach the internet without receiving connections", which points to a NAT gateway.
- "Reach S3 or DynamoDB without going over the internet", which points to a VPC endpoint.
- "Connect many VPCs", which points to Transit Gateway, and "connect two VPCs", which points to VPC peering.
cloud path tip: if you use an account with the new AWS experience, VPC is included in the free plan, but Transit Gateway is not available until you turn on the advanced features.