AWS Transit Gateway and PrivateLink: Connect VPCs and Services Explained
Two VPCs peer easily; twenty VPCs become a mesh nightmare. Partners want private access to your service without the public internet. AWS Transit Gateway (TGW) is the hub for many VPCs; PrivateLink (interface endpoints / endpoint services) keeps traffic on the AWS network privately.
In this chapter
- Why hub-and-spoke beats full mesh peering
- What Transit Gateway and PrivateLink are
- How to connect VPCs and expose services privately
- Hybrid and industry patterns
- Lab, errors, FAQ, interview
1. Everyday example first
A Bengaluru bank has VPC-app, VPC-data, VPC-shared. Instead of peering every pair, each attaches to a Transit Gateway. A fintech partner reaches the bank’s payments API through a PrivateLink endpoint service — no public ALB required for that partner path.
2. Why TGW and PrivateLink?
VPC peering does not transit; meshes do not scale. TGW routes between attachments. PrivateLink exposes a Network Load Balancer-powered service to consumers via interface endpoints — private IPs in their VPC.
- Scale many VPC connections centrally
- Shared services VPC without spaghetti peering
- Private partner connectivity
- Hybrid via VPN/DX attachments to TGW
3. What are they?
Imagine two office systems in separate VPCs, each with its own range of addresses. Transit Gateway is a routing hub that can connect network attachments. It needs routes that tell traffic where to travel and return. PrivateLink can give a client a private endpoint for one supported service without sharing routes to all other systems in the provider VPC. Draw one request from a client to a service endpoint and one request that needs a route to a whole network. Those are different requirements, even when both requests are private.
Transit Gateway: a regional hub. Attach VPCs, VPNs, Direct Connect gateways; use route tables to isolate or share. PrivateLink: create a VPC endpoint service (NLB) or consume AWS/partner services via interface VPC endpoints (ENIs in your subnets).
| Piece | Plain job |
|---|---|
| TGW | Hub router for many attachments |
| VPC attachment | Connect a VPC to TGW |
| TGW route table | Control which attachments talk |
| Interface endpoint | ENIs to reach a PrivateLink service |
| Endpoint service | Your NLB-backed private service |
| Gateway endpoint | S3/DynamoDB prefix-list style (not PrivateLink ENI) |
4. How to design without spaghetti
A route table answers where matching destination packets go next. For a Transit Gateway path, follow the sender’s subnet route to its attachment, then check the transit route table for the receiver’s attachment. Trace the reply back too. An overlapping CIDR makes destination choice ambiguous in this design. For a service-only path, trace the private DNS name or endpoint address to the interface endpoint and check the service permission and security group separately.
- Draw hub-and-spoke: shared, prod, nonprod spokes.
- Create TGW; attach VPCs; update subnet route tables to TGW.
- Use separate TGW route tables to isolate prod/nonprod if needed.
- For AWS APIs privately, prefer interface endpoints (or gateway for S3/DDB).
- To expose your SaaS privately, put NLB + endpoint service; accept consumer principals.
- Approve endpoint connections; least-privilege security groups on ENIs.
- For hybrid, attach VPN/DX to TGW; watch ASN/routes.
- Monitor TGW bytes and endpoint ENI costs.
- Document CIDR plan — overlapping CIDRs break designs.
- Avoid peering + TGW loops; pick a clear primary path.
# Mental model
# Consumer creates interface endpoint to vpce-svc-xxxxx
# ENIs get private IPs; SG allows app→ENI
# Provider NLB targets private IP tasks/instances
5. TGW vs peering vs PrivateLink
| Option | When |
|---|---|
| VPC peering | Few VPCs, simple, no transit |
| Transit Gateway | Many VPCs / hybrid hub |
| PrivateLink | Expose/consume service privately across accounts |
| Public API + WAF | Internet clients; different threat model |
6. Multi-industry notes
ISVs sell PrivateLink-connected APIs to banks who forbid public egress. Manufacturers attach plant VPCs to a TGW shared-services hub for Active Directory. Unis use TGW to connect campus firewalls via DX.
7. Industries and roles
- Banks: private fintech connectivity
- ISVs: PrivateLink product SKU
- Enterprises: shared services hub
- Hybrid IT: DX + TGW
- Security: reduce public exposure
8. Lab: two VPCs + TGW path (account permitting)
On paper choose two separate address ranges and follow one permitted connection forward and backward. Mark the attachment and route-table entry at each hop. In an allowed sandbox lab, expect only the intended connection to work and check the denied case separately. For the PrivateLink sketch, the consumer should reach the offered service without a general route to the provider’s network.
Do this in ap-south-1 (Mumbai) unless your org forbids it. Set a budget alert first.
- Create two small VPCs with non-overlapping CIDRs.
- Create TGW; attach both; fix routes for a ping path.
- Launch tiny instances; security groups allow ICMP/SSH via SSM preferably.
- Ping across VPCs via TGW; capture a traceroute mindset.
- Optional: create an interface endpoint to a public AWS service (e.g., SSM) in one VPC.
Cleanup (stop billing)
- Delete instances, attachments, TGW, VPCs.
- Watch for leftover ENIs/endpoints.
9. Common errors and fixes
Each row is a real mistake students and juniors hit. Read the fix before you panic.
| Error / symptom | Fix |
|---|---|
| Overlapping CIDRs across spokes | Re-IP or use careful NAT patterns; prefer unique CIDRs. |
| Peering mesh “temporary” forever | Migrate to TGW when > few VPCs. |
| TGW route table shares prod↔dev | Isolate route tables. |
| Open SG on endpoint ENIs | Least ports from app SG only. |
| Forgot consumer approval on endpoint service | Automate accept for trusted principals. |
| Used gateway endpoint expecting PrivateLink ENI | Know gateway vs interface. |
| No DX/VPN redundancy | Two tunnels/connections. |
| Cost surprise on many AZs endpoints | Endpoints are per-AZ ENIs. |
| Hairpin traffic inefficiently | Place endpoints near consumers. |
| DNS not enabling private DNS on endpoint | Turn on private DNS names when appropriate. |
10. Troubleshooting checklist
- No route: subnet RT missing TGW target.
- Blackhole: wrong TGW association/propagation.
- Endpoint pending: provider must accept.
- Timeouts: NLB targets unhealthy.
- DNS resolves public still: private DNS flag / hosted zone.
- Hybrid asymmetric routing: check return paths.
11. FAQ
Q. TGW free?
Hourly + data processing charges — check pricing.
Q. PrivateLink vs peering?
Service exposure vs network join.
Q. Cross-region TGW?
Peering TGWs across regions is a pattern.
Q. Replace Direct Connect?
No — DX is physical; TGW can attach it.
Q. Security?
SG/NACL + route isolation + endpoint policies.
Q. S3 via PrivateLink?
Gateway endpoint common; interface options exist for some.
12. Interview Q&A
Q. What is Transit Gateway?
Regional hub to connect VPCs/VPN/DX with route tables.
Q. Why not only peering?
No transit; mesh does not scale.
Q. PrivateLink?
Private connectivity to services via ENIs / endpoint services.
Q. Endpoint service needs?
NLB + allowed principals + connection acceptance.
Q. Hub-and-spoke benefit?
Central control, fewer connections.
Q. Overlapping CIDR problem?
Routing ambiguity; redesign CIDRs.
13. Tips in English, Marathi and Hindi
Ravindra Bagale's Tip (EN)
Draw CIDRs and trust boundaries before you click Create Transit Gateway. Networks are harder to renumber than IAM roles.
Ravindra Bagale's Tip (MR)
TGW create आधी CIDR व trust boundaries काढा. Renumber कठीण.
Tip (HI)
TGW बनाने से पहले CIDR और trust boundary बनाओ — IP बदलना IAM से कठिन है।
Try at home
- Sketch 3 spokes + shared hub with TGW route tables.
- List steps to expose an NLB service via PrivateLink.
- Write one overlapping CIDR failure story in two lines.
In short
- TGW hubs many VPCs/hybrid links.
- PrivateLink privately exposes/consumes services.
- Unique CIDRs and route isolation matter.
- Watch endpoint and TGW data costs.
Revision, interview and comparison cards
Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.








More cards: Ravi Sir's Cards.
Practise this chapter
Interview questions and answers
A partner needs one application but uses the same VPC CIDR as you. How would you compare Transit Gateway and PrivateLink?
General routing across overlapping ranges needs a deliberate address and route design. If the partner only needs one supported service, consider a PrivateLink endpoint with a local address and agreed endpoint-service access. Verify both the service request and the absence of broad network routing.
Check your understanding
Choose an answer, then compare your reasoning with the explanation.
Practice Tasks
Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.
About this scenarioMilan Furniture is a furniture business in Milan. Giulia Rossi looks after its IT and cloud work. They count money in EUR and run their AWS resources in the eu-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 16
Easy Describe transit gateways
Hub inventory.
Describe transit gateways.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Describe VPC endpoints
PrivateLink list.
Describe vpc endpoints.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Easy Apply the lesson: scenario 3
Many VPCs need a central routing hub instead of a large peering mesh. Which AWS service fits that topology?
- Read the situation and identify what you need to decide.
- Work through the relevant concept or calculation.
- Enter only the requested term or number.
- Check your answer, then read the explanation.
Easy Apply the lesson: scenario 4
A supported service is accessed using a private network interface endpoint in your VPC. Which AWS technology provides that service connection?
- Read the situation and identify what you need to decide.
- Work through the relevant concept or calculation.
- Enter only the requested term or number.
- Check your answer, then read the explanation.
Medium Describe TGW attachments
VPC links.
Describe transit gateway attachments.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Describe TGW route tables
Segregation.
Describe transit gateway route tables.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Describe VPC endpoint services
Provider side.
Describe vpc endpoint services.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Describe TGW peering attachments
Inter-region.
Describe transit gateway peering attachments.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium Allow CreateVpcEndpoint
Consumer LP.
Allow ec2:CreateVpcEndpoint on *.
- Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
- In each statement write Effect, Action and Resource.
- Give only what the task needs (least privilege).
- Use double quotes and commas correctly. Click Check answer.
Medium Hub spoke JSON
Prefer TGW hub.
JSON prefer_transit_gateway true.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.
Medium Apply the lesson: scenario 11
Two business units share a Transit Gateway but must use different route domains. Which TGW component do you separate?
- Read the situation and identify what you need to decide.
- Work through the relevant concept or calculation.
- Enter only the requested term or number.
- Check your answer, then read the explanation.
Medium Sample AZ count for HA endpoints
HA.
Sample AZ count for HA interface endpoints (enter 2)?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Describe TGW VPC attachments
Per-VPC.
Describe transit gateway vpc attachments.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Describe VPC endpoint connections
Accept/reject.
Describe vpc endpoint connections.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Hard Allow DescribeTransitGateways
Viewer LP.
Allow ec2:DescribeTransitGateways on *.
- Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
- In each statement write Effect, Action and Resource.
- Give only what the task needs (least privilege).
- Use double quotes and commas correctly. Click Check answer.
Hard Private DNS JSON
Keep private.
JSON PrivateDnsEnabled true.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.