Transit Gateway, VPN, Direct Connect and PrivateLink
Overview
Most organisations connect many VPCs and on-premises networks. AWS offers several building blocks: VPC peering for simple one-to-one links, Transit Gateway (TGW) as a regional hub-and-spoke router, Site-to-Site VPN and Direct Connect (DX) for hybrid links, and PrivateLink for exposing individual services privately.
Consider an airline network. Peering is a direct flight between two cities; Transit Gateway is a hub airport where every route connects through one place; VPN is a flight over the public sky with encryption; Direct Connect is your own private runway; PrivateLink is a courier that delivers to one specific office without exposing the building.
The operational skill is choosing the right option and troubleshooting: route propagation, BGP status, overlapping CIDRs, asymmetric routing and bandwidth.
Key Concepts
- VPC peering: one-to-one, non-transitive, no overlapping CIDRs, cross-Region/account supported; both route tables must be updated.
- Transit Gateway connects thousands of VPCs and VPN/DX attachments with route tables, association and propagation, supports multicast and inter-Region peering.
- Site-to-Site VPN: two IPsec tunnels per connection (up to 1.25 Gbps each); static or BGP routing; terminates on a VGW or TGW (TGW supports ECMP across tunnels for more bandwidth).
- Direct Connect: dedicated 1/10/100 Gbps (or hosted 50 Mbps-25 Gbps) private connection; not encrypted by default (use VPN over DX or MACsec); lead time of weeks.
- Resilience: DX with two connections at separate locations (or DX + VPN backup); BGP prefers DX over VPN via local preference, and longest prefix.
- Direct Connect Gateway connects DX to VPCs in multiple Regions via private VIF (VGW) or transit VIF (TGW).
- PrivateLink (interface endpoints / endpoint services) exposes a service via NLB privately; no peering or route changes, overlapping CIDRs allowed.
- Route 53 Resolver endpoints provide hybrid DNS resolution; Client VPN gives remote users access.
Detailed Notes
Choosing connectivity
| Requirement | Choice |
|---|---|
| Two VPCs, lowest cost/latency | VPC peering |
| Many VPCs + on-premises hub | Transit Gateway |
| Quick encrypted hybrid link | Site-to-Site VPN |
| Consistent latency, high throughput | Direct Connect |
| Expose one service to many consumers | PrivateLink |
| Remote workers | Client VPN / Identity Center |
| Hybrid DNS | Route 53 Resolver endpoints |
Transit Gateway routing
| Concept | Meaning |
|---|---|
| Attachment | VPC, VPN, DX gateway, peering, Connect |
| Association | Attachment uses one TGW route table to forward traffic |
| Propagation | Attachment advertises its routes into one or more TGW route tables |
| Static route | Manually defined; supports blackhole routes |
aws ec2 create-transit-gateway --description hub --options AmazonSideAsn=64512,DefaultRouteTableAssociation=disable,DefaultRouteTablePropagation=disable
aws ec2 create-transit-gateway-vpc-attachment --transit-gateway-id tgw-0abc --vpc-id vpc-0111 --subnet-ids subnet-a subnet-b
aws ec2 associate-transit-gateway-route-table --transit-gateway-route-table-id tgw-rtb-0prod --transit-gateway-attachment-id tgw-attach-0111
aws ec2 enable-transit-gateway-route-table-propagation --transit-gateway-route-table-id tgw-rtb-0shared --transit-gateway-attachment-id tgw-attach-0111
aws ec2 create-route --route-table-id rtb-0aaa --destination-cidr-block 10.0.0.0/8 --transit-gateway-id tgw-0abc
Remember to add routes in each VPC route table pointing to the TGW. Use separate TGW route tables for segmentation (e.g. prod vs dev isolation, shared services). Use one subnet per AZ for attachments.
VPN troubleshooting
| Symptom | Check |
|---|---|
| Both tunnels down | Customer gateway device config, IKE/IPsec parameters, pre-shared key, public IP / NAT-T, firewall UDP 500/4500 |
| Tunnel up but no traffic | Routes (propagation enabled on VPC route table), BGP advertised prefixes, SG/NACL, overlapping CIDR |
| One tunnel only | Both tunnels should be configured for redundancy; AWS maintenance can bring one down |
| Low throughput | 1.25 Gbps limit per tunnel; use TGW + ECMP or Direct Connect |
CloudWatch metrics: TunnelState (0/1), TunnelDataIn, TunnelDataOut. Enable VPN tunnel logging to CloudWatch Logs.
Direct Connect
| Item | Detail |
|---|---|
| Virtual interfaces | Private VIF (VPC via VGW/DX gateway), Public VIF (AWS public services), Transit VIF (TGW) |
| Redundancy | Two DX locations/devices + VPN backup; test failover with BFD |
| Encryption | Not default; use IPsec VPN over a public/transit VIF or MACsec on dedicated 10/100 Gbps |
| Monitoring | ConnectionState, ConnectionBpsEgress, light levels; BGP status in console |
| BGP troubleshooting | ASN mismatch, MD5 key, VLAN ID, prefix limits (100 routes on private VIF) |
PrivateLink service example
aws ec2 create-vpc-endpoint-service-configuration --network-load-balancer-arns arn:aws:elasticloadbalancing:us-east-1:111122223333:loadbalancer/net/svc/abc --acceptance-required
aws ec2 create-vpc-endpoint --vpc-id vpc-0consumer --service-name com.amazonaws.vpce.us-east-1.vpce-svc-0123 \
--vpc-endpoint-type Interface --subnet-ids subnet-a subnet-b --security-group-ids sg-0ep
Hybrid DNS
aws route53resolver create-resolver-endpoint --name inbound --direction INBOUND \
--creator-request-id r1 --security-group-ids sg-0dns \
--ip-addresses SubnetId=subnet-a SubnetId=subnet-b
Outbound endpoints + forwarding rules send corporate domains to on-premises DNS servers; share rules via RAM across accounts.### Hybrid connectivity options and failure modes
| Option | Characteristics | Typical problem |
|---|---|---|
| Site-to-Site VPN | IPsec over internet, 2 tunnels per connection, about 1.25 Gbps per tunnel | One tunnel down, mismatched routing (static vs BGP) |
| Direct Connect | Dedicated private link, 1/10/100 Gbps, not encrypted by default | Long provisioning; needs a backup path |
| DX + VPN | Encrypted over DX or VPN as backup | Route preference confusion |
| Direct Connect gateway | Connect one DX to VPCs in many Regions | Association limits |
| Transit Gateway | Regional hub, route tables, attachments, peering between TGWs | Missing route propagation or association |
| Client VPN / SSM | Remote user access | Authorization rules and routes |
Route preference when the same prefix is learned from several sources: longest prefix first, then static, then Direct Connect BGP, then VPN. Use VPN CloudWatch metric TunnelState with alarms, and enable BGP with BFD or multiple DX connections for resiliency. Use Accelerated Site-to-Site VPN for better internet performance.
aws ec2 describe-vpn-connections --query "VpnConnections[].VgwTelemetry[].[OutsideIpAddress,Status,StatusMessage]"
aws ec2 search-transit-gateway-routes --transit-gateway-route-table-id tgw-rtb-0abc --filters Name=state,Values=active
aws ec2 get-transit-gateway-route-table-propagations --transit-gateway-route-table-id tgw-rtb-0abc
Remember that TGW attachments need both a route in the VPC route table pointing to the TGW and a TGW route table entry, and security groups still apply.
Real World Example
Scenario – consolidating 30 VPCs and a data centre. A retailer replaces a mesh of 200 peering connections with a Transit Gateway. Production, development and shared-services VPCs attach with separate TGW route tables so dev cannot reach prod but both reach shared DNS and logging.
The data centre connects with two Direct Connect links in different locations terminating on a transit VIF, with a Site-to-Site VPN to the same TGW as backup. A CloudWatch alarm on ConnectionState pages the network team, and quarterly failover drills pull one link down to prove BGP converges.
Architecture Diagram
- 1The on-premises router advertises its prefixes over BGP on Direct Connect and VPN.
- 2The Transit Gateway learns routes through propagation into its route tables.
- 3VPC attachments are associated with route tables that decide which networks they can reach.
- 4VPC route tables send remote CIDRs to the TGW; if DX fails, traffic shifts to the VPN.
Best Practices
- ✓Use Transit Gateway beyond a handful of VPCs and segment with multiple route tables.
- ✓Design redundant hybrid links: dual DX locations plus VPN backup, with BGP monitoring.
- ✓Plan non-overlapping CIDRs across VPCs and on-premises from day one.
- ✓Encrypt where required: IPsec VPN over DX or MACsec.
- ✓Use PrivateLink to share services without exposing whole networks.
Common Interview Questions
Exam Tips
SOA-C03 focus
- Many VPCs plus on-premises -> Transit Gateway; two VPCs -> peering.
- Direct Connect is not encrypted by default; fast to deploy backup -> Site-to-Site VPN.
- Overlapping CIDRs but service access needed -> PrivateLink.
- Static public IP and TLS passthrough for a service endpoint -> NLB; TGW attachments need routes in VPC tables.
Finished this lesson?
0 of 46 lessons done · 0% of the course

