AWS Learning Journey

One VPC Is Never Enough: Peering, Transit Gateway, PrivateLink, and Hybrid Networks

How real AWS networks connect dozens of VPCs, reach AWS services privately, and link back to the office — without becoming spaghetti.

8 min read · 1518 words
AWSNetworkingCloud ArchitectureTransit GatewayDevOps
One VPC Is Never Enough: Peering, Transit Gateway, PrivateLink, and Hybrid Networks cover image

AWS from Zero to Production — Phase 3, Part 3 of 5 · See the full series roadmap


It starts with one VPC. Then there’s a second for staging. Then a shared-services VPC. Then the data team’s VPC. Then a VPC in another account that needs to call your API. Then the on-premises data center.

Six months later, someone draws the network on a whiteboard, and it looks like a plate of spaghetti.

Multi-VPC networking is where AWS architecture gets real. The good news: there’s a small set of tools, and each has a clear job. This article shows you which one to reach for, and why.

What you’ll walk away with


VPC peering: a private link between two VPCs

VPC peering connects two VPCs so resources can talk using private IP addresses.

The catch: peering isn’t transitive

If A peers with B, and B peers with C, A still can’t reach C through B. Every pair needs its own connection.

VPCs     Peering connections needed for a full mesh
3        3
5        10
10       45
20       190

Peering is perfect for a handful of VPCs. Past that, you need a hub.


AWS Transit Gateway: the network hub

AWS Transit Gateway is a regional router that connects many VPCs — and on-premises networks — through one central hub.

            +-----------+
 VPC A -----|           |----- VPC D
 VPC B -----|  Transit  |----- VPN to office
 VPC C -----|  Gateway  |----- Direct Connect
            +-----------+

Cost note: Transit Gateway charges per attachment per hour and per GB processed. For two or three VPCs, peering is usually cheaper. Check current pricing.


VPC endpoints: reach AWS services without the internet

By default, when an app in a private subnet calls Amazon S3, the traffic goes through a NAT gateway to the service’s public endpoint. That costs money and needs an internet path.

VPC endpoints give private, direct access to AWS services.

Gateway endpoints

aws ec2 create-vpc-endpoint \
  --vpc-id vpc-0abc123 \
  --service-name com.amazonaws.us-east-1.s3 \
  --route-table-ids rtb-0private1 rtb-0private2

Quick win: If your private workloads use S3 or DynamoDB, add gateway endpoints. They’re free and keep that traffic off your NAT gateway.

Interface endpoints (powered by AWS PrivateLink)

Engineer’s note: A fully private ECS service on Fargate typically needs interface endpoints for ECR (API and Docker), CloudWatch Logs, and Secrets Manager, plus an S3 gateway endpoint for image layers. You’ll see this in Phase 4.

VPC endpoint policies

An endpoint policy is a resource-based policy attached to the endpoint. It limits what can be accessed through it.

{
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": "*",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": "arn:aws:s3:::my-company-data/*"
    }
  ]
}

This endpoint only allows access to one company bucket — a strong control against data being copied to someone else’s bucket. IAM policies still apply too; both must allow the request.


AWS PrivateLink: expose your own service privately

PrivateLink isn’t only for AWS services. You can publish your own service to other VPCs and accounts:

  1. Put your service behind a Network Load Balancer.
  2. Create a VPC endpoint service that points to it.
  3. Consumers create interface endpoints to your endpoint service.

Why it’s powerful:

This is how many SaaS vendors offer “private connectivity” to their customers.


Connecting to on-premises networks

AWS Site-to-Site VPN

An encrypted IPsec tunnel over the internet between your data center’s router and AWS.

AWS Client VPN

A managed OpenVPN-based service that lets individual users connect their laptops to your VPCs. Think “remote access for engineers,” not “site to site.”

AWS Direct Connect

A dedicated private network connection from your data center or colocation facility to AWS.

Which one?


Hybrid DNS with Route 53 Resolver

Once networks are connected, names must resolve both ways:

Amazon Route 53 Resolver is the DNS server built into every VPC. For hybrid setups, add:

EC2 asks: db.corp.internal?
  -> Route 53 Resolver
  -> forwarding rule for corp.internal
  -> outbound endpoint
  -> on-premises DNS server

Share forwarding rules across accounts with AWS RAM, so every VPC resolves corporate names the same way.


AWS Network Firewall

Security groups and NACLs filter by IP, port, and protocol. Sometimes you need more:

AWS Network Firewall is a managed, stateful network firewall that does this. You place it in dedicated firewall subnets and route traffic through it. It supports domain filtering and Suricata-compatible rules.

Cost note: Network Firewall charges per endpoint hour and per GB processed. It’s a production control, not a lab default.


Multi-VPC architecture patterns

Hub and spoke

A Transit Gateway in a central network account connects workload VPCs (spokes) to a shared services VPC and to on-premises networks. Route tables keep environments apart.

Centralized egress

Instead of NAT gateways in every VPC, spokes route internet traffic through one egress VPC with NAT gateways and, optionally, Network Firewall. This cuts cost and centralizes inspection.

Shared VPCs

With VPC sharing, a central network account owns the VPC and shares subnets with other accounts through AWS RAM.


Common mistakes


Key takeaways


Quick self-check

Test yourself before moving on:

  1. VPC A peers with B, and B peers with C. Can A reach C?
  2. Which AWS services support gateway endpoints?
  3. Two companies’ VPCs both use 10.0.0.0/16. How can one consume the other’s API privately?
  4. Your on-premises servers can’t resolve names in a Route 53 private hosted zone. What do you need?

Answers

  1. No. Peering isn’t transitive.
  2. Amazon S3 and Amazon DynamoDB.
  3. AWS PrivateLink — an endpoint service behind a Network Load Balancer.
  4. A Route 53 Resolver inbound endpoint, with on-premises DNS forwarding to it.

What’s next

In Part 4, we move up to the edge: Route 53 hosted zones and routing policies, CloudFront caching, Origin Access Control, signed URLs, AWS WAF, and AWS Shield.

How many VPCs does your organization run? Peering, Transit Gateway, or shared VPCs? Tell me in the comments.


Share this article

LinkedIn post draft