Sub topic 9
PrivateLink: exposing a service, not a network
This chapter assumes you know CIDR blocks, subnets, route tables, security groups, and what a Network Load Balancer (NLB) does. It introduces the PrivateLink model. The next chapters build the provider and consumer sides.
The problem peering and Transit Gateway don't solve
Peering and Transit Gateway join networks. Once two VPCs are connected, any address in one can be routed to any address in the other, subject to security groups and network ACLs. That is the wrong shape when you only want to share one service. It also fails when the two VPCs have overlapping CIDR ranges, because routes cannot tell the two address spaces apart.
AWS PrivateLink exposes one service to other VPCs without connecting the networks. The consumer never receives a route to the provider's VPC.
Provider and consumer
PrivateLink has two roles:
- The provider owns the service. It puts the service behind a Network Load Balancer and publishes that NLB as an endpoint service.
- The consumer wants to call the service. It creates an interface endpoint in its own VPC.
An interface endpoint is a set of elastic network interfaces (ENIs), one per chosen subnet. Each ENI has a private IP address from the consumer's subnet. The consumer sends traffic to those addresses, and AWS carries it over its own network to the provider's NLB.
What this model gives you
- One-way access. Connections start at the consumer and go to the service. The provider cannot open connections back into the consumer VPC through the endpoint.
- No address coordination. Neither side sees the other's CIDR. The provider sees traffic arriving from the NLB's private addresses, not from consumer IPs. Overlapping ranges are not a problem.
- A small attack surface. The consumer reaches only the listeners on the NLB, not the provider's subnets or instances.
- Cross-account use. Providers decide who may connect, and consumers can be in other accounts.
What it costs you
- The service must sit behind an NLB (or a Gateway Load Balancer for appliance use cases). You cannot publish an arbitrary instance.
- Traffic is limited to what the NLB supports, which is TCP, UDP, and TLS. You can't send general IP traffic such as ping.
- You pay hourly per endpoint per Availability Zone, plus a per-GB data processing charge.
- A provider's NLB must be in the Availability Zones that the consumer's endpoint subnets use, or the endpoint can't be created in those zones.
Choosing PrivateLink
| Requirement | Better fit |
|---|---|
| Many VPCs need full, any-to-any IP reachability | Transit Gateway |
| One service shared with many consumers, possibly in other accounts | PrivateLink |
| Overlapping CIDRs between parties | PrivateLink |
| Consumer must not be able to scan the provider network | PrivateLink |
Exercise
A SaaS team in one account wants 200 customer VPCs, some with the same 10.0.0.0/16 range, to call its API privately. Why does PrivateLink fit, and what must the team put in front of the API?
Show answer
PrivateLink gives each customer a private entry point to just the API, with no routes between VPCs, so overlapping CIDRs don't matter and customers can't reach the provider's network. The team must place the API behind a Network Load Balancer and publish that NLB as an endpoint service.