Cloud Networking and VPC Design Questions
Designing networks inside a cloud provider: VPC/VNet topology, subnets, route tables, gateways, NAT, and peering, plus private connectivity through VPC endpoints and cloud load balancers. Covers segmentation, security groups and network ACLs, hybrid connectivity to on-premises data centers over VPN or dedicated links like Direct Connect and ExpressRoute, IP address planning across many VPCs and accounts, and how cloud network design differs from traditional data-center networking.
Before launching a new workload that needs to reach an internal database, a private object store, and one external SaaS API, what networking, DNS, egress, and reliability concerns would you validate, and how would you test them in staging?
Sample Answer
Direct Answer
Validate three distinct connectivity paths before launch, the internal database, the private object store, and the external SaaS (Software as a Service) API, because each has a different failure mode and a different fix. Then prove each one under actual failure, not just under a happy-path connection test, by deliberately breaking DNS, denying egress (blocking outbound traffic), and forcing a database failover in staging before trusting any of it in production.
Internal Database
Networking. Confirm the route from the new workload's subnet to the database subnet exists, and confirm the database's security group actually allows this specific new caller; a common miss is a security group still scoped to an old instance's identity that was never updated for the new workload.
DNS and reliability. Confirm the workload targets the database's durable endpoint, a cluster endpoint or a connection proxy that survives failover, rather than a specific instance's address; targeting an instance address directly means a failover breaks connectivity even though the database itself is still up. The reliability question that actually needs testing, not assuming, is what happens to in-flight connections and how quickly the client reconnects during a real failover.
Private Object Store
Networking and DNS. Confirm the VPC (Virtual Private Cloud) endpoint's route and, if scoped, its resource policy actually cover this subnet and this specific bucket. Confirm the workload is not accidentally resolving the public endpoint and routing through NAT (Network Address Translation) instead of the intended private path, which happens when an SDK's regional endpoint configuration does not match or a proxy setting overrides it.
Egress. Verify there is not also an accidental NAT or internet path available that would work today by coincidence and only reveal the private-path misconfiguration later, for example when NAT capacity is intentionally reduced for cost reasons.
External SaaS API
Egress. Confirm which NAT gateway or egress proxy this traffic will actually use, and confirm the SaaS provider's IP allowlist, many require allowlisting the caller's egress address, matches that NAT gateway's current address, not a stale address left over from a previous NAT gateway.
DNS. Confirm the API's hostname resolves consistently and is not served from a content delivery network that returns different addresses per query in a way that could break a static allowlist entry on the provider's side.
Reliability. Confirm what the workload does when the SaaS API times out or rate-limits it, retry and backoff behavior, since an external dependency's outage should degrade the new workload gracefully, not cascade into its own availability.
How to Test All of This in Staging
Confirming that each dependency connects successfully is not enough; deliberately break each one in staging and observe the actual behavior.
Block DNS temporarily. Drop or black-hole resolution for the SaaS hostname, or the whole subnet's resolver, and confirm the workload fails in an expected way, a clear timeout and an alert, rather than a silent hang or a crash loop.
Deny egress temporarily. Remove the path to the SaaS API, the NAT route, the security-group rule, or the VPC endpoint route, and confirm the workload's error handling and alerting actually fire; this catches the case where a workload silently degrades a feature instead of surfacing that the integration is down.
Exercise database failover. Trigger an actual staging failover, most managed database services support an on-demand test failover, while the workload is under light load, and measure how long reconnection genuinely takes and whether any requests are lost or duplicated. This is the only way to know the connection and retry logic is correct; reasoning about it without testing it is exactly the kind of unverified claim that does not hold up.
Worked Example
| Dependency | Primary concern | Staging fault-injection test | Pass criterion |
|---|---|---|---|
| Internal database | Security group allows the new caller; workload uses a failover-safe endpoint | Trigger an on-demand failover under light load | Workload reconnects within its own defined timeout, no data loss on idempotent operations |
| Private object store | Traffic actually uses the VPC endpoint, not NAT or a public path | Temporarily remove the NAT route, leaving only the endpoint | Requests still succeed, confirming the private path was really being used rather than silently falling back |
| External SaaS API | Correct egress address allowlisted; sane timeout and retry behavior | Deny egress to the SaaS API's address range | Workload surfaces a clear failure and alert within its timeout, rather than hanging or crash-looping |
Trade-offs and Pitfalls
Validating only that a connection succeeds and never validating what happens when it fails is the single biggest gap in most pre-launch checklists; a workload that works in a demo can still have completely unvalidated, and often terrible, failure behavior.
Allowlisting a NAT gateway's current address with an external provider and forgetting that recreating the NAT gateway, a fairly routine operational event, usually assigns a new address is a recurring, silent breakage. Prefer a stable mechanism, an explicitly associated static address preserved across recreation, or PrivateLink (a private connection straight to the provider's specific service, without routing through the public internet or a NAT gateway) to the provider where it is offered, over a one-time manual allowlist entry.
Testing database failover against a synthetic health check rather than the actual application's connection pool and retry logic misses exactly where reconnection bugs actually live.
Fault-injection testing in staging costs real time and coordination, especially triggering an actual failover, versus trusting the happy path. That cost is worth paying for dependencies the workload genuinely cannot function without, and can be lightened for optional, best-effort integrations.
Compare ALB, NLB, and Gateway Load Balancer and recommend an architecture for a web application that requires TLS termination, WebSocket support, and a separate TCP-based backend service that must be proxied to third‑party IDS appliances. Explain choices for cross-zone load balancing, WAF, health checks, and sticky sessions.
Sample Answer
Direct answer
Application Load Balancer (ALB) operates at Layer 7 (the application layer) and understands HTTP/HTTPS and WebSockets, making it the right front door for the web tier that needs TLS (Transport Layer Security) termination and content-aware routing; Network Load Balancer (NLB) operates at Layer 4 (the transport layer), handling raw TCP/UDP at very high throughput and extremely low latency with no visibility into the traffic's content, making it the right choice for the separate TCP-based backend that must be proxied, byte for byte, to third-party intrusion detection system (IDS) appliances; Gateway Load Balancer (GWLB) is a specialized Layer-3/4 load balancer purpose-built to insert third-party network appliances transparently into a traffic path. For this workload, the recommended architecture is an ALB in front of the web tier for TLS termination and WebSocket support, with the separate TCP backend service reached through an NLB, and if the IDS appliances need to transparently inspect traffic in-line rather than just receive a proxied copy, a GWLB sits in front of those appliances specifically.
Structured elaboration
| Dimension | ALB | NLB | GWLB |
|---|---|---|---|
| OSI layer | Layer 7 (application) | Layer 4 (transport) | Layer 3/4 (network/transport), purpose-built for appliance insertion |
| Protocol awareness | Understands HTTP/HTTPS, WebSockets, gRPC; can route on host header, path, or other request content | Protocol-agnostic at the packet level: TCP, UDP, TLS passthrough | Passes traffic transparently to third-party virtual appliances (firewalls, IDS/IPS, IPS being the always-blocking sibling of IDS: an intrusion prevention system) using GENEVE encapsulation (a tunneling protocol that wraps the original packet so it can be delivered to the appliance and sent back unaltered) |
| TLS termination | Yes, natively, with certificate management built in | Only TLS passthrough (the backend terminates TLS itself) unless using NLB's own TLS listener feature, which still doesn't give content-based routing | Not applicable; it delivers the packet to the appliance, termination and inspection happen there |
| WebSocket support | Yes, natively | Works, since NLB just passes TCP through at the connection level | Not applicable to this use case |
| Latency and throughput | Higher latency than NLB because it terminates and processes at Layer 7; still very capable for typical web workloads | Extremely low latency, extremely high throughput, since it does no content inspection, just forwards connections | Adds appliance processing latency by design (that is the point: traffic is meant to be inspected) |
| Typical use case here | Public-facing web tier | The separate TCP backend service that must be proxied intact to an IDS appliance | In-line insertion of the IDS appliances themselves if traffic must be transparently intercepted rather than mirrored or received as a separate proxied stream |
Cross-zone load balancing. For a workload spread across multiple Availability Zones (AZs), cross-zone load balancing determines whether each load balancer node distributes traffic only to targets in its own AZ, or across all registered targets in every AZ. ALB has cross-zone load balancing enabled by default at the load balancer level, and that load-balancer-level setting cannot be turned off; AWS does let you disable cross-zone load balancing for an individual target group if a specific target group needs zone-local behavior, but the default posture, and the one that applies unless you deliberately override it per target group, is evenly distributed across every AZ, which is usually the right behavior for an HTTP workload: it evens out load regardless of how evenly clients happen to be distributed across AZs. NLB defaults to cross-zone disabled (each zone's traffic stays local to that zone's targets) because for a latency- and throughput-sensitive Layer-4 workload, keeping traffic zone-local avoids an extra cross-AZ hop and its associated data-transfer cost; it can be enabled explicitly if target distribution across AZs is uneven enough that zone-local routing would overload one AZ's targets.
WAF. A web application firewall (WAF) attaches to the ALB (not to NLB or GWLB, since WAF inspects Layer-7 HTTP content) to filter common web attacks, bad bots, and known malicious patterns before traffic reaches the web tier, reducing both attack surface and unnecessary load on the application itself.
Health checks. ALB health checks are HTTP/HTTPS-based: they call a specific path and expect a specific status code, so they can detect an application that is technically running but returning errors, not just a dead process. NLB health checks are typically TCP-based (a bare connection check) unless configured otherwise, since NLB generally does not inspect content; for the TCP backend service here, health checks confirm the port is accepting connections, but detecting an application-level failure behind that port requires the backend service to fail the TCP connection itself when unhealthy, or a separate application-level health mechanism.
Sticky sessions. ALB supports session stickiness through a cookie it manages (or an application-generated cookie it can key off of), which is often needed for stateful web sessions that have not externalized their session state to a shared store. NLB's stickiness works differently, at the connection level (the same client IP and port routes to the same target for the life of that connection) rather than through cookies, since it has no visibility into HTTP at all.
Worked example
graph TD
CLIENT((Client)) -->|HTTPS + WebSocket| WAF[WAF]
WAF --> ALB[ALB: TLS termination, sticky sessions]
ALB --> WEBTARGETS[Web tier targets]
CLIENT -->|Raw TCP| NLB[NLB: TCP passthrough]
NLB --> GWLB[GWLB in front of IDS appliances]
GWLB --> IDS[Third-party IDS appliances]
IDS --> BACKENDSVC[TCP backend service]
The web tier sits behind the ALB: TLS is terminated there (certificates managed centrally rather than on every backend instance), WebSocket connections are upgraded and proxied transparently, and a sticky-session cookie keeps a given client's requests landing on the same backend instance for the duration of its session, if the application has not externalized session state. The separate TCP-based backend service, which by the question's own framing must be proxied to third-party IDS appliances rather than served directly, is fronted by an NLB for raw, low-latency TCP forwarding; if the requirement is that the IDS appliances must transparently inspect this traffic in-line (as opposed to receiving a redirected copy after the NLB), a GWLB is placed specifically in front of the IDS appliance fleet, since GWLB's entire purpose is making a fleet of third-party appliances look like a single, scalable, highly available next hop in a traffic path.
Trade-offs and pitfalls
The most common mistake is trying to make a single load balancer type do both jobs: putting the TCP backend behind an ALB either fails outright (ALB cannot proxy arbitrary TCP the way NLB does) or forces an awkward workaround, and putting the web tier behind an NLB alone loses TLS termination management, content-based routing, and WebSocket-aware handling that ALB provides natively. A second pitfall is assuming GWLB is simply "another load balancer option" rather than understanding its specific purpose: it exists to insert third-party appliances into a traffic path transparently and at scale, and reaching for it when you actually just need NLB's plain TCP forwarding adds appliance-hop latency and operational complexity with no benefit. Finally, teams sometimes leave NLB's cross-zone load balancing at its default (disabled) without checking whether their actual target distribution across AZs is even enough to make that safe, then discover one AZ's targets are overloaded while another AZ's targets sit idle, purely because clients happened to connect unevenly across AZs that day.
Explain what a Virtual Private Cloud (VPC) is across AWS, Azure, and GCP. Describe the core components (subnets, route tables, internet gateway or equivalent, NAT, security groups, and network ACLs) and explain the differences between public and private subnets. Provide a simple example layout for a 3-tier web application (web, app, db), indicating which tiers belong in public vs private subnets and why.
Sample Answer
Direct answer
A Virtual Private Cloud (VPC), called a VNet (Virtual Network) on Azure, is a logically isolated, software-defined slice of a cloud provider's physical network that you carve out for your own resources. You define its private IP address range, split it into subnets, control what can route in and out, and layer firewall rules on top. The building blocks are the same on AWS, Azure, and GCP even though the names differ: an address space, subnets that place resources in specific zones, route tables that decide where traffic goes, an internet-facing gateway, NAT (Network Address Translation: swapping a private IP address for a public one) for outbound-only internet access, and two layers of firewalling (one per instance, one per subnet).
Structured elaboration
Core components, mapped across the three providers:
| Concept | AWS | Azure | GCP |
|---|---|---|---|
| The network container | VPC | VNet (Virtual Network) | VPC network (global, not regional) |
| Subdivision by zone | Subnet (tied to one Availability Zone, AZ) | Subnet (tied to a region, zone-redundant) | Subnet (regional, spans all zones in that region) |
| Routing rules | Route table | Effective routes / User-Defined Routes (UDR) | Routes (global, automatic + custom) |
| Path to the public internet | Internet Gateway (IGW) | Public IP + (optionally) an internet-facing NAT gateway or load balancer | Default route via the implied internet gateway |
| Outbound-only internet for private resources | NAT Gateway | Azure NAT Gateway | Cloud NAT |
| Instance-level firewall | Security group (stateful, attached to the elastic network interface, ENI) | Network Security Group (NSG), same idea | Firewall rules (tag or service-account scoped, VPC-wide but effectively per-instance) |
| Subnet-level firewall | Network ACL (NACL, stateless) | NSG can also attach to a subnet | No separate stateless layer; firewall rules are the only layer |
The one structural difference worth knowing cold: AWS and Azure subnets are pinned to a single AZ, so a highly available design needs one subnet per tier per AZ. GCP subnets are regional and automatically span every zone in that region, so a GCP design needs far fewer subnet objects to get the same zonal spread.
Public vs private subnet, the actual definition. A subnet is "public" only because its route table sends 0.0.0.0/0 (all internet-bound traffic) to an internet gateway. A subnet is "private" when its route table has no such route: outbound internet access, if any, goes through a NAT gateway instead, and there is no path for unsolicited inbound traffic from the internet at all. Nothing about the subnet's IP range or a checkbox makes it public or private; it is entirely a routing decision. That means you can silently turn a private subnet public by adding one route, which is why route tables are the thing to audit, not subnet names.
- Public subnet: route table has a
0.0.0.0/0 -> IGWroute. Resources here can receive inbound connections from the internet if a security group allows it (a public web server, a load balancer, a bastion host). - Private subnet: no route to an IGW. Resources here cannot be reached directly from the internet. If they need outbound internet access (to pull OS patches or call a third-party API), traffic is routed through a NAT gateway that lives in a public subnet, which translates their private addresses to its own public one and hides them from unsolicited inbound connections.
Worked example
A standard 3-tier web application, one AZ shown (repeat per AZ for high availability):
graph TD
INTERNET((Internet)) --> IGW[Internet Gateway]
IGW --> ALB[Load Balancer - public subnet]
ALB --> WEB[Web tier - public subnet]
WEB --> APP[App tier - private subnet]
APP --> DB[(Database tier - private subnet)]
APP --> NAT[NAT Gateway - public subnet]
NAT --> IGW
- Web tier: public subnet. It must accept inbound HTTP/HTTPS from arbitrary internet clients, so it needs the IGW route. Security group allows inbound 443 from 0.0.0.0/0 and nothing else.
- App tier: private subnet. It only ever receives traffic that the web tier forwards to it; nothing on the internet should be able to open a connection to it directly. Its security group allows inbound only from the web tier's security group, on the application port. It still needs outbound internet access for things like calling a payment API or pulling a dependency, which is why the private subnet's route table sends 0.0.0.0/0 to the NAT gateway, not the IGW.
- Database tier: private subnet, and stricter than the app tier. It has no legitimate reason to reach the internet at all (patches usually come through a maintenance window or a private mechanism, not a live outbound call), so many teams give it no NAT route whatsoever, only local VPC routes. Its security group allows inbound only from the app tier's security group, on the database port.
The reasoning behind this layout is defense in depth and blast-radius containment: if an attacker compromises the internet-facing web tier, the private subnets' lack of a route back from the internet, plus security groups that only trust the tier directly upstream, mean the attacker cannot reach the database in one hop. A common refinement worth naming even though it wasn't in the layout above: instead of routing the app tier's outbound calls to specific AWS services (object storage, a private API) through the NAT gateway and out to the internet and back, add a VPC endpoint. For example, a data-processing app pulling training data from S3 gets a Gateway Endpoint for S3, a routing-table entry that sends S3 traffic over AWS's internal network instead of through the NAT gateway and the public internet. That traffic no longer counts against NAT data-processing charges and never leaves AWS's backbone, which is both cheaper and a smaller attack surface. The same core-components list above (VPC, subnets, route tables, an internet gateway, NAT, security groups, NACLs) applies unchanged whether the workload sitting behind it is a web app, a data-processing cluster reading from object storage, or any other three-tier shape: the tier names change, the routing and isolation logic does not.
When you plan this layout, decide four things up front rather than reactively: how many Availability Zones you need (at least two, for anything that has to survive a zone outage), how big a CIDR block to give the VPC and each subnet (oversize subnets rather than sizing them to exactly today's instance count, since resizing a live subnet is disruptive), which tiers actually need internet reachability at all (fewer than people assume), and where you will need private connectivity to managed services later so you are not retrofitting a NAT bottleneck.
Trade-offs and pitfalls
The most common mistake is putting the application tier in a public subnet "to make debugging easier" and locking it down with security groups alone. Security groups are the right control for who can talk to an instance, but they do not stop a misconfigured resource, like a database with a public IP by accident, from being reachable from the internet in the first place; only the route table (no IGW route) guarantees that. A second pitfall is forgetting that a private subnet with no NAT route also has no outbound internet: this is fine for a database but will silently break an application tier that needs to call an external API, so "private" and "internet-reachable outbound" are two separate decisions you make per tier, not one. Finally, teams sometimes conflate "private subnet" with "encrypted" or "compliant"; subnet placement controls network reachability only; encryption, IAM (identity and access management: who is allowed to do what), and logging are separate controls layered on top.
At a high level, explain AWS VPC Peering versus AWS Transit Gateway. For which scenarios would you recommend Transit Gateway over peering as the number of VPCs grows, and why? Discuss scaling, route propagation, centralization of services, and cost implications.
Sample Answer
Direct answer
VPC Peering is a direct, point-to-point private connection between exactly two Virtual Private Clouds (VPCs) that routes as if they were on the same network, with no gateway or extra hop in between. Transit Gateway is a managed hub: every VPC, VPN, and Direct Connect connection (a dedicated private network link from an on-premises facility into the cloud, unlike peering or a Transit Gateway attachment) attaches to it once, and the Transit Gateway routes between all attached networks according to its own route tables, so no VPC needs a direct connection to any other. Peering makes sense while the number of VPCs that need to talk to each other is small; Transit Gateway earns its keep the moment that number grows enough that a full mesh of peering connections becomes the harder thing to operate, not the cheaper one.
Structured elaboration
Why peering does not scale on its own: the mesh problem. Peering is non-transitive: if VPC A peers with VPC B, and B peers with C, A cannot reach C through B: A needs its own direct peering connection to C. Connecting N VPCs so that all of them can reach each other requires N x (N-1) / 2 peering connections. That is 10 connections for 5 VPCs, 45 for 10 VPCs, and 190 for 20 VPCs: it grows quadratically, not linearly, and each one is a separate resource to create, route, and eventually decommission.
| Dimension | VPC Peering | Transit Gateway |
|---|---|---|
| Topology | Point-to-point, non-transitive | Hub-and-spoke; every attachment can reach every other attachment (subject to route tables) |
| Scaling | Quadratic connection count as VPCs grow | Linear: one attachment per VPC, regardless of how many VPCs there are (up to the attachment quota) |
| Route propagation | Manual: add a route in each peered VPC's route table pointing at the peering connection | Centralized: Transit Gateway route tables control reachability for every attached network in one place |
| Centralizing shared services | Awkward: a "hub" VPC still needs a direct peering connection to every spoke | Natural: attach a shared-services VPC once and every other attachment can reach it through Transit Gateway routing, no extra connections needed |
| Cross-account | Supported, but each connection needs manual accept/request handling per account pair | AWS Resource Access Manager (RAM) lets you share one Transit Gateway across accounts, so onboarding a new account's VPC is one attachment, not N new peering connections to every existing account |
| Cost | No hourly charge for the peering connection itself, only standard data-transfer rates | Hourly charge per attachment plus a per-gigabyte data-processing charge on top of data-transfer rates |
| Known limitations | CIDR blocks (the IP address ranges assigned to each VPC, written like 10.0.0.0/16) of the two VPCs must not overlap; peering does not by itself enable private DNS resolution across the connection, you must explicitly enable DNS resolution support on both sides for private hostnames to resolve to private IPs across the peering connection | Higher baseline cost per attachment; adds an extra network hop and its own route tables to reason about |
When to recommend Transit Gateway over peering as VPC count grows. The decision point is not a fixed VPC count so much as whether you are trending toward needing most VPCs to reach most other VPCs (or a shared set of services). A handful of VPCs with a narrow, stable set of point-to-point relationships (say, a data VPC that only ever needs to talk to two specific application VPCs) can stay on peering indefinitely; the operational cost of two or three peering connections is trivial. The moment you are adding a new VPC every few weeks and each one needs to reach a shared-services VPC (logging, a central database, a security tooling VPC), Transit Gateway turns "one new peering connection per existing VPC that needs access" into "one new attachment, done." A concrete trigger worth naming: an organization running around 25 VPCs across several AWS accounts that all need to reach a shared services VPC is already past the point where peering is the simpler design, since that shared VPC alone would need roughly 25 separate peering connections, each with its own route-table entries to maintain, versus 25 straightforward Transit Gateway attachments managed from one set of route tables.
Worked example
A company starts with 3 VPCs: production, staging, and a shared-services VPC holding a central logging pipeline. Three peering connections (prod-shared, staging-shared, and, if prod and staging ever need to talk directly, prod-staging) is entirely reasonable; nobody should reach for Transit Gateway here. Eighteen months later the company has grown to 12 AWS accounts, each with its own VPC, all needing to reach that same shared-services VPC and, in a few cases, each other. A full mesh at that scale would need up to 66 peering connections; even the minimal "everyone talks only to shared-services" star topology needs 12 direct peering connections, each independently routed, and every new account added means one more. At this point the team migrates to Transit Gateway: shared with the other 11 accounts through AWS Resource Access Manager (RAM) so each account owner attaches their own VPC without the central network team creating a connection per account, and Transit Gateway route tables enforce that spoke VPCs can reach shared-services but not each other directly, a segmentation policy that would have required careful, individually maintained route tables in a pure-peering design.
Trade-offs and pitfalls
The most common mistake is reaching for Transit Gateway on day one "for future-proofing" when 2 or 3 VPCs are the entire foreseeable footprint: it adds an hourly per-attachment cost and an extra hop for no benefit if the mesh never grows past a size peering handles comfortably. The opposite mistake, staying on peering well past the point of diminishing returns, is more common and more expensive to unwind: teams often notice the problem only when they are maintaining dozens of peering connections' worth of route-table entries by hand and a single new VPC onboarding takes a checklist of individual peering requests. A specific peering gotcha worth calling out explicitly: even after a peering connection is active and routes exist, resources will fail to resolve each other's private DNS names across it until DNS resolution support is explicitly enabled on both VPCs' sides of the connection, which is easy to miss because the underlying IP connectivity works fine and masks the DNS gap until someone's code tries to connect by hostname instead of IP.
Explain AWS VPC endpoints and the differences between Interface Endpoints (PrivateLink) and Gateway Endpoints. Provide concrete examples: how would you grant private access to S3 and to a private API in your VPC without exposing traffic to the public internet?
Sample Answer
Direct answer
A VPC endpoint lets resources inside a Virtual Private Cloud (VPC) reach a supported service privately, over the provider's internal network, without the traffic ever crossing the public internet and without needing a NAT gateway or internet gateway at all. There are two kinds: a Gateway Endpoint, which works only for a small set of services (Amazon S3 and DynamoDB) and is implemented as a route-table entry with no additional cost, and an Interface Endpoint (built on AWS PrivateLink), which works for the vast majority of AWS services plus many third-party and customer-hosted services, and is implemented as an actual network interface with a private IP address inside your subnet, billed per Availability Zone-hour plus data processed.
Structured elaboration
| Dimension | Gateway Endpoint | Interface Endpoint (PrivateLink) |
|---|---|---|
| Supported services | Only S3 and DynamoDB | Most AWS services, many AWS Marketplace services, and any service a provider chooses to publish via PrivateLink, including services in your own other VPCs or accounts |
| How it works | A special target in your subnet's route table, pl-xxxx -> vpce-xxxx, that redirects traffic destined for the service's published IP ranges | An Elastic Network Interface (ENI) with a private IP address placed directly in your subnet; traffic reaches it exactly like any other resource in the subnet |
| Cost | No hourly or per-gigabyte charge from the endpoint itself | Hourly charge per Availability Zone the endpoint is deployed in, plus data processed |
| DNS | Private DNS is optional; without it, applications must use the service's endpoint-specific DNS name explicitly | Private DNS can be enabled so the service's normal public DNS name (e.g. an API's default hostname) automatically resolves to the interface endpoint's private IP inside the VPC, so no application code changes are needed |
| Reach | Limited to the VPC(s) whose route tables you add the entry to | Reachable from anywhere with network access to the ENI: the local VPC, and, with the right routing, from peered VPCs or on-premises networks over Direct Connect or VPN |
| Security control | Endpoint policy (which principals/actions are allowed through this endpoint) plus the target service's own resource policy | Endpoint policy, the target service's own policy, plus a security group directly on the ENI, giving you an extra network-layer control interface endpoints alone have |
Worked example
Private access to S3 without touching the public internet: a Gateway Endpoint. A data-processing application running in a private subnet needs to read training data from an S3 bucket. Without an endpoint, that traffic would need a NAT gateway to reach S3's public endpoint over the internet, incurring NAT data-processing charges and taking a path that leaves the provider's network. Adding an S3 Gateway Endpoint to the VPC and associating it with the private subnet's route table adds a route that sends traffic destined for S3's published IP prefix list directly to the endpoint instead of the NAT gateway, at no additional cost for the endpoint itself, and the traffic never leaves AWS's network. The bucket's own policy can then be tightened to require that requests arrive via this specific endpoint (using a condition on the endpoint's ID), which closes off the possibility of the same bucket being reached from some other, less trusted network path.
Private access to a private API in your VPC: an Interface Endpoint. A separate team owns an internal pricing API running behind a Network Load Balancer in its own VPC, and another team's application, in a different VPC, needs to call it without any public exposure and without a full VPC peering or Transit Gateway relationship (which would give broader network access than intended). The pricing team publishes their load balancer as a PrivateLink endpoint service; the consuming team creates an Interface Endpoint for that specific service in their own VPC, which places a private-IP network interface directly in their subnet. With private DNS enabled, the consuming application calls the pricing API using its normal hostname, which now silently resolves inside the VPC to that private IP instead of any public address, and the security group on the interface endpoint's network interface controls exactly which of the consumer's resources may even attempt the call. Crucially, the consuming team gets access to that one API and nothing else in the pricing team's VPC: there is no routed network path between the two VPCs at all, which is the isolation property a full peering connection would not have given them.
Trade-offs and pitfalls
The most common mistake is defaulting to an Interface Endpoint for S3 or DynamoDB out of habit, paying the per-Availability-Zone-hour charge for a case where the free Gateway Endpoint does the same job (Interface Endpoints for S3 do exist and are occasionally the right call, for example when you specifically need endpoint access from on-premises over Direct Connect or from a different VPC in a way a Gateway Endpoint cannot reach, but that is the exception, not the default). A second pitfall is enabling an Interface Endpoint but forgetting to enable its private DNS option, which leaves applications still resolving the service's public hostname to a public IP and routing out through the NAT gateway or internet gateway exactly as before, quietly defeating the entire point of adding the endpoint, since nothing is actually broken, it is just not being used. Finally, teams sometimes assume an endpoint alone is a complete security boundary and skip the endpoint policy, relying only on the target service's own resource policy; a scoped endpoint policy is what stops an over-permissioned identity from reaching services or resources it should not, even if it otherwise has valid credentials.
Unlock Full Question Bank
Get access to all 40 Cloud Networking and VPC Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.