Certopolis

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 alb target 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/0 unless 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.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A media company runs 35 VPCs across several AWS accounts in the eu-west-1 Region, and its head office connects to AWS through one AWS Site-to-Site VPN connection. Every VPC must reach the head office and a shared tooling VPC. The network team wants a single central routing point in the Region, where route tables decide which networks can reach which others. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Architecture Design and Implementation Built for the Cloud building.

    Not that one: B is right. In the game your Architecture Design and Implementation Built for the Cloud building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Sharing it through AWS RAM lets VPCs in the other accounts attach to the one gateway.

    Written from docs.aws.amazon.com/vpc/latest/tgw/how-transit-gateways-work.html

  2. A retailer has acquired a payments company. The retailer's checkout VPC and the payments company's VPC are in different AWS accounts in us-east-1, and both use 10.20.0.0/16. Neither VPC can be renumbered before next year. Only two services need to be reachable between the companies: • Checkout applications call a card-tokenization API that runs on Amazon EC2 instances behind an internal Application Load Balancer in the payments VPC. • Payments applications call a fraud-scoring service that runs on EC2 instances behind an internal Network Load Balancer in the checkout VPC. All of this traffic must stay on the AWS network. Which combination of steps should a solutions architect take to meet these requirements? (Select TWO.)

    Right. In the game that’s Renown for your Architecture Design and Implementation Built for the Cloud building.

    Not that one: C,E is right. In the game your Architecture Design and Implementation Built for the Cloud building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Fraud scoring already sits behind a Network Load Balancer in the checkout VPC, which is what a PrivateLink endpoint service is built on: publish it there and create the interface endpoint in the payments VPC, whose network interfaces take addresses from payments subnets, so the clash never matters. Tokenization sits behind an Application Load Balancer, which is not what an endpoint service selects. The fix is a new Network Load Balancer in the same VPC and account with a target group of type alb holding the existing Application Load Balancer; the layer 7 routing stays, and the Network Load Balancer brings PrivateLink with it. Peering fails in both of its forms, because AWS refuses a peering connection while any CIDR block of one VPC overlaps a block of the other, whichever block the traffic would use.

    Written from docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html

  3. A company runs a producer fleet in VPC P and a consumer fleet in VPC C. Both VPCs are in the same AWS account and Region, have non-overlapping CIDR blocks, and are attached to a transit gateway that also connects 30 other VPCs and an on-premises network. Each fleet runs in the same three Availability Zones, and the consumers pull about 2 PB each month from the producers. Any consumer can read from any producer. All other traffic must keep using the transit gateway. Which solution will meet these requirements with the LOWEST data transfer and processing charges?

    Right. In the game that’s Renown for your Cost-Optimized Architecture Design building.

    Not that one: B is right. In the game your Cost-Optimized Architecture Design building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    VPC peering has no processing charge, and data over a peering connection that stays within one Availability Zone is free, while cross-zone peering data is charged. Moving the pair onto peering removes processing; having each consumer read only from producers in its own zone removes the inter-zone transfer. Only the option that does both brings the 2 PB close to zero cost, and the other traffic stays on the transit gateway.

    Written from docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html

Ask for something