Reaching Services Privately with VPC Endpoints and AWS PrivateLink
This lesson explains how VPC endpoints let resources in a VPC reach AWS services and partner services privately, without an internet gateway, NAT gateway or public IP addresses.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish gateway and interface endpoints.
- Restrict use with endpoint policies.
- Expose services with endpoint services.
Gateway endpoints
Gateway endpoints are available for Amazon S3 and DynamoDB. Creating one adds a route to the service's prefix list in the route tables you choose, so traffic from those subnets to the service goes through the endpoint. They are free, do not use IP addresses, and work only for traffic from the same Region's VPC; they cannot be reached from on premises or from peered VPCs. Security groups must allow outbound traffic to the prefix list if outbound rules are restricted.
Interface endpoints
Interface endpoints, powered by AWS PrivateLink, create elastic network interfaces with private IPs in your subnets for most AWS services (such as Systems Manager, CloudWatch, KMS, Secrets Manager, ECR, STS, SQS and SNS) and for S3. With private DNS enabled, the service's standard hostname (for example ssm.eu-west-1.amazonaws.com) resolves to the endpoint's private IPs inside the VPC, so applications need no changes; this requires the VPC's DNS hostnames and DNS support attributes. Interface endpoints have a security group that must allow HTTPS (443) from clients, are charged per hour per AZ and per GB processed, and can be reached from peered VPCs, Transit Gateway and on premises (with Route 53 Resolver inbound endpoints for name resolution).
Gateway or interface endpoint?
Endpoint policies
An endpoint policy is a resource-based policy on the endpoint that limits which principals, actions and resources can be used through it, for example allowing only access to the company's own S3 buckets. The default policy allows everything. Endpoint policies work together with bucket policies, which can require access through a specific endpoint with aws:SourceVpce or from a VPC with aws:SourceVpc.
{
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::acme-*", "arn:aws:s3:::acme-*/*"]
}]
}The following diagram shows the endpoint policy and the bucket policy working together.

Endpoint policies
Endpoint services
A service provider can expose its own application to other VPCs and accounts through PrivateLink by creating an endpoint service in front of a Network Load Balancer (or Gateway Load Balancer). Consumers create interface endpoints to it in their VPCs, connections can require acceptance, and allowed principals are listed. Traffic is one-directional (consumer to provider), the networks can have overlapping CIDRs, and no peering or routing is needed. The following table compares the endpoint types.
Private access to AWS APIs
A workload in isolated subnets must use Secrets Manager, KMS, CloudWatch Logs and S3 without any internet path. The operator creates interface endpoints for secretsmanager, kms and logs with private DNS in two AZs, with a security group allowing 443 from the VPC CIDR, and an S3 gateway endpoint associated with the isolated subnets' route table. The bucket policy denies requests that do not come through the gateway endpoint (aws:SourceVpce), with an exception for the administrators' role.
Which endpoint type can be reached from on premises?
Show answer
Interface endpoints. Gateway endpoints only work for traffic from within the VPC.
Exam Tips
Remember for the exam
- Gateway endpoints (S3, DynamoDB) add route table entries and are free.
- Interface endpoints use ENIs, private DNS and security groups allowing 443.
- Only interface endpoints are reachable from on premises and peered VPCs.
- Endpoint policies limit what can be done through an endpoint; bucket policies can require aws:SourceVpce.
- Endpoint services expose your application through PrivateLink behind an NLB.