VPC Peering and Transit Gateway
VPC Peering connects two VPCs so that their instances can communicate using private IP addresses, as if they are on the same network. Peering works within a region or across regions (inter-region peering). The critical constraint: VPC peering is non-transitive. If VPC A is peered with VPC B, and VPC B is peered with VPC C, VPC A cannot reach VPC C through VPC B. Each pair of VPCs that needs to communicate requires its own peering connection. With many VPCs, the number of peering connections grows quadratically and becomes unmanageable.
Transit Gateway solves the scaling problem. It acts as a central hub that multiple VPCs, VPN connections, and Direct Connect connections attach to. Traffic between any two attached networks routes through the Transit Gateway, which supports transitive routing. Ten VPCs need ten attachments to Transit Gateway rather than 45 individual VPC peering connections. Transit Gateway also enables shared services VPCs, centralized egress, and centralized network inspection through integration with Gateway Load Balancer.
Transit Gateway Connect extends Transit Gateway to support SD-WAN appliances using GRE tunnels, and Transit Gateway Network Manager provides a global view of the network across multiple regions and on-premises locations.
Direct Connect, VPN, and VPC Endpoints
AWS Direct Connect is a dedicated physical network connection from an on-premises data center to an AWS Direct Connect location. Unlike a VPN that tunnels traffic over the public internet, Direct Connect provides a private, dedicated line with consistent bandwidth and latency. Direct Connect is available in 1 Gbps, 10 Gbps, and 100 Gbps speeds. For organizations that cannot achieve Direct Connect, a Site-to-Site VPN creates an encrypted IPsec tunnel over the public internet. VPN is faster to provision (minutes versus weeks for Direct Connect) and cheaper, but bandwidth and latency are variable because it shares the public internet.
VPC Endpoints allow resources inside a VPC to access AWS services privately without routing traffic through the public internet. Gateway Endpoints work for S3 and DynamoDB only. They are free and add a route to the VPC route table pointing to the endpoint. Interface Endpoints (powered by AWS PrivateLink) create an Elastic Network Interface in your subnet with a private IP address. Services accessed through Interface Endpoints include Secrets Manager, Systems Manager, Kinesis, SQS, and hundreds of other AWS and third-party services. Interface Endpoints incur an hourly charge per AZ.
PrivateLink is the underlying technology for Interface Endpoints and also lets you expose your own services to other VPCs without peering. You deploy your service behind an NLB, create a VPC Endpoint Service, and grant consumers permission to create Interface Endpoints into your service. Traffic stays on the AWS network and never crosses the public internet.
How to choose the correct answer
VPC Peering: two VPCs, direct connection, non-transitive. Simple, free data transfer within same region.
Transit Gateway: many VPCs, hub-and-spoke, transitive routing, centralized connectivity. Use when managing multiple VPCs.
Direct Connect: dedicated physical line, consistent bandwidth and latency, private network. Use for high-bandwidth or latency-sensitive hybrid workloads.
Site-to-Site VPN: encrypted tunnel over public internet, fast to set up, variable performance. Use when Direct Connect is not available or needed.
Gateway Endpoint: free, S3 and DynamoDB only, route table entry. Use to keep S3 traffic off the internet.
Interface Endpoint (PrivateLink): private IP in subnet, supports most AWS services, per-AZ cost. Use for private access to services beyond S3 and DynamoDB.
VPN CloudHub: connect multiple on-premises sites to each other through a single Virtual Private Gateway.