Networking on AWS — VPCs, Route 53 and connections to AWS
Every server, database and container on AWS sits on a network. Amazon Virtual Private Cloud (Amazon VPC) lets you build that network yourself: your own private section of AWS where you choose the IP addresses, split them into subnets, and decide exactly what traffic may come in and go out.
The parts of a VPC
| Part | What it does |
|---|---|
| VPC | Your private network in one Region, with an IP address range you choose, such as 10.0.0.0/16 |
| Subnet | A slice of the VPC’s address range in one Availability Zone |
| Public subnet | A subnet whose route table sends internet traffic to an internet gateway; resources with public IP addresses can be reached from the internet |
| Private subnet | A subnet with no route to an internet gateway; used for databases and internal servers |
| Internet gateway | Connects the VPC to the internet |
| NAT gateway | Lets resources in private subnets start connections out to the internet (for software updates, say) without being reachable from it |
| Route table | Rules that decide where traffic from a subnet goes |
A common design: web servers in public subnets, databases in private subnets, each repeated in two or more Availability Zones for high availability.
Security in a VPC
You get two layers of firewall.
| Security group | Network ACL | |
|---|---|---|
| Protects | An instance or other resource (its network interface) | A whole subnet |
| Rules | Allow rules only | Allow and deny rules, checked in number order |
| State | Stateful: if a request is allowed in, the reply is allowed out automatically | Stateless: return traffic needs its own rule |
| Starting point | A new group allows no inbound and all outbound traffic | The default ACL allows all traffic; a new custom ACL denies all |
Example: a web server’s security group allows inbound HTTPS (port 443) from anywhere; the database’s security group allows port 3306 only from the web servers’ security group.
Amazon Inspector adds another check: it can report network paths that leave instances reachable in ways you did not intend.
Amazon Route 53: DNS
DNS (the Domain Name System) turns names like www.example.com into IP addresses. Amazon Route 53 is AWS’s highly available DNS service:
- Domain registration: buy and manage domain names.
- DNS hosting: answer DNS queries for your domains, from edge locations worldwide.
- Health checks: monitor your endpoints and stop sending users to unhealthy ones.
- Routing policies: send users to the endpoint with the lowest latency, fail over to a backup site, split traffic by weight, or route by the user’s location.
Connecting your network to AWS
| Option | What it is | Choose it for |
|---|---|---|
| AWS Site-to-Site VPN | An encrypted tunnel over the public internet between your network and a VPC | Quick setup and lower cost |
| AWS Client VPN | VPN connections from individual users’ devices | Remote employees reaching private resources |
| AWS Direct Connect | A dedicated, private network connection from your data center to AWS | Consistent performance, high bandwidth, traffic that stays off the public internet |
Many companies use Direct Connect as the main link and a Site-to-Site VPN as a backup.
Other network services you may see
- Amazon CloudFront: a content delivery network that caches content at edge locations.
- AWS Global Accelerator: routes users over AWS’s global network for better performance.
- AWS Transit Gateway: a central hub connecting many VPCs and on-premises networks.
- AWS PrivateLink: private access to services without going over the internet.
Putting it together: a three-tier app
- A VPC with address range
10.0.0.0/16in the Frankfurt Region. - In each of two AZs: a public subnet with a load balancer, and private subnets for the application servers and an RDS database.
- Security groups allow HTTPS to the load balancer, application traffic only from the load balancer, and database traffic only from the app servers.
- A NAT gateway lets private servers download updates.
- Route 53 points
shop.example.comat the load balancer. - The company’s office connects over Site-to-Site VPN for administrators.
Common mix-ups
- Security group vs network ACL. Instance level, stateful, allow-only vs subnet level, stateless, allow and deny.
- Internet gateway vs NAT gateway. An internet gateway allows two-way internet access for public subnets; a NAT gateway allows only outbound access for private subnets.
- VPN vs Direct Connect. A VPN is encrypted over the internet and quick to set up; Direct Connect is a private dedicated line, more consistent but slower to set up.
- A subnet is in one AZ, while a VPC spans all AZs in its Region.
Check yourself
Which firewall is stateful and applies to individual instances?
A security group.
A database must not be reachable from the internet, but needs to download patches. How?
Put it in a private subnet and give that subnet a route to a NAT gateway.
A company needs a consistent, high-bandwidth private connection from its data center to AWS. Which service?
AWS Direct Connect.
Which service registers domain names and routes users to the healthiest endpoint?
Amazon Route 53.
Key takeaways
- A VPC is your private network in a Region, split into subnets that each live in one AZ.
- Public subnets route to an internet gateway; private subnets do not, and use a NAT gateway for outbound traffic.
- Security groups (stateful, instance) and network ACLs (stateless, subnet) control traffic.
- Route 53 is DNS; Site-to-Site VPN and Direct Connect connect your network to AWS.
Cloud Study Lab is an independent study site. It is not affiliated with or endorsed by Amazon Web Services. AWS and the names of AWS certifications are trademarks of Amazon.com, Inc. or its affiliates.