VPC endpoints and PrivateLink
Reach AWS services and other teams' services privately: gateway endpoints for S3 and DynamoDB, interface endpoints, private DNS and endpoint policies.
Route tables, internet gateways and NATSecurity groups and network ACLsPolicy documents and evaluation logic
VPC endpoints and PrivateLink
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- AWS service APIs have public addresses. Without an endpoint, reaching them from a private subnet means going through NAT.
- Gateway endpoints exist for S3 and DynamoDB only, work by adding a route, and have no extra charge. Create them by default.
- Interface endpoints put network interfaces with private addresses in your subnets, use security groups and private DNS, and are billed per hour per zone and per gigabyte.
- An endpoint policy limits what can be done through that endpoint. It grants nothing by itself.
- PrivateLink exposes one service across VPCs or accounts, one way, without joining networks, even with overlapping addresses.
The long way round
Your application sits in a private subnet and reads from S3. S3 is a regional service with public endpoints, outside your VPC. So the request goes out through the NAT gateway, to S3’s public address, paying per gigabyte. If you have no NAT gateway, it simply times out.
That is like posting a letter to the office next door through the city’s mail system. A VPC endpoint is an internal door: a private path from your VPC to a service.
Gateway endpoints: a route
For S3 and DynamoDB only. You pick route tables, and AWS adds a route whose destination is the service’s prefix list, a managed list of its address ranges:
aws ec2 create-vpc-endpoint --vpc-id vpc-... \
--service-name com.amazonaws.eu-west-1.s3 --route-table-ids rtb-...
10.20.0.0/16 local
0.0.0.0/0 nat-...
pl-... vpce-...
The prefix route is more specific than 0.0.0.0/0, so S3 traffic takes it. Nothing in your code changes and there is no additional charge. To give a sense of why it is a list: AWS’s public ip-ranges.json dated 28 November 2026 showed 13 IPv4 blocks for S3 in eu-west-1.
Limits: same Region, and only from inside the VPC. Peered networks in other Regions and on-premises connections cannot use it.
Interface endpoints: a network interface
Most other services (Secrets Manager, ECR, CloudWatch Logs, STS, SQS and so on) use AWS PrivateLink. An interface endpoint creates a network interface with a private IP in each subnet you choose.
- Turn on private DNS and the usual name, such as
secretsmanager.eu-west-1.amazonaws.com, resolves to those private addresses. The VPC needs DNS support and DNS hostnames enabled. - Give it a security group allowing 443 from your clients. Forgetting this is the most common failure.
- Choose subnets in at least two zones.
It costs money. In eu-west-1, November 2026, each interface endpoint is 0.011 USD per hour per zone plus 0.01 USD per GB at the first tier. Ten services across three zones is roughly 240 USD a month idle. Compare that with your NAT bill and your security needs, not with zero. Some workloads need several at once: pulling images privately takes ECR’s endpoints plus the S3 gateway endpoint.
S3 and DynamoDB also offer interface endpoints, for callers outside the VPC such as on-premises.
Endpoint policies
An endpoint can carry a policy limiting what passes through it:
{"Version":"2012-10-17","Statement":[{
"Effect":"Allow","Principal":"*",
"Action":["s3:GetObject","s3:PutObject"],
"Resource":"arn:aws:s3:::acme-app-data/*"}]}
The default allows everything. A tight one stops a compromised server from copying data to somebody else’s bucket through your private path. It filters; callers still need their own IAM permission. The reverse condition, in a bucket policy, is aws:SourceVpce: accept requests only through this endpoint. Take care, since that also locks out your console session.
Be aware that a narrow S3 policy can break things that read AWS-owned buckets, such as package repositories or image layers. Test it.
PrivateLink for your own services
The same mechanism lets you publish a service. Put it behind a Network Load Balancer, create an endpoint service, and allow specific accounts. Each consumer creates an interface endpoint in their VPC and sees private addresses of their own.
Only that service is exposed. Consumers can start connections to you, never the reverse, and the two VPCs can use identical address ranges. Compare this with peering, which joins whole networks.
Related endpoint types extend the idea. A resource endpoint reaches a specific resource such as a database in another VPC without a load balancer (TCP only), and VPC Lattice service networks connect many services. Use them when the simple forms don’t fit.
About the video
The embed is Be A Better Dev’s “Keep Your Network Traffic in AWS with VPC Endpoints”, June 2023, 17 minutes. Its chapters set out the problem and the endpoint solution, then build it in the console: security groups, the endpoint, a Lambda function, testing and fixing connectivity. It predates resource endpoints. I judged it from chapters and description, since transcripts couldn’t be fetched. The re:Invent session in deeper looks at cost, security and operations.
What was run: the gateway endpoint and route ran on moto, a local emulator, and the prefix count came from AWS’s public address file. No traffic flowed and private DNS was not tested. Prices are AWS list prices from its public price data; behaviour is from the documentation, checked in November 2026.
Where this fits
Endpoints connect to services. Next, connecting whole networks: peering, Transit Gateway and VPN.
Check yourself
You add an S3 gateway endpoint but one private subnet still sends S3 traffic through NAT. Why?
A gateway endpoint works through a route added to the route tables you select. That subnet's table was not associated with the endpoint.
After creating an interface endpoint for Secrets Manager, calls from your application time out. What is the first suspect?
The endpoint's security group. It must allow inbound 443 from the application. With private DNS on, the normal service name now resolves to the endpoint's private addresses.
Can servers in your office use the VPC's S3 gateway endpoint over a VPN?
No. Gateway endpoints are reachable only from within the VPC. On-premises clients need an interface endpoint for S3, or the public endpoint.
A partner needs to call one API in your VPC, and your address ranges overlap. What do you use?
PrivateLink: put the service behind a Network Load Balancer, publish an endpoint service and let the partner create an interface endpoint. Their traffic reaches that service only.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.