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.
Describe operational uses for VPC Flow Logs. Explain how you'd configure destinations (CloudWatch Logs vs S3), sampling vs full logs, retention policies, parsing challenges, and integration with SIEM or analytics pipelines for use cases like security detections and cost analysis.
Sample Answer
Direct answer
Treat Flow Logs as an operational data pipeline you have to design, not a checkbox you enable once: pick a destination that matches how you'll actually query the data, decide up front whether you need every flow or a representative slice, set a retention policy that matches your compliance and cost tolerance, and plan for the parsing effort before the first incident forces you to do it under pressure.
Structured elaboration
Destinations: CloudWatch Logs versus S3. CloudWatch Logs is the right choice when you need near-real-time metric filters and alarms (for example, alerting the moment REJECT records spike on a sensitive subnet), because CloudWatch Logs Insights can query recent data with low latency and integrate directly with CloudWatch Alarms. Amazon S3 (Simple Storage Service) is the right choice for high-volume, long-retention, or batch-analytical use, because it's dramatically cheaper per gigabyte at scale and pairs naturally with Amazon Athena for SQL-style ad hoc querying or with a SIEM (Security Information and Event Management) ingestion pipeline. Many mature setups use both: a short CloudWatch Logs retention window for live alerting, with the same logs (or the S3-destined copy) retained far longer in S3 for forensics and compliance.
Sampling versus full logs. Full logging (every flow, every network interface) gives complete visibility but generates real volume, especially in a busy production VPC (Virtual Private Cloud), translating directly into ingestion and storage cost. A narrower approach, logging REJECT-only traffic, or only specific subnets carrying sensitive workloads, cuts cost significantly while preserving the highest-value signal (most day-to-day debugging and security monitoring cares more about what got blocked than about the sea of normal ACCEPT traffic), at the cost of losing full traffic-volume visibility for cost or capacity-planning use cases that specifically need the ACCEPT records too.
Retention policies. Set retention deliberately at both layers: the CloudWatch Logs group's retention setting (which otherwise defaults to "never expire" and silently grows forever) and the S3 bucket's lifecycle policy (transitioning older data to cheaper storage classes, or expiring it, on a schedule matched to your actual compliance requirement, commonly 90 days to a year for general operational use and longer for regulated environments).
Parsing challenges. The default record format is a whitespace-delimited flat string, not JSON, which means most ingestion pipelines need an explicit parser or a custom log format with fields you've pre-selected; get the field order and format right at flow-log creation time, because you cannot change an existing flow log's format after the fact, only delete it and create a new one, which loses continuity in your historical data.
Integration with SIEM and analytics pipelines. Streaming through Amazon Data Firehose into a SIEM lets security teams correlate network flow data with other signals (authentication logs, application logs) in one place, which is where flow logs earn their keep for detections like lateral movement (an internal host suddenly talking to hosts it's never talked to before) or data exfiltration (an unusual, sustained high-byte-count flow to an external destination). For cost analysis, the same data, queried via Athena against the S3 destination, lets you attribute cross-AZ or NAT gateway data-processing charges to the specific flows generating them, which billing data alone cannot do.
Worked example
A security team wants to detect a specific pattern: an internal host suddenly initiating outbound connections to a large number of distinct external IPs in a short window, a common exfiltration or scanning signature. They configure flow logs on the relevant VPCs to stream to Data Firehose into their SIEM, with a custom format that includes pkt-dstaddr in addition to the version-2 default fields (needed because the destination might be behind a NAT gateway, whose flow log entry shows the NAT's own address in the standard dstaddr field rather than the packet's true destination). The SIEM rule counts distinct dstaddr values per srcaddr per 5-minute window and alerts above a threshold; the same underlying data, retained in S3 for a year under a lifecycle policy, later gets queried through Athena during a retrospective audit to confirm no prior instance of the same pattern had been missed.
Trade-offs and pitfalls
Enabling full logging everywhere without a sampling or scoping decision is the most common way this gets expensive fast, particularly in a high-throughput production VPC. The second common mistake is choosing a destination based on what's easiest to set up rather than how the data will actually be used, landing everything in CloudWatch Logs and only later discovering that months of forensic data are prohibitively costly to store there long-term compared to S3. Finally, remember that a flow log's format is fixed at creation, so retrofitting a needed field (like pkt-dstaddr for NAT gateway visibility) means starting a new flow log going forward, not recovering the field from history you already collected.
Your NAT Gateway costs have grown dramatically due to large volumes of container image pulls and OS updates across many accounts. Propose a combination of architecture and operational changes to reduce NAT and egress costs while maintaining security isolation and reliability for development and production workloads.
Sample Answer
Direct Answer
Stop paying to fetch the same bytes through NAT repeatedly: cache container images close to the workload with a pull-through cache or a regional registry mirror, mirror the OS package repositories the same way, and route whatever still must reach AWS APIs through VPC endpoints instead of NAT, all rolled out as shared infrastructure across accounts rather than as a per-account fix.
Diagnose First, Per Account
Attribute the volume with the same VPC Flow Log approach as any NAT cost investigation, but segmented per account since this is explicitly a many-accounts problem. Container image pulls are typically dominated by a small number of large base images pulled repeatedly, on every pod start, every CI (continuous integration) run, every node bootstrap, rather than by genuinely unique data.
Fixing Container Image Pull Costs
Amazon Elastic Container Registry (ECR) Interface VPC endpoints (for the registry API and the Docker-compatible data endpoint) remove the NAT hop for pulls from ECR, but they are not sufficient by themselves: image layers are actually stored in and served from Amazon S3, so an S3 Gateway endpoint is also required, a gotcha that leaves pulls silently falling back to NAT when teams add only the ECR endpoints.
ECR's pull-through cache feature is the single biggest lever when many accounts are pulling the same public base images repeatedly: configure ECR as a local cache in front of a public registry so the first pull of a given image and tag in the region fetches it once, and every subsequent pull, across every account attached to the shared cache, is served from the regional cache over PrivateLink and S3 rather than re-fetched from the public internet through NAT each time.
For the multi-account structure specifically, centralize the pull-through cache and the shared VPC endpoints in a shared-services or network account, reachable from spoke accounts via Transit Gateway (a central hub connecting many VPCs and accounts without pairing each one individually) or Resource Access Manager (RAM)-shared endpoints, so this is configured and patched once rather than per account.
Fixing OS Update Costs
Route package-manager traffic to a regional mirror where the distribution provides one, or stand up an internal package proxy or mirror refreshed on a schedule, so instances pull updates from inside the region instead of the public internet on every patch cycle. The equivalent for Windows fleets is a local update-management server rather than every instance reaching a public update endpoint directly through NAT.
Security Isolation and Reliability for Dev vs Production
VPC endpoints and a private image cache do not reduce isolation, they remove a public-internet path that existed before, which is a security improvement rather than a trade-off against one. Per-account NAT gateways can stay in place for whatever residual, genuinely external traffic remains, sized down now that the highest-volume, noisiest traffic, images and packages, is gone.
Development and test accounts are usually the highest-volume, lowest-value NAT traffic, a CI pipeline pulling the same base image hundreds of times a day. Route that traffic through the shared cache aggressively, since a cache miss there is cheap to recover from. Production should get its own dedicated cache or registry replica rather than sharing a rate limit or availability fate with a noisy development environment, so a development CI storm cannot affect a production node's ability to pull an image during an incident.
Worked Example
Assume 50 AWS accounts, each running CI that pulls the same 0.5 GB base image an average of 20 times per day, currently all routed through NAT to the public registry:
Total pulls/month=50×20×30=30,000 pulls Total NAT-processed GB/month (no cache)=30,000×0.5 GB=15,000 GB NAT processing cost (no cache)=15,000×$0.045/GB=$675/monthWith a shared ECR pull-through cache across the 50 accounts, the only traffic left touching NAT is the cache's own periodic refresh from the public registry, not 30,000 individual pulls. If the cache refreshes once per day:
Cache-refresh GB/month=1×0.5 GB×30=15 GB NAT processing cost (with cache)=15×$0.045=$0.68/monthThat is roughly a 99% cut in NAT-billed data for this one image alone, since the remaining 29,970 pulls now flow over PrivateLink and S3 at that path's own, much smaller endpoint cost rather than the NAT per-gigabyte charge, and the saving scales with account count because the fix is shared infrastructure rather than a per-account change. As with any cost projection, treat these inputs as illustrative and re-derive the real numbers from each account's own CI logs.
Trade-offs and Pitfalls
A shared pull-through cache becomes a single dependency for every account's CI. If it is rate-limited by the upstream public registry or has an outage, every account's builds can stall at once, which is exactly why production needs its own replica rather than depending on the same instance as development.
Forgetting the S3 Gateway endpoint alongside the ECR interface endpoints is the most common implementation miss: pulls keep falling back to NAT, and the team does not realize the actual image bytes are an S3 fetch, not just an ECR API call.
Centralizing the cache in a shared-services account adds cross-account IAM (Identity and Access Management, the permissions system controlling who and what can access a resource) and networking complexity, resource policies on the registry, shared endpoints, versus the simplicity of every account doing its own thing, but the cost and consistency payoff usually justifies it once there are more than a handful of accounts.
A self-hosted OS package mirror is one more system to patch and secure; only worth running once the NAT savings or reliability benefit clearly outweighs that operational cost.
For a compliance-heavy environment, describe how you would restrict and monitor outbound egress traffic from private subnets, including the use of NAT gateway, centralized proxy, firewall rules, and logging. Explain pros/cons of forcing egress through a single inspection point.
Sample Answer
Direct answer
For a compliance-heavy environment, the requirement is usually not just "block bad outbound traffic" but "prove every outbound connection was inspected and can be reconstructed later," which means forcing all egress from private subnets through one controlled, logged inspection point rather than letting each subnet or account exit independently. The trade-off you're explicitly accepting is a single choke point that adds latency, cost, and a scaling bottleneck, in exchange for the auditability a compliance program actually needs.
Structured elaboration
The building blocks. A NAT (Network Address Translation) gateway still handles the address translation itself, but instead of sitting directly in each workload's own path to the internet, it sits behind (or alongside) a centralized proxy or firewall tier that every subnet's outbound traffic is routed through, typically via a shared inspection VPC (Virtual Private Cloud) reached over a Transit Gateway (TGW). A centralized forward proxy (or a firewall appliance like AWS Network Firewall or a third-party equivalent, fronted by a Gateway Load Balancer for scale) applies domain and IP allowlisting or denylisting, TLS (Transport Layer Security) inspection where policy requires it, and logs every connection attempt, allowed or blocked. Flow logs and, where applicable, proxy access logs are shipped to a retained, tamper-evident log store, since "we had a firewall" is a much weaker compliance answer than "here is the log of every connection this workload made in the last 12 months."
Pros of forcing all egress through one inspection point. A single, well-audited enforcement point is dramatically easier to certify and reason about than dozens of independent NAT gateways each with their own, potentially drifting, rule set; a compliance auditor can review one policy and one log stream rather than reconciling configuration across every account. It also makes detection easier: a single place to watch for anomalous destinations or volumes across the entire estate, rather than needing to aggregate signals from many independent egress points after the fact.
Cons of forcing all egress through one inspection point. Every workload's outbound traffic now takes an extra hop, adding latency that's real even if often small, and concentrating both the traffic volume and the cost (data-processing charges accrue at the centralized NAT/firewall tier, at a scale proportional to the whole estate's egress, not any one workload's). It also creates a single point that must be sized and made highly available correctly, because an outage there doesn't just degrade one workload's egress, it degrades every workload's egress across the estate simultaneously; and it becomes an organizational bottleneck if every new outbound destination a team needs requires a change request against a shared, centrally-owned firewall rule set, which can slow legitimate work if the change process isn't kept fast.
What a compliance program typically requires beyond the mechanism itself. Documented change control on the firewall/proxy rule set (who approved adding a new allowed destination, and why), retained logs meeting the specific regulation's retention window, and periodic access review confirming the rule set still reflects only what's currently needed, since egress rules tend to accumulate permissive exceptions over time if nobody prunes them.
Worked example
A financial services company subject to a regulatory requirement to log and control all outbound network connections routes every workload VPC's 0.0.0.0/0 traffic through a shared inspection VPC via TGW. The inspection VPC runs a proxy that allowlists specific external domains (a payment processor, a small number of SaaS (Software as a Service) vendors, and nothing else by default) and logs every connection attempt with the requesting workload's identity, destination, and outcome. When an application team needs a new external dependency, they submit a change request to add the domain to the allowlist rather than being able to reach arbitrary internet destinations by default; the resulting log, retained for the regulation's required period, becomes the artifact the compliance team hands to an auditor as evidence that outbound connectivity is both controlled and observable.
Trade-offs and pitfalls
The single inspection point is the correct design for the stated compliance goal, but treating it as a "set it once" control invites rule-set rot: allowlist entries added under time pressure during an incident and never revisited accumulate into a broad, effectively-uncontrolled allowlist that technically satisfies "we have an egress control" while defeating its purpose. Sizing the shared inspection tier for peak aggregate load across the whole estate, not just its current load, matters too: because every workload depends on the same choke point, under-provisioning it turns a routine traffic spike in one team's workload into a shared outage for every team behind it.
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 how private hosted zones (Route 53 Private Hosted Zones, or the Azure/GCP private DNS zone equivalent) enable split-horizon DNS for hybrid applications. Describe cross-account private hosted zone sharing, conditional forwarding to on-prem DNS via resolver rules, resolving internal names from serverless and container compute (e.g. Lambda/EKS), and common pitfalls such as overlapping domain names.
Sample Answer
Direct answer
A private hosted zone (Route 53's term; Azure and Google Cloud Platform (GCP) have their own private DNS zone equivalents) is a DNS zone that only resolves inside the VPCs (Virtual Private Clouds) explicitly associated with it. Cross-account sharing means associating that zone with a VPC that lives in a different AWS account than the one that owns the zone, which requires an explicit two-step authorization handshake rather than a simple share, and gets combined with conditional forwarding to on-premises DNS for the pieces of the namespace that live outside AWS entirely.
Structured elaboration
Cross-account sharing mechanics and IAM (Identity and Access Management) prerequisites. The owning account calls an authorization API (create-vpc-association-authorization) naming the specific VPC ID in the other account that should be allowed to associate. Only then can the consuming account call associate-vpc-with-hosted-zone for that VPC; without the authorization step first, the association request is simply rejected. This is deliberately more friction than AWS Resource Access Manager (RAM) sharing for most resources, because a hosted zone association silently changes what every workload in the target VPC resolves for that namespace, which is a meaningful trust boundary to cross.
Conditional forwarding to on-premises DNS. For portions of the namespace that live on-premises rather than in a private hosted zone, the same Resolver rules and inbound/outbound endpoint pattern used for general split-horizon DNS applies here too, layered on top of the cross-account private hosted zone: a Resolver rule forwarding a specific suffix to on-premises can itself be shared to other accounts via RAM and associated with their VPCs, so a consuming account's workloads get both "look in the shared private hosted zone" and "forward this other suffix on-premises" without duplicating either configuration per account.
Resolving from serverless and container compute. AWS Lambda functions only see private hosted zone records if the function itself is configured to run inside the VPC (attached via an ENI, or elastic network interface); a Lambda function running outside any VPC uses public DNS resolution and simply cannot see private zone records, regardless of how the zone is shared. Amazon EKS (Elastic Kubernetes Service) pods resolve names through CoreDNS, which by default forwards non-cluster-local queries to the VPC's own DNS resolver (the .2 address in the VPC's CIDR range), which does see any private hosted zones associated with that VPC; the failure mode to watch for is a customized CoreDNS forward plugin configuration that points queries somewhere other than the VPC resolver, which silently breaks resolution of the shared zone for every pod even though the zone association itself is correct.
DNS firewalling. Route 53 Resolver DNS Firewall lets you attach a domain-list-based policy to a VPC's resolver, blocking or alerting on queries to known-malicious domains or enforcing an allowlist for outbound DNS from sensitive subnets. It operates independently of the private-hosted-zone sharing itself, but belongs in the same design conversation because a workload that can resolve internal names via a shared zone can usually also resolve external names, and a compromised workload using DNS for command-and-control or data exfiltration is a real risk that private-hosted-zone sharing alone does nothing to address.
Naming conventions for ephemeral service discovery. A static private hosted zone record works well for long-lived infrastructure (a database endpoint, a load balancer), but doesn't fit workloads that scale up and down continuously. A consistent naming hierarchy, something like <service>.<environment>.internal, gives humans and automation a predictable pattern, but the actual resolution for short-lived compute (Lambda invocations, EKS pods, ECS (Elastic Container Service) tasks) is better served by a service-discovery layer built for churn, such as AWS Cloud Map or Kubernetes' own Service DNS backed by short TTLs (time-to-live values), rather than trying to keep a private hosted zone record manually in sync with instances that come and go every few minutes.
flowchart LR
Owner[Owning account: hosted zone] -->|create-vpc-association-authorization| Auth[Authorization]
Consumer[Consumer account VPC] -->|associate-vpc-with-hosted-zone| Owner
Consumer -->|Lambda ENI in VPC, or EKS CoreDNS forward| Resolve[Resolves shared zone via VPC .2 resolver]
Worked example
A platform team owns internal.corp.com in a central networking account and needs three application accounts to resolve names in it, plus needs one legacy suffix, legacy.onprem.corp.com, forwarded to an on-premises DNS server. For each application account's VPC, the networking account first calls create-vpc-association-authorization naming that VPC's ID, then each application account calls associate-vpc-with-hosted-zone to complete it. A Resolver rule forwarding legacy.onprem.corp.com to the on-premises DNS server's IPs is created once in the networking account and shared to all three application accounts via RAM, then associated with each of their VPCs, so none of the three teams has to configure their own forwarding rule. An EKS cluster in one application account resolves db.internal.corp.com correctly through its CoreDNS forward plugin's default configuration; a Lambda function in the same account that isn't attached to the VPC cannot resolve the same name and needs to be reconfigured with VPC access before it will work.
Trade-offs and pitfalls
Overlapping domain names are the single most common failure here: if two accounts each independently create a private hosted zone for the same suffix and both get associated with the same VPC, which one answers a given query becomes effectively undefined, and this is exactly the kind of problem that only shows up once two previously-independent teams' infrastructure gets connected. A second pitfall is forgetting the authorization step entirely and assuming a hosted zone can simply be "shared" the way an S3 bucket or a subnet can; the two-call handshake is intentional friction, not a bug, precisely because a zone association is a strong trust grant. Finally, don't assume DNS Firewall and private-hosted-zone sharing solve the same problem: sharing controls what internal names resolve to, while DNS Firewall controls what external names a workload is allowed to look up at all, and a mature hybrid DNS design uses both.
Unlock Full Question Bank
Get access to all 49 Cloud Networking and VPC Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.