VPC endpoints and PrivateLink
VPC endpoints for private access to AWS services, interface endpoints (PrivateLink) vs gateway endpoints, choosing for S3, Lambda in a VPC reaching DynamoDB, and PrivateLink endpoint services.
What they are
- Every AWS service is publicly exposed (public URL).
- VPC endpoints (powered by AWS PrivateLink) let resources connect to AWS services using a private network instead of the public internet.
- They're redundant and scale horizontally.
- They remove the need for an IGW, NAT gateway… to access AWS services.
- In case of issues:
- check the DNS resolution settings in the VPC;
- check the route tables.
Types of endpoints
- Interface endpoints (powered by PrivateLink):
- provision an ENI (private IP address) as an entry point (a security group must be attached);
- support most AWS services;
- $ per hour (per AZ) + $ per GB of data processed.
- Gateway endpoints:
- provision a gateway that must be used as a target in a route table (doesn't use security groups);
- support both S3 and DynamoDB (only those two);
- free.
Gateway or interface endpoint for S3?
- Gateway is most likely going to be preferred all the time at the exam.
- Cost: free for gateway, $ for interface endpoint.
- Interface endpoint is preferred if access is required from on premises (Site-to-Site VPN or Direct Connect), a different VPC or a different Region: a gateway endpoint can only be used from inside its own VPC.
Lambda in a VPC accessing DynamoDB
DynamoDB is a public service from AWS.
- Option 1: access from the public internet. Because Lambda is in a VPC, it needs a NAT gateway in a public subnet and an internet gateway.
- Option 2 (better and free): access from the private VPC network. Deploy a VPC gateway endpoint for DynamoDB and change the route tables.
PrivateLink endpoint services
AWS PrivateLink can also expose a custom service to other VPCs (other accounts, customers):
- the service provider puts the service behind a Network Load Balancer (or Gateway Load Balancer) and creates an endpoint service;
- each consumer creates an interface endpoint (ENI) in its own VPC.
- No VPC peering, public internet, NAT gateway or route table changes are needed, and CIDRs can overlap. It's one-way and scales to thousands of consumer VPCs.
Real-world examples
- A data pipeline on EC2 in private subnets writes terabytes to S3 every day. Replacing the NAT gateway path with an S3 gateway endpoint removes about $45 of NAT processing per TB.
- A SaaS provider offers its API to customers' VPCs through a PrivateLink endpoint service behind an NLB.
Exam tips
- "Private access to S3 or DynamoDB from a VPC, cheapest" → gateway endpoint.
- "Private access to SQS, SNS, KMS, Secrets Manager… from a private subnet" → interface endpoint.
- "Access S3 privately from on premises over Direct Connect or VPN" → S3 interface endpoint.
- "Expose a service to many VPCs, overlapping CIDRs, no peering" → PrivateLink endpoint service with an NLB.
- "Endpoint created but traffic still fails" → check DNS settings (private DNS) and route tables.
Common traps
- "Gateway endpoints for SQS." Gateway endpoints exist only for S3 and DynamoDB.
- "Use a gateway endpoint from on premises." It works only from inside its VPC.
Hands-on lab: an S3 gateway endpoint
Goal: add a free S3 gateway endpoint to a VPC and see the route it creates.
Costs money
Gateway endpoints are free. Use the default VPC or the lab VPC from VPC and subnets. Any Region works.
Create the endpoint
VPC → Endpoints → Create endpoint: type AWS services, service com.amazonaws.<region>.s3 of type Gateway, your VPC, and tick its route tables.
Look at the route table
Open one of the route tables you ticked.
Expected result: a new route whose destination is a prefix list (pl-…, the S3 IP ranges) and whose target is the endpoint (vpce-…).
Clean up: delete the endpoint; its routes are removed.
AWS documentation
VPC peering
VPC peering for private connections between two VPCs, the no-overlap and no-transitivity rules, route tables, cross-account and cross-Region peering, and referencing security groups.
AWS Transit Gateway
AWS Transit Gateway for hub-and-spoke, transitive connections between thousands of VPCs and on premises, route tables, sharing with RAM, inter-Region peering, multicast, ECMP for VPN bandwidth, and sharing Direct Connect.