AWS Certified Solutions Architect – Professional
Transit Gateway vs VPC peering vs PrivateLink for SAP-C03
The AWS Transit Gateway guide describes a transit gateway as a Regional virtual router whose route tables decide which attached VPCs and on-premises networks reach each other. The VPC peering guide describes a one-to-one, non-transitive link between two VPCs that cannot have overlapping CIDR blocks. AWS PrivateLink exposes one service behind a Network Load Balancer instead of joining networks.
What each option connects
A transit gateway routes at layer 3 between its attachments. Attachments can be VPCs, Site-to-Site VPN connections, Direct Connect gateways, Transit Gateway Connect attachments and peering connections to other transit gateways. One gateway can work across accounts, and it scales with the traffic volume. It is the choice when many VPCs and an on-premises network need one central routing point.
A VPC peering connection joins exactly two VPCs, in the same or different accounts and Regions. The owner of the accepter VPC must accept the request, and each owner then adds routes for the other VPC's range. Peering is not transitive: if A is peered with B and with C, B cannot reach C through A. A peered VPC also cannot use the other side's internet gateway, NAT device, VPN connection, Direct Connect connection or gateway endpoint.
PrivateLink shares a service and nothing else. The provider puts a Network Load Balancer in front of the service and creates an endpoint service for it. The provider grants specific AWS principals permission to connect. Each consumer creates an interface endpoint, which places network interfaces with addresses from the consumer's own subnets.
Overlapping CIDR blocks
AWS does not create a peering connection between VPCs with matching or overlapping CIDR blocks. This holds for a VPC with several blocks even if only the non-overlapping blocks would carry traffic. Adding a clean secondary CIDR block does not get around it.
A transit gateway does not solve it either. The transit gateway guide notes that the CIDR blocks of attached VPCs cannot overlap, which is why VPC attachments do not support equal-cost multipath routing.
With PrivateLink, clients connect to endpoint addresses inside their own VPC, so the design does not depend on a peering connection. An endpoint service is built on a Network Load Balancer. A service behind an Application Load Balancer needs a Network Load Balancer in front of it, with a target group of type alb that holds the one Application Load Balancer. Both load balancers must be in the same VPC and account. The target group protocol is TCP and its port must match the Application Load Balancer's listener port.
Isolating traffic with transit gateway route tables
Each attachment is associated with one transit gateway route table, and it can propagate its routes to one or more route tables. Associating groups of attachments with separate route tables makes the gateway act as several isolated routers. Attachments in one group cannot route to another group, because the route table they use has no route to it.
The gateway uses the most specific matching route. When a static and a propagated route have the same destination, the static route wins. A blackhole route drops matching traffic. This matters when each isolated route table also carries a static 0.0.0.0/0 route to a shared egress or inspection VPC. Traffic for another group's range then matches the default route. A blackhole route for the shared supernet in each group's route table drops it, while the more specific propagated routes of the group's own VPCs still work.
For a stateful appliance in a shared VPC, enable appliance mode on that VPC's attachment. The gateway then keeps a flow on the same Availability Zone in both directions. AWS guarantees this only when exactly one transit gateway connects to the appliance VPC, because transit gateways do not share flow state.
How the charges differ
A transit gateway is billed per attachment per hour, and it adds a data processing charge for every gigabyte sent to it from a VPC, Direct Connect or VPN attachment. The owner of the attached VPC pays the hourly charge, and the VPC owner that sends the traffic pays the processing charge. Standard data transfer charges still apply.
A peering connection costs nothing to create and has no processing charge. Data that stays inside one Availability Zone is free, including between accounts. Data that crosses Availability Zones or Regions is charged. For a very large flow between two VPCs, a peering connection with same-zone traffic is the lowest-cost path, and the transit gateway can keep carrying everything else.
Where the exam catches people
- Believing a hub VPC can route between its peered VPCs or share its VPN connection with them: peering is not transitive and does not allow edge-to-edge routing through the other side's gateways.
- Believing a non-overlapping secondary CIDR block lets two overlapping VPCs peer: peering is refused if any CIDR block of one VPC overlaps a block of the other.
- Believing an endpoint service can be created directly on an Application Load Balancer: the service front end is a Network Load Balancer, which can forward to one Application Load Balancer through an
albtarget group. - Believing separate transit gateway route tables isolate groups that share a static default route: traffic for the other group follows
0.0.0.0/0unless a blackhole route drops it. - Believing a transit gateway is the lowest-cost path for heavy traffic between two VPCs: it charges per gigabyte processed, and peering does not.