Connecting VPCs and Reaching AWS Services Privately
This lesson explains how companies with many VPCs connect them to each other and to AWS services, ideally without sending traffic over the public internet.
Learning outcomes
After completing this lesson, you will be able to:
- Choose between VPC peering and AWS Transit Gateway from the number of VPCs.
- Distinguish gateway endpoints from interface endpoints.
- Identify the services that connect on-premises networks to AWS.
Connecting VPCs
The right way to connect VPCs depends on how many there are. VPC peering connects two VPCs directly, with traffic staying on the AWS network, which suits a few VPCs that need to talk to each other. AWS Transit Gateway is a central hub that many VPCs and on-premises networks attach to, so each network needs only one connection, which simplifies routing as the number grows. The following table summarises the options.
| Option | How it works | Best for |
|---|---|---|
| VPC peering | A direct connection between two VPCs; traffic stays on the AWS network | A few VPCs that need to talk to each other |
| AWS Transit Gateway | A central hub that VPCs and on-premises networks attach to | Many VPCs and networks; simplifies routing |
Peering is not transitive: if A peers with B and B with C, A cannot reach C through B. Transit Gateway solves this by acting as a hub.
VPC A cannot reach VPC C
Reaching AWS services privately
By default, an instance in a private subnet needs a NAT gateway to reach public AWS service endpoints such as S3. VPC endpoints let it reach them privately. There are two types, as follows.
- Gateway endpoints for Amazon S3 and DynamoDB, free of charge.
- Interface endpoints (powered by AWS PrivateLink) for most other services, and for services offered by other companies or your own teams.
Gateway or interface endpoint?
Reaching on-premises networks
AWS provides several services for connecting on-premises networks and users to AWS. The following list describes them.
- AWS Site-to-Site VPN: encrypted tunnels over the internet; quick to set up.
- AWS Direct Connect: a dedicated private connection with consistent performance; takes longer to set up.
- AWS Client VPN: lets individual users connect to a VPC from their devices.
A company has 40 VPCs across several accounts and an office network, all of which must be able to communicate. Managing dozens of peering connections has become difficult. Which service simplifies this?
AWS Transit Gateway: each VPC and the office VPN attach to one hub, instead of a mesh of peering connections.
Which service connects many VPCs and on-premises networks through one central hub?
Show answer
AWS Transit Gateway.
Exam Tips
Remember for the exam
- VPC peering connects two VPCs and is not transitive.
- Transit Gateway is a hub that connects many VPCs and on-premises networks.
- Gateway endpoints (S3, DynamoDB) are free; interface endpoints use PrivateLink.
- PrivateLink keeps traffic to services off the public internet.
- Site-to-Site VPN goes over the internet; Direct Connect is a private dedicated link.