Home › AWS › AWS data services › VPC, endpoints and NAT
AWS data services · Security, identity and network · about 12 min read
Amazon VPC, VPC endpoints and NAT gateway
Your private network in AWS, the private doors from it to AWS services, and the one guarded door out to the internet.
In plain words
What it is
An Amazon Virtual Private Cloud (VPC) is a private network that you own inside AWS. You choose its address range, split it into subnets (smaller slices of addresses, each living in one availability zone, which is one data centre group in a region), and decide with route tables where traffic from each subnet may go. A subnet is called private when it has no route to the internet and its machines have no public IP addresses, so nothing on the internet can reach them directly.
Machines in a private subnet still need to talk to AWS services. A Spark cluster reading orders from S3, a job asking STS (the AWS Security Token Service, which hands out short-lived credentials) for a token, or a reader pulling sensor events from Kinesis all call public AWS addresses by default. A VPC endpoint gives them a private path instead. There are two kinds. A gateway endpoint, available only for S3 and DynamoDB, is a route-table entry that sends traffic for that service straight across the AWS network, and it costs nothing. An interface endpoint is a network card with a private IP address inside your subnet that stands in for a service such as STS, Kinesis or Secrets Manager; it is billed per hour and per gigabyte.
A NAT gateway (network address translation) is the opposite tool: a managed box that lets private machines start connections out to the internet while nothing can start a connection in. It is how a cluster downloads a Python library from a public package index. It is also billed per hour and per gigabyte, and every byte that goes through it when a free endpoint could have carried it is money wasted.
Picture a tyre plant's quality team running a nightly Databricks job that reads a week of press sensor readings, about 2 TB, from S3. Without an S3 gateway endpoint, those 2 TB flow through the NAT gateway every night and you pay its per-gigabyte processing charge on all of it. With the endpoint, the same read is free and never touches the internet path.
A gated factory campus: the VPC is the fence, endpoints are private covered walkways to the suppliers next door, and the NAT gateway is the single guarded gate where trucks can leave but strangers cannot enter.
Big picture
Where it fits
The lit lane is where VPC, endpoints and NAT works. Boxes on the left feed it; boxes on the right use what it produces.
In the reference platform every environment (dev, pre-prod, prod) has its own AWS account and its own VPC in Mumbai, with private subnets in two availability zones and no public IP address anywhere. Classic Databricks compute, the clusters that run in your account, launches into those subnets. This is a customer-managed VPC, which Databricks requires for PrivateLink and which lets your network team own the address plan, the security groups and the routes.
Three endpoints carry most of the traffic. The S3 gateway endpoint carries every read and write of landing, bronze, silver and gold files. An STS interface endpoint lets clusters swap their instance profile for the per-catalog IAM roles that Unity Catalog storage credentials point at. A Kinesis interface endpoint lets streaming jobs read the plant event belt privately. PrivateLink endpoints to Databricks itself, for the workspace and the secure cluster connectivity relay, sit beside them and are covered on their own page.
A NAT gateway stays, but on a short leash. It handles the few things that still need the internet, such as package downloads that are not yet mirrored, and an egress firewall or DNS filter can narrow it further. The Terraform layer 2-network builds all of this from Git, the same in every environment and again in Hyderabad for recovery. Plants and SAP reach these VPCs over Direct Connect and a Transit Gateway, which is why on-premises callers need interface endpoints where the free gateway endpoint cannot follow.
How it works
The ideas you need
| Idea | What it means |
|---|---|
| VPC | A private network you own in one AWS region, with an address range you choose. |
| Private subnet | A slice of the VPC in one availability zone whose machines have no public IP and no direct route to the internet. |
| Route table | The rules that say where traffic from a subnet goes: to another subnet, an endpoint, a NAT gateway or a transit gateway. |
| Gateway endpoint | A free route-table target that sends S3 or DynamoDB traffic privately; it works only from inside that VPC, in the same region. |
| Interface endpoint | A private network card in your subnet that stands in for an AWS service, built on PrivateLink and billed per hour per zone plus per gigabyte. |
| Endpoint policy | A resource policy on the endpoint that limits which principals, actions and buckets may be used through it. |
| NAT gateway | A managed device that lets private machines open outbound internet connections while blocking inbound ones; zonal or, since late 2025, regional. |
| Security group | A stateful firewall attached to a network card; Databricks classic compute and the endpoints each get their own. |
| Private DNS | The option that makes the normal service name, such as sts.ap-south-1.amazonaws.com, resolve to the interface endpoint's private address. |
| VPC Flow Logs | Records of accepted and rejected connections per network card, used to prove where traffic went. |
Choosing
When to use it, and when not
Use it when
- Use a customer-managed VPC whenever Databricks classic compute runs in your account, because it is required for back-end PrivateLink and lets your network team own routing and firewalls.
- Add the S3 gateway endpoint to every VPC that reads or writes S3 from the first day, because it is free and removes the largest NAT charge.
- Add interface endpoints for STS, Kinesis and Secrets Manager when compute must call them without any internet route, and when a security review asks for proof that no data leaves the AWS network.
- Use bucket policies with the aws:SourceVpce or aws:SourceVpc condition when only the platform's network may touch the data buckets.
- Keep one NAT gateway path, ideally regional, for the narrow set of outbound calls that cannot be avoided, and log it.
Avoid it when
- Do not build a customer VPC just for Databricks serverless compute; serverless runs in Databricks' plane and reaches your resources through network connectivity configurations, not your subnets.
- Do not add an interface endpoint for S3 for traffic that starts inside the VPC; the gateway endpoint does the same job for free. Use the interface endpoint only for callers on-premises or across a transit gateway.
- Do not create an interface endpoint for every AWS service by habit; each one costs per hour in every zone, and a dozen unused ones across three environments add up.
- Do not rely on the NAT gateway as a security control; it does not filter where traffic goes, so pair it with an egress firewall or DNS filtering if you need that.
Production grade
What goes wrong in production
| Problem | What breaks | What to do |
|---|---|---|
| NAT bill from S3 traffic | Clusters read terabytes from S3 through the NAT gateway because the gateway endpoint was missing or not attached to the right route table. The NAT processing line becomes one of the largest items on the bill. | Attach the S3 gateway endpoint to every private route table; check the NAT BytesOutToDestination metric and Cost Explorer's NatGateway-Bytes usage type after each new subnet. |
| Cross-region S3 reads | A gateway endpoint only covers buckets in its own region. A job in Mumbai reading a bucket in Hyderabad goes through NAT and pays inter-region transfer too. | Keep compute and buckets in the same region; route deliberate cross-region copies through replication, not through cluster reads. |
| STS calls failing in a closed network | Clusters with no internet route cannot assume the per-catalog IAM roles, so storage credentials fail with timeouts that look like permission errors. | Create the STS interface endpoint with private DNS, use the regional STS endpoint in Spark configuration, and test role assumption from a notebook before go-live. |
| Endpoint policy too strict or too loose | A custom endpoint policy that lists only platform buckets breaks access to AWS-owned buckets, for example those holding Amazon Linux packages or Databricks artefacts; the default full-access policy lets data leave to any bucket. | Start from a policy that allows your account's buckets plus named service buckets; test cluster start-up after every change; remember the 20,480-character limit. |
| Subnet address exhaustion | Each Databricks classic node takes two IP addresses, and subnets must be between /17 and /26; a busy job with autoscaling runs out of addresses in a small subnet and clusters fail to start. | Size subnets for peak nodes plus endpoints with room to spare; watch free IP counts; prefer serverless for bursty work. |
| NAT port exhaustion | Many workers calling the same external host exceed 55,000 simultaneous connections per NAT IP address and per destination, and connections drop. | Watch ErrorPortAllocation; add secondary IP addresses to the NAT gateway; mirror packages internally so fewer calls go out. |
| Single-zone NAT | One zonal NAT gateway shared by both zones takes down outbound access in the healthy zone when its own zone fails. | Use one zonal NAT per zone with matching routes, or the regional NAT gateway that spreads across zones by itself. |
Alternatives
What to compare it with
| Alternative | Pick the alternative when | Pick VPC, endpoints and NAT when |
|---|---|---|
| NAT gateway only (no endpoints) | A short proof of concept where the bill and audit do not matter yet. | Anything with real data volumes or a security review; every S3 byte pays NAT processing. |
| Interface endpoint for S3 | Callers on-premises or in other VPCs through a Transit Gateway must reach S3 privately. | Callers live inside the VPC; the gateway endpoint is free. |
| Databricks serverless with network connectivity configurations | Most SQL, jobs and pipelines; Databricks manages the network and you approve private endpoints to your resources. | A job must reach a private system serverless cannot yet reach; then use classic compute in your VPC. |
| Azure Virtual Network with private endpoints | The platform runs on Azure Databricks; service endpoints and private endpoints play the same roles. | You are on AWS; the concepts carry over but the parts do not. |
| Google Cloud VPC with Private Service Connect | The platform runs on GCP; Private Google Access is the closest to the S3 gateway endpoint. | You are on AWS. |
Cost
How you pay
A VPC, subnets, route tables and security groups are free. Gateway endpoints for S3 and DynamoDB carry no charge. Interface endpoints are billed for every hour they exist in each availability zone, plus a charge per gigabyte processed that drops in tiers as volume grows (for example about 0.01 USD per endpoint per zone per hour and 0.01 USD per GB in us-east-1, list price, check your region). A NAT gateway is billed per hour and per gigabyte processed, and ordinary data transfer charges apply on top for traffic leaving the region or going to the internet.
What drives the bill
- Gigabytes through the NAT gateway, which is where a missing S3 gateway endpoint shows up.
- The number of interface endpoints times the number of zones times the number of environments.
- Gigabytes through interface endpoints, mainly Kinesis reads and writes for streaming.
- Cross-zone and cross-region data transfer between clusters, endpoints and buckets.
Cost traps
- Turning on private DNS for an S3 interface endpoint without the inbound-resolver-only option sends in-VPC S3 traffic through the paid interface endpoint instead of the free gateway endpoint.
- Leaving dev and test endpoints and NAT gateways running all month for environments used a few hours a week.
- Classic clusters in one zone reading through an endpoint or NAT in the other zone pay cross-zone transfer on every byte.
- Databricks serverless private endpoints carry Databricks networking charges on the Databricks bill, not the AWS bill, so they are easy to miss in an AWS-only cost review.
Prices change; check the AWS pricing page for your region before deciding.
Security and governance
Keeping it safe
- No public IP addresses on any compute; enforce it with a service control policy and the Databricks workspace setting, not by convention.
- Bucket policies deny access unless the request comes through the platform's VPC endpoint (aws:SourceVpce) or from the Databricks roles, so a leaked key used from outside cannot read data.
- Endpoint policies limit what may pass through each endpoint, for example only the platform's buckets and the AWS-owned buckets clusters need to start.
- VPC Flow Logs go to the central log-archive account and are kept with CloudTrail, so an auditor can see that data never crossed the internet.
- The NAT gateway does not filter destinations; if you must prevent data leaving to unknown hosts, put DNS filtering or a network firewall in its path.
Operating it
What to watch, and the limits
| Watch | Why |
|---|---|
| BytesOutToDestination (NAT gateway) | Bytes leaving through NAT; a jump usually means S3 or Kinesis traffic is missing its endpoint. |
| ErrorPortAllocation (NAT gateway) | The NAT gateway ran out of source ports for a destination; connections are being dropped. |
| PacketsDropCount (NAT gateway) | Packets dropped by the NAT gateway, often from overload. |
| BytesProcessed (interface endpoints) | Traffic through each interface endpoint, which is what the per-gigabyte charge follows. |
| VPC Flow Logs REJECT records | Connections blocked by security groups or network ACLs; the first place to look when a cluster cannot reach a service. |
| NatGateway-Bytes in Cost Explorer | The cost view of NAT processing per account; review it weekly per environment. |
| Limit | Value and notes |
|---|---|
| Interface and Gateway Load Balancer endpoints per VPC | 50 by default, adjustable |
| Gateway endpoints | 20 per region by default (adjustable), and up to 255 per VPC |
| Endpoint policy size | 20,480 characters, not adjustable |
| Interface endpoint bandwidth | 10 Gbps per zone by default, scaling automatically to 100 Gbps |
| NAT gateway throughput | 5 Gbps scaling automatically to 100 Gbps; 55,000 simultaneous connections per IP address to each unique destination |
Limits and quotas checked 2026-11-11; many can be raised through Service Quotas.
Decisions
Situations and verdicts
| Situation | Choice | Verdict |
|---|---|---|
| Classic clusters reading 2 TB of sensor history from S3 each night | S3 gateway endpoint on every private route table | Pursue: free, private and removes the largest NAT line on the bill. |
| Clusters must assume per-catalog IAM roles with no internet route | STS interface endpoint with private DNS and the regional STS endpoint | Pursue: without it storage credentials fail in a closed network. |
| Streaming jobs reading the plant Kinesis stream | Kinesis interface endpoint in both zones | Pursue: keeps the event belt private; watch its per-gigabyte charge as volumes grow. |
| Clusters need public Python packages | Regional NAT gateway behind a DNS filter, with a package mirror planned | Pursue with care: keep NAT for what truly needs the internet and measure what goes through it. |
| Plant historian on-premises writing straight to S3 | S3 interface endpoint reached over Direct Connect and the Transit Gateway | Pursue with care: the gateway endpoint cannot be reached from on-premises, so pay for the interface endpoint only for that traffic. |
FAQ
Questions people ask
What is the difference between a gateway endpoint and an interface endpoint?
A gateway endpoint is a free route-table entry that only works for S3 and DynamoDB and only for traffic starting in that VPC. An interface endpoint is a private network card in your subnet, works for many services and from on-premises, and is billed per hour and per gigabyte.
Why is my NAT gateway so expensive with Databricks?
Usually because S3 traffic from classic clusters goes through it. Add the S3 gateway endpoint to the route tables of the Databricks subnets, keep buckets in the same region, and check Cost Explorer a day later. Serverless compute avoids NAT entirely.
Does Databricks need a NAT gateway at all?
Classic compute with back-end PrivateLink and endpoints for S3, STS and Kinesis can run without internet access, but it then cannot download public libraries or call outside APIs. Most teams keep a narrow NAT path or mirror packages internally.
Do I need a customer-managed VPC for Databricks on AWS?
You need one for classic compute with PrivateLink, which the reference platform uses. A serverless-only workspace does not need one; it reaches your private resources through a network connectivity configuration.
What is the regional NAT gateway?
A mode added in November 2025 where one NAT gateway serves the whole VPC and expands across availability zones by itself, without a public subnet per zone. The older zonal mode still exists and is needed for private NAT.
Sources
Checked against
- AWS docs: Gateway endpoints for Amazon S3
- AWS docs: AWS PrivateLink quotas
- AWS docs: NAT gateway basics
- AWS What's New: NAT Gateway regional availability
- AWS PrivateLink pricing
- Databricks docs: Classic compute plane PrivateLink
Checked 2026-11-11.
Related
Where it connects
AWS and Databricks reference platform · AWS PrivateLink · Direct Connect, VPN and Transit Gateway · Amazon S3 · Cost calculator · All AWS data services
← Secrets Manager · AWS Backup →