VPCs, subnets, traffic controls and private connectivity

What a VPC is made of: the one route-table line that makes a subnet public, the two firewalls and which of them can refuse a single address, the ways out to the internet and to AWS services, and the two ways in from your own building.

Lesson 6 of 11 in objective 3. Cloud technology and services, part of AWS Certified Cloud Practitioner (CLF-C02).

The two firewalls in a VPC, and only one of them can refuse one address. Security group — Attached to: The network interface of an instance; Stateful: Yes — return traffic is allowed automatically; Rule types: Allow only; How the rules are read: All together; anything not allowed is already denied. Network ACL — Attached to: The subnet; Stateful: No — you permit each direction yourself; Rule types: Allow and deny; How the rules are read: In number order, until one matches Security group Network ACL Attached to The network interface of an instance The subnet Stateful Yes — return traffic is allowed automatically No — you permit each direction yourself Rule types Allow only Allow and deny How the rules are read All together; anything not allowed is already denied In number order, until one matches
The two firewalls in a VPC, and only one of them can refuse one address.

One line in a route table decides public from private

A VPC is your own network inside a Region, cut into subnets that each live in one Availability Zone. The entire public-versus-private distinction comes down to a single entry: a subnet is PUBLIC if its route table sends 0.0.0.0/0 to an internet gateway, and private if it does not. Nothing else about the subnet makes it one or the other, which is why "attach an internet gateway and route the private subnets to it" is a contradiction in terms rather than a design.

A route table chooses a next hop by DESTINATION address, and that is worth stating because a question will offer a route as a way to block an attacker. There is no source-based routing here, so you cannot route one client away; the tool that expresses "everyone except this address" belongs to the firewalls below.

The guest list and the blacklist

A security group is attached to an instance's network interface, contains allow rules only, and is stateful: traffic you permitted in is permitted back out without a matching rule. Every rule is evaluated together and anything not allowed is denied by default. That last property is the most common misconception on this objective in either direction — there is no deny rule to add, so you cannot subtract one address from a rule that allows the world.

A network ACL sits on the SUBNET, is stateless, and holds both allow and deny rules evaluated in number order until one matches. It is therefore the only one of the two that can express "keep the site public but refuse this one address", and it applies to everything in the subnet at once. Removing the rule that allows port 443 from the world would also work, in the sense that it stops the attacker and every genuine visitor together. For a flood at real scale the purpose-built tools are AWS WAF and AWS Shield.

Getting out, and staying on the AWS network

Instances in a private subnet that must fetch operating system patches need a way out that is not also a way in, and that is a NAT gateway: it translates connections the private instances START and returns the replies, while offering nothing an outside party can connect to. It lives in a public subnet, is scoped to one Availability Zone — so a resilient design has one per zone — and is billed per hour plus per gigabyte processed. Giving each server a public address instead satisfies the outbound half of the requirement and breaks the inbound half completely.

VPC endpoints give private access to AWS services without an internet gateway, a NAT gateway or a public address, and there are two kinds whose difference shows up on the bill. GATEWAY endpoints exist for Amazon S3 and DynamoDB, are entries in a route table, and carry no charge — which is why several terabytes a month of S3 traffic currently leaving through a NAT gateway is both a security answer and a cost answer. INTERFACE endpoints, powered by AWS PrivateLink, put a network interface with a private address in your subnet for most other services and are billed per hour and per gigabyte.

Three ways out of a subnet, and who is allowed to start the conversation. Internet gateway — Who can start a connection: Both directions; Where the traffic goes: Straight out to the internet; What it costs: Nothing itself — but the subnet is now public. NAT gateway — Who can start a connection: Outbound only; nothing outside can start one; Where the traffic goes: Out to the internet, replies come back; What it costs: Per hour, plus per gigabyte processed. VPC endpoint — Who can start a connection: Outbound, and only to AWS services; Where the traffic goes: Stays on the AWS network; What it costs: Gateway endpoints free; interface endpoints charged Internet gateway NAT gateway VPC endpoint Who can start a connection Both directions Outbound only; nothing outside can start one Outbound, and only to AWS services Where the traffic goes Straight out to the internet Out to the internet, replies come back Stays on the AWS network What it costs Nothing itself — but the subnet is now public Per hour, plus per gigabyte processed Gateway endpoints free; interface endpoints charged
Three ways out of a subnet, and who is allowed to start the conversation.

Reaching a VPC from your own building

A stem that mentions terabytes a day, performance that must not vary, traffic that never touches the public internet, and an accepted lead time of several weeks is describing AWS Direct Connect in four separate clauses. A stem that wants encryption, cheaply, this afternoon is describing an AWS Site-to-Site VPN. A common production arrangement is both, with the VPN standing by as the backup for the dedicated circuit.

Two neighbours are offered against these and neither reaches outside AWS. VPC peering connects one VPC to another, including across accounts and Regions, and has no concept of a data centre. AWS Transit Gateway is a hub that simplifies connecting many VPCs and on-premises links together, and it still needs a Direct Connect or a VPN underneath it to reach the building at all.

Two ways in from a data centre, answering two different worries. Site-to-Site VPN — The path: An encrypted tunnel over the public internet; Ready in: Under an hour, for very little money; What it buys: Privacy today, over whatever path the internet gives you. Direct Connect — The path: A dedicated physical circuit into AWS; Ready in: Weeks — a circuit is being provisioned; What it buys: Bandwidth and latency that do not vary with the internet Site-to-Site VPN Direct Connect The path An encrypted tunnel over the public internet A dedicated physical circuit into AWS Ready in Under an hour, for very little money Weeks — a circuit is being provisioned What it buys Privacy today, over whatever path the internet gives you Bandwidth and latency that do not vary with the internet
Two ways in from a data centre, answering two different worries.

DNS is a layer above the load balancer

Amazon Route 53 is the authoritative DNS service, and it answers one question: which address does this name resolve to. Its routing policies — simple, weighted, latency-based, failover, geolocation, geoproximity and multivalue — are how you express a global answer, and its health checks are what stop it handing out an endpoint that has stopped responding. It also registers domains.

Elastic Load Balancing answers a different question one level down: which of my healthy targets gets this request, inside one Region. Sending visitors to whichever of two Regional deployments answers them fastest therefore takes BOTH — a latency-based policy with health checks to choose the Region, and a load balancer inside each Region to spread the requests across instances and zones. A question offering only one of the two is testing whether the layers are separate in your head.

Worth carrying in

VPC
Your own network in one Region, cut into subnets that each sit in one Availability Zone.
Route table
Chooses the next hop by DESTINATION. 0.0.0.0/0 to an internet gateway is what makes a subnet public.
Internet gateway
The VPC's door to the internet, in both directions.
NAT gateway
Outbound-only for private subnets. One per zone for resilience; per hour and per gigabyte.
Security group
Instance-level, stateful, allow rules only. No deny exists.
Network ACL
Subnet-level, stateless, allow and deny, read in number order.
VPC endpoint
Private path to AWS services. Gateway for S3 and DynamoDB and free; interface via PrivateLink and charged.
AWS Direct Connect
A dedicated circuit. Consistent bandwidth and latency, weeks of lead time.
AWS Site-to-Site VPN
Encrypted tunnel over the internet. Fast to set up, as steady as the internet is.
Amazon Route 53
Authoritative DNS, routing policies and health checks. Chooses a Region, not a server.
AWS WAF
Filters HTTP requests by rule. With AWS Shield, the purpose-built answer to a flood.

What the exam does with this

Objective
3. Cloud technology and services
Share of the exam
34% (the whole objective)
Questions in this lesson
5
Signed for by a person
0

Partly checked. None of the 5 questions here has been read against the cited source by a person. 5 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.

Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.

Questions in this lesson

Drill this lesson

A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.

Practise VPCs, subnets, traffic controls and private connectivity

The rest of objective 3