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.
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.
Explain how TLS (encryption in transit) is typically implemented in cloud architectures. Discuss end-to-end TLS versus terminating TLS at a load balancer, certificate management (rotation and trust), SNI considerations, and where you might decrypt traffic for inspection while minimizing the attack surface.
Sample Answer
Direct answer
Transport Layer Security (TLS), the protocol that encrypts data in transit, is almost never implemented as one unbroken encrypted tunnel from the end user's browser all the way to the database; it's implemented as a chain of TLS connections with a deliberate choice, at each hop, of where to terminate (decrypt) and where to keep encrypting further. The two poles are end-to-end TLS, where the same encrypted session runs unbroken from client to the final backend, and termination at a load balancer, where the load balancer decrypts, inspects or routes based on the plaintext, and re-encrypts (or doesn't) before forwarding.
Structured elaboration
- End-to-end versus termination at a load balancer. Terminating at a load balancer, most commonly an Application Load Balancer (ALB), lets the load balancer do content-based routing (path or host header rules), attach a Web Application Firewall (WAF) that can only inspect plaintext, and centralizes certificate management to one place. The cost is that the plaintext exists, briefly, inside your infrastructure at that hop. End-to-end TLS (or "TLS passthrough," where a Network Load Balancer forwards the encrypted bytes at Layer 4 without ever decrypting them) means nothing in between the client and the final server ever sees plaintext, which matters for payment card data or other regulated traffic, at the cost of losing content-based routing and WAF inspection at that layer.
- Certificate management: rotation and trust. Certificates expire and must be rotated before they do, or every client sees a trust failure. Managed services like AWS Certificate Manager (ACM) or a cloud provider's equivalent handle issuance and automatic renewal for load-balancer-terminated certificates; for services further inside the network (a database, an internal microservice) a private certificate authority combined with short-lived, automatically-rotated certificates (via a service mesh or a tool like HashiCorp Vault) avoids the classic failure mode of a manually-issued internal certificate nobody remembers to renew.
- Server Name Indication (SNI). The TLS handshake needs to know which certificate to present before the HTTP layer (and its Host header) is even visible, because the handshake happens first. SNI is the extension that lets the client state, in the clear, which hostname it's connecting to during the handshake, so a single IP address and load balancer can serve many different certificates for many different domains rather than requiring one IP per certificate.
- Where to decrypt for inspection, while minimizing attack surface. If you need to inspect traffic (a WAF, an intrusion-detection appliance, deep packet inspection for compliance), decrypt at the smallest number of points possible and as close to the edge as the inspection requirement allows, then re-encrypt immediately for the next hop ("TLS bridging"). Decrypting once at the edge load balancer and re-encrypting over a private, VPC-internal (Virtual Private Cloud) hop to the backend is a common middle ground: the plaintext only exists briefly, inside infrastructure you control, and never crosses a network boundary you don't own.
Worked example
An e-commerce site puts a CDN (content delivery network) and an ALB in front of its application. For general browsing traffic, TLS terminates at the ALB using an ACM-issued certificate that renews automatically before its expiry, and the ALB re-encrypts over a private VPC hop to the application servers, so the WAF sitting in front of the ALB can inspect requests for SQL injection and other attack patterns in plaintext. For the checkout and payment page specifically, the same site instead routes through a Network Load Balancer in TLS-passthrough mode straight to a PCI-scoped (Payment Card Industry) backend, so no intermediate component, including the company's own WAF, ever sees the decrypted card data, trading away WAF inspection on that one path in exchange for a materially smaller compliance and breach-exposure surface.
Trade-offs and pitfalls
Terminating everywhere for convenience (every hop decrypts and re-encrypts "just in case") multiplies the number of places a certificate can expire unnoticed and the number of places plaintext technically exists, without a corresponding security benefit, since most internal hops don't need content-based inspection. The opposite mistake, insisting on end-to-end TLS everywhere including for traffic that genuinely needs edge inspection, gives up the WAF's ability to see and block malicious payloads. The practical answer is almost always a mix: terminate where you need to inspect or route, pass through where the sensitivity of the payload outweighs the value of inspection, and automate rotation everywhere so trust never depends on a human remembering an expiry date.
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.
Describe the public/private subnet pattern for a multi-tier application (web, application, database) in a VPC. For each tier specify whether it belongs in a public or private subnet, where NAT/IGW is required, typical routing and ACL/security-group configuration, and how this pattern improves security and manageability.
Sample Answer
Direct answer
The public/private subnet split for a multi-tier app puts only the resources that must accept unsolicited inbound internet traffic (the web tier) in a public subnet, and everything else (application, database) in private subnets that are unreachable from the internet by construction. Security is improved because the blast radius (how far an attacker who breaches one tier can then reach) of an internet-facing compromise stops at the first tier: even with a perfect security-group rule set, only the route table decides whether an internet path exists at all, and the private tiers simply have none. Manageability improves because each tier gets its own routing and firewall boundary, so a change to one tier's exposure cannot silently affect another.
Structured elaboration
Per-tier breakdown:
| Tier | Subnet type | Internet Gateway (IGW) route needed? | NAT needed? | Typical inbound security-group rule | Typical NACL posture |
|---|---|---|---|---|---|
| Web (or a load balancer in front of it) | Public | Yes, 0.0.0.0/0 -> IGW | No (it already has a public path) | Allow 443/80 from 0.0.0.0/0 | Default allow, tightened only if the NACL is doing broad IP blocking |
| Application | Private | No | Yes, for outbound calls to third-party APIs or OS updates | Allow the app port from the web tier's security group only | Allow ephemeral return traffic (1024-65535) plus the specific inbound app port from the web subnet's CIDR |
| Database | Private | No | Usually no route at all; databases rarely need outbound internet | Allow the database port (e.g. 5432 for PostgreSQL) from the app tier's security group only | Allow ephemeral return traffic plus the database port from the app subnet's CIDR only |
Route tables, concretely. Each subnet associates with exactly one route table (though one route table can serve several subnets). The public subnet's table has a route for the VPC's own CIDR (added automatically, cannot be deleted) plus 0.0.0.0/0 -> igw-xxxx. Each private subnet's table has the local VPC route plus 0.0.0.0/0 -> nat-xxxx if it needs outbound internet, pointed at the NAT gateway that lives in a public subnet (a NAT gateway needs a public subnet and its own Elastic IP to reach the internet on behalf of everyone routing through it).
Security group vs NACL in this pattern, briefly (the full comparison is its own topic, but the shape that matters here): security groups are stateful and attached to the instance or its network interface, so you write one inbound rule and return traffic is automatically allowed back out. NACLs are stateless and attached to the subnet, evaluated before the security group, so you must explicitly allow both the inbound request and the ephemeral-port outbound return traffic, or connections will hang. Most teams run security groups as the primary control and leave NACLs at their permissive default unless they have a specific reason (blocking a known-bad IP range at the subnet boundary, or enforcing a hard compliance boundary that must hold even if every security group is misconfigured).
Worked example
A two-Availability-Zone (AZ) checklist for a 3-tier app, since anything less than two AZs is not actually highly available:
- One public subnet per AZ (e.g.
10.0.0.0/24in AZ-a,10.0.1.0/24in AZ-b) holding the load balancer and, if used, a bastion or jump host. - One private application subnet per AZ (
10.0.10.0/24,10.0.11.0/24). - One private database subnet per AZ (
10.0.20.0/24,10.0.21.0/24), often placed in a dedicated "DB subnet group" so the managed database service only ever launches replicas into subnets you intended for it. - One NAT gateway per AZ (not one shared NAT gateway for the whole VPC): if the only NAT gateway lives in AZ-a and AZ-a fails, AZ-b's private resources lose outbound internet access even though their own AZ is healthy. Each AZ's private route tables point only at their own AZ's NAT gateway.
- Security groups chained tier to tier as in the table above: load-balancer security group accepts the internet, web/app security group accepts only the load-balancer's security group, database security group accepts only the app security group.
Secure administrator access, without a public jump box. A classic weak point in this pattern is putting a bastion host in the public subnet with SSH open to a corporate IP range, which is one more standing internet-facing attack surface to patch and monitor. The current recommended pattern (AWS Systems Manager Session Manager, or Azure Bastion / GCP Identity-Aware Proxy on the other clouds) removes that: the administrator authenticates through the cloud provider's identity and access management (IAM), and the agent already running on the instance opens an outbound-only connection to the Session Manager service, so no inbound port needs to be open on the instance at all, not even from a "trusted" IP range. That also gets you centralized, immutable session logging for free, which a bare SSH bastion does not.
Trade-offs and pitfalls
The single most common mistake in this pattern is a shared, single-AZ NAT gateway "to save cost," which quietly turns a multi-AZ design into one with a single point of failure for all outbound internet access; it also concentrates all cross-AZ private-subnet egress traffic onto one gateway and one AZ's data-transfer path. A second pitfall is treating "private subnet" as sufficient security on its own and skipping the security-group chaining: a private subnet stops internet ingress, but without tier-to-tier security group rules, anything else already inside the VPC (a compromised instance in the same VPC, or an overly broad peering connection) could still reach the database directly. Finally, teams sometimes forget that NACLs are stateless when they add a "temporary" outbound-only NACL rule and wonder why responses never arrive: without the matching ephemeral-port inbound rule, the return leg of the connection is dropped at the subnet boundary even though the security group would have allowed it.
Compare and contrast instance-level security groups and subnet-level Network ACLs (NACLs) in cloud providers. Explain evaluation order, stateful vs stateless behavior, default rules and limits, and give examples of when to use each for a multi-tier application. Include an example where both are required and explain why.
Sample Answer
Direct answer
Security groups operate at the instance level (attached to the network interface) and are stateful: allow an inbound request and the matching response is automatically permitted back out, with no separate outbound rule needed. Network ACLs (NACLs) operate at the subnet level and are stateless: you must explicitly allow both directions of every conversation, including the ephemeral high-numbered ports used for return traffic, or replies get silently dropped. In a well-designed multi-tier application both layers are typically in play at once, security groups doing the fine-grained, per-tier access control and NACLs providing a coarser, second layer that holds even if a security group is ever misconfigured.
Structured elaboration
| Dimension | Security Group | Network ACL |
|---|---|---|
| Scope | Attached to individual network interfaces (effectively, per instance) | Attached to a subnet; applies to every resource in it |
| State | Stateful: return traffic for an allowed connection is automatically permitted | Stateless: inbound and outbound rules are evaluated independently; return traffic needs its own explicit rule |
| Rule evaluation | All rules are evaluated; there is no "first match wins" concept, only allow rules exist (nothing is explicitly denied, traffic simply isn't allowed if no rule matches) | Rules are evaluated in numbered order, lowest number first; the first rule that matches wins, and an explicit Deny is possible |
| Default behavior | A default security group denies all inbound and allows all outbound until you add rules | A default NACL allows all inbound and outbound traffic; a custom NACL you create denies everything until you add rules |
| Typical limits | Commonly around 60 rules per direction by default (adjustable), and a handful of security groups per network interface | Commonly around 20 rules per direction by default (adjustable up to around 40 per direction), evaluated in strict numeric order |
| Best used for | Fine-grained, per-tier or per-role access control ("only the web tier's security group may reach the app tier's security group on this port") | A coarse, subnet-wide boundary: blocking a known-bad IP range outright, or enforcing a hard compliance requirement that must hold regardless of what any individual security group says |
Why stateful vs stateless matters in practice, concretely. A client outside the VPC opens a connection to a web server: the request arrives from an ephemeral, randomly assigned high-numbered source port on the client side, destined for port 443 on the server, and the server's reply goes from port 443 back to that same ephemeral port on the client. A security group only needs one inbound rule (allow port 443 from the client's range) because it tracks the connection's state and automatically permits the matching reply out, no matter what port the reply uses. A NACL has no such memory: the inbound rule allowing port 443 says nothing about the outbound reply, so the NACL also needs an explicit outbound rule allowing traffic to the entire ephemeral port range (typically 1024 to 65535) back to the client, or every reply will be silently dropped at the subnet boundary even though the security group and the application are both configured correctly. This ephemeral-port gap is the single most common NACL misconfiguration: everything looks right, connections still fail, and the cause is invisible unless you specifically know to check for the missing return-traffic rule.
When to use each for a multi-tier application. Security groups do essentially all of the meaningful access control day to day: web tier's security group allows inbound 443 from the internet, application tier's security group allows inbound only from the web tier's security group, database tier's security group allows inbound only from the application tier's security group. NACLs are usually left at a permissive default in this pattern, and are reached for deliberately, not by default, when you need a control that survives a security-group mistake: for example, a subnet-wide rule blocking a specific IP range known to be malicious regardless of which instance or security group it targets, or a hard compliance boundary (say, "the database subnet must never accept inbound traffic from outside the VPC's own CIDR (its assigned IP address range, e.g. 10.0.0.0/16), full stop") that you want enforced even if someone someday attaches an overly permissive security group to something in that subnet by mistake.
Worked example
A case where both are genuinely required, and why. A financial services company runs its database tier in a private subnet and, separately from its normal tier-to-tier security groups, has a compliance requirement that the database subnet must categorically reject any traffic from outside the VPC's address range, independent of any application-level security group configuration, because a security group misconfiguration must never be sufficient on its own to expose the database externally. They implement this as a custom NACL on the database subnet with an explicit rule denying inbound traffic from any source outside the VPC's CIDR, positioned before (a lower rule number than) a broader allow rule for the VPC's own range, plus the normal outbound ephemeral-port allow rule for return traffic to the application tier. Independently, the database's security group allows inbound only from the application tier's specific security group on the database port, which is the layer actually doing meaningful per-tier access control day to day. The two layers answer different questions: the security group asks "is this specific source explicitly permitted," while the NACL asks "does this traffic even belong in this subnet at all," and having both means a mistake in one (an overly broad security-group rule accidentally added during a migration, for instance) does not by itself defeat the other.
Trade-offs and pitfalls
The most common mistake is trying to use NACLs for fine-grained, frequently changing access control, such as per-application-team rules: because NACL rules are evaluated in strict numeric order and typically capped at a modest number per direction, this quickly becomes an unmanageable, easy-to-misorder rule list, which is precisely the job security groups are built for instead. The second most common mistake, already covered above, is forgetting the ephemeral-port outbound rule when customizing a NACL, which silently breaks return traffic for entirely correctly configured applications and security groups. Finally, teams sometimes treat NACLs as unnecessary given that security groups exist, missing that the value of a NACL is specifically that it is a separate, subnet-wide layer that does not depend on any individual resource's security-group configuration being correct, which is exactly the property that makes it worth the extra maintenance for a genuinely hard boundary like the database example above.
Unlock Full Question Bank
Get access to all 7 Cloud Networking and VPC Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.