Lesson 3 of 5 Encryption in Transit and Certificates

Keeping Traffic Private with VPC Endpoints and PrivateLink

This lesson explains how private connectivity keeps traffic to AWS and partner services off the internet and makes network-based policy conditions possible.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish gateway endpoints from interface endpoints.
  • Use endpoint policies and aws:SourceVpce conditions as data perimeter controls.
  • Describe how PrivateLink endpoint services expose your own services.

Endpoint types

VPC endpoints let resources reach AWS services without an internet gateway or NAT device, and there are two types. A gateway endpoint supports only S3 and DynamoDB. It adds routes, using the service's prefix list, to the route tables you choose. It is free, and access is controlled by an endpoint policy. It cannot be used from on premises or from another VPC.

An interface endpoint, powered by AWS PrivateLink, supports most other services, such as KMS, Secrets Manager, STS, Systems Manager, CloudWatch and Bedrock. It places network interfaces with private IP addresses in your subnets, and private DNS makes the service's standard name resolve to them, so applications need no change. It is charged per hour and per gigabyte, and both an endpoint policy and security groups control access. The following table summarises the differences.

Gateway endpoint
ServicesS3 and DynamoDB
HowRoutes (prefix lists) in selected route tables
CostFree
Access controlEndpoint policy
Interface endpoint (PrivateLink)
ServicesMost AWS services: KMS, Secrets Manager, STS, SSM, CloudWatch, Bedrock…
HowENIs with private IPs in your subnets; private DNS resolves standard names to them
CostHourly plus per GB
Access controlEndpoint policy and security groups
Sort into groups

Gateway or interface endpoint?

Exam skills 5.1.2

Decide which VPC endpoint type each statement describes.

Log in to try this activity Interactive activities are free with an account.

Policies that use endpoints

VPC endpoints keep traffic to AWS services on the AWS network, but they also provide control points for data perimeters. An endpoint policy limits which principals and resources can be reached through the endpoint, which prevents data from being copied to an attacker's resources in another account. Resource policies can require that requests arrive through a specific endpoint or VPC, which ensures that data cannot be accessed from outside the network, even with valid credentials. The following list describes the relevant policies.

  • Endpoint policies restrict what is reachable, e.g. only your organisation's buckets with aws:ResourceOrgID, preventing exfiltration to attacker buckets.
  • Resource policies on buckets, keys or secrets can deny access unless the request comes through a given endpoint (aws:SourceVpce) or VPC (aws:SourceVpc).

The following diagram compares a call through a production VPC endpoint with a call from the internet for a secret whose resource policy requires the endpoint.

A secret retrievable only through the production VPC endpoint. The resource policy denies GetSecretValue unless aws:SourceVpce is vpce-0prodsecrets123 or the caller is the BreakGlass role, so stolen credentials are useless from the internet. Console calls and AWS services lack the key, so exceptions must be designed in.
The scenario is illustrative.
True or false

Endpoints as perimeter controls

Exam skills 5.1.2 · 4.2.3

Check how endpoint and resource policies build a data perimeter.

Log in to try this activity Interactive activities are free with an account.

Exposing your own services

AWS PrivateLink can also expose the customer's own services. An endpoint service places a service behind a Network Load Balancer (or a Gateway Load Balancer for security appliances), and consumers in other VPCs and accounts create interface endpoints to reach it privately. Traffic flows in one direction only, from consumer to provider, there is no VPC peering or route table change, and overlapping IP address ranges do not matter. The provider controls which principals can connect and can require each connection request to be accepted. Many SaaS providers offer their services in this way.

True or false

Endpoint services

Exam skills 5.1.2

Check how PrivateLink exposes your own services.

Log in to try this activity Interactive activities are free with an account.
Worked example

Secrets reachable only through the VPC

A database password in Secrets Manager must be retrievable only from inside the production VPC, so stolen credentials are useless from the internet. An interface endpoint provides the private path, and the secret's resource policy refuses every other path:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "OnlyThroughProdEndpoint",
    "Effect": "Deny",
    "Principal": "*",
    "Action": "secretsmanager:GetSecretValue",
    "Resource": "*",
    "Condition": {
      "StringNotEquals": { "aws:SourceVpce": "vpce-0prodsecrets123" },
      "ArnNotLike": { "aws:PrincipalArn": "arn:aws:iam::111111111111:role/BreakGlass" }
    }
  }]
}

The endpoint policy can narrow things further, allowing only this account's secrets through the endpoint. Note that aws:SourceVpce is present only on requests that travel through a VPC endpoint; calls from the console, or by AWS services on your behalf, lack it, which is why break-glass and service exceptions must be designed in.

Check yourself

How can a VPC endpoint stop exfiltration to buckets outside the organisation?

Show answer

With an endpoint policy that allows only resources whose aws:ResourceOrgID is your organisation.

Exam Tips

Remember for the exam

  • To reach S3 from private subnets without the internet, use a gateway endpoint, which is free.
  • For private access to KMS or Secrets Manager from isolated subnets, use interface endpoints.
  • To stop exfiltration to buckets outside the organisation, use an endpoint policy with aws:ResourceOrgID.
  • To ensure a bucket can be accessed only through your VPC, use an aws:SourceVpce condition.
  • To expose a service privately to other accounts, use a PrivateLink endpoint service.