Prev Next

Cloud / Amazon VPC (Virtual Private Cloud) Interview questions

Last updated

1. What is Amazon VPC? 2. What are the main components of an Amazon VPC? 3. What is a subnet in Amazon VPC? 4. What are the types of subnets you can create in a VPC? 5. What is an Internet Gateway? 6. What is a NAT Gateway? 7. What is a route table in Amazon VPC? 8. What are Security Groups? 9. What are Network ACLs (NACLs)? 10. What is the default VPC? 11. What is CIDR notation used for in VPC design? 12. What is VPC Peering? 13. What is a VPC endpoint? 14. What are the types of VPC endpoints? 15. What is an Elastic IP address? 16. Define VPC Flow Logs? 17. What is AWS Transit Gateway? 18. List the default VPC limits per AWS Region? 19. How does traffic flow from the internet to an EC2 instance in a public subnet? 20. How is a NAT Gateway different from an Internet Gateway? 21. What is the difference between Security Groups and Network ACLs? 22. What is the difference between a NAT Gateway and a NAT instance? 23. What is the difference between an Interface Endpoint and a Gateway Endpoint? 24. How does route table association determine whether a subnet is public or private? 25. Why do we use VPC Peering instead of public internet for cross-VPC communication? 26. When should you choose Transit Gateway over VPC Peering? 27. What happens when two peered VPCs have overlapping CIDR blocks? 28. How is Security Group evaluation different from NACL evaluation for return traffic? 29. Why should you use multiple Availability Zones when designing VPC subnets? 30. How do you troubleshoot an EC2 instance that cannot reach the internet? 31. What is the difference between a VPC and a subnet in terms of scope? 32. How does AWS Site-to-Site VPN connect an on-premises network to a VPC? 33. Why doesn't a private subnet have direct outbound internet access by default? 34. What is the difference between an Elastic IP and a standard public IP? 35. How do you optimize costs when using NAT Gateways in a multi-AZ VPC? 36. What is the difference between VPC Flow Logs and CloudTrail? 37. When should you use a Bastion Host versus AWS Systems Manager Session Manager? 38. How does DNS resolution work inside a VPC? 39. Explain the execution flow of a packet from a private EC2 instance to an S3 bucket using a Gateway Endpoint? 40. Explain the internal working of Security Group connection tracking? 41. How can you optimize a VPC design for a multi-account AWS Organization? 42. Explain the lifecycle of a VPC Peering connection request? 43. How do you troubleshoot asymmetric routing issues in a VPC with multiple route tables? 44. Explain the internal working of AWS Transit Gateway route propagation? 45. What is the difference between Transit Gateway and VPC Peering at scale for a hub-and-spoke architecture? 46. How does AWS PrivateLink differ from a standard VPC Peering connection? 47. Explain the execution flow of traffic through a VPC with a centralized inspection VPC architecture? 48. How can you optimize VPC Flow Logs for cost and security monitoring at scale? 49. Explain the internal working of DNS resolution for a VPC endpoint with Private DNS enabled? 50. How do you troubleshoot intermittent connectivity between two peered VPCs in different AWS Regions?

1. What is Amazon VPC?

Amazon VPC (Virtual Private Cloud) is a logically isolated network you provision inside AWS, where you control your own IP address range, subnets, route tables, and gateways.

It behaves like a traditional data center network but runs on AWS's shared infrastructure - resources you launch inside it, such as EC2 instances or RDS databases, only talk to each other or the outside world the way you've configured routing and security to allow.

Every AWS account gets a default VPC in each Region automatically, but most production workloads use a custom VPC so the CIDR range, subnet layout, and internet exposure match the application's actual needs.

Take quiz
Amazon VPC gives you control over:
The physical servers underneath your account
Your own IP address range, subnets, and routing
The billing region for your account
Other AWS customers' network traffic
How many VPCs does a new AWS account start with per Region?
Zero, until one is created
Five default VPCs
One default VPC, created automatically
As many as there are Availability Zones

2. What are the main components of an Amazon VPC?

A VPC is built from a handful of pieces that work together: the VPC itself defines the overall CIDR block, and subnets carve that range into smaller pieces tied to specific Availability Zones.

  1. Route tables decide where traffic from each subnet is allowed to go.
  2. Internet Gateway (IGW) gives resources with public IPs a path to and from the internet.
  3. NAT Gateway lets private-subnet resources reach the internet outbound without being reachable from it.
  4. Security Groups and Network ACLs filter traffic at the instance and subnet level.
  5. VPC endpoints, peering connections, and Transit Gateway attachments extend connectivity to AWS services, other VPCs, or on-premises networks.

Not every VPC needs all of these - a small isolated dev VPC might only have subnets, a route table, and Security Groups.

Take quiz
Which component decides where traffic from a subnet is permitted to go?
VPC Flow Log
Route table
Security Group
Elastic IP
Which component lets a private-subnet instance make outbound internet calls without being directly reachable from the internet?
Internet Gateway
VPC Peering
NAT Gateway
Network ACL

3. What is a subnet in Amazon VPC?

A subnet is a segment of a VPC's IP address range that you place inside a single Availability Zone - it can't span multiple AZs.

Each subnet gets its own smaller CIDR block carved out of the VPC's larger range, and its own route table association, which is what actually determines whether the subnet behaves as public or private.

AWS reserves five IP addresses in every subnet (the network address, the VPC router, DNS, a future-use address, and the broadcast address), so a /24 subnet with 256 addresses only has 251 usable for your resources.

Spreading workloads across subnets in multiple AZs is the standard way to build fault tolerance into a VPC design.

Take quiz
A single subnet can span:
Multiple Availability Zones for redundancy
An entire AWS Region
Exactly one Availability Zone
Multiple VPCs at once
In a /24 subnet, how many IP addresses does AWS reserve and make unavailable to your resources?
Five
Twenty
Two
None, all 256 are usable

4. What are the types of subnets you can create in a VPC?

A VPC subnet is either public or private, and the label comes entirely from its route table, not from any special subnet setting.

A subnet is public when its route table has a route sending 0.0.0.0/0 traffic to an Internet Gateway, and its instances have public or Elastic IPs to actually use that path.

A subnet is private when it has no route to an Internet Gateway - it may still reach the internet outbound through a NAT Gateway in a public subnet, which counts as private since nothing can initiate a connection into it from outside.

A third variant, sometimes called an isolated subnet, has no route to the internet at all, not even through NAT, and typically only reaches other resources inside the VPC or through VPC endpoints.

Take quiz
What actually determines whether a subnet is public or private?
The Availability Zone it's placed in
The subnet's route table and its route to an Internet Gateway
The subnet's CIDR block size
A checkbox set when the subnet is created
An isolated subnet is best described as one that:
Routes outbound traffic through a NAT Gateway only
Can only be used for database engines
Has no route to the internet at all, even via NAT
Has a direct route to an Internet Gateway

5. What is an Internet Gateway?

An Internet Gateway (IGW) is the VPC component that lets resources with a public IP address send and receive traffic directly to and from the internet.

It's horizontally scaled and highly available by design - there's nothing to size or patch - and exactly one IGW can be attached to a VPC at a time.

Attaching an IGW alone doesn't make anything public; a subnet's route table also needs a 0.0.0.0/0 route pointing at the IGW, and the instance itself needs a public or Elastic IP, before traffic can actually flow.

The IGW also performs the 1:1 NAT translation between an instance's private IP and its public or Elastic IP for internet-bound traffic.

Take quiz
How many Internet Gateways can be attached to a single VPC at one time?
Up to two, one per AZ
Zero, IGWs attach to subnets, not VPCs
Exactly one
As many as there are subnets
Besides attaching an IGW, what else is required before an instance can actually reach the internet through it?
Nothing else is needed
A VPC endpoint policy
A Transit Gateway attachment
A route to the IGW plus a public or Elastic IP on the instance

6. What is a NAT Gateway?

A NAT Gateway is a managed AWS resource that lets instances in a private subnet initiate outbound connections to the internet or other AWS services, while blocking unsolicited inbound connections from reaching them.

You deploy it inside a public subnet, attach an Elastic IP to it, and then point the private subnet's route table at the NAT Gateway for its 0.0.0.0/0 route.

AWS manages its availability, patching, and bandwidth scaling automatically, up to 100 Gbps, but each NAT Gateway lives in a single Availability Zone, so a multi-AZ design typically deploys one NAT Gateway per AZ to avoid a cross-AZ single point of failure.

You're billed hourly for the NAT Gateway plus a per-GB data processing charge, which is a common source of unexpected VPC cost.

Take quiz
A NAT Gateway is deployed in:
A public subnet
An isolated subnet
A private subnet
The default VPC only
What is a common, often underestimated cost driver of NAT Gateways?
The Elastic IP itself, which is very expensive
NAT Gateways are always free within a Region
A one-time setup fee
The per-GB data processing charge on top of the hourly rate

7. What is a route table in Amazon VPC?

A route table is a set of rules, called routes, that determine where network traffic from a subnet is directed based on its destination IP range.

Every VPC has a main route table by default, and any subnet not explicitly associated with a custom route table uses it; you can also create custom route tables and associate specific subnets with them.

Each route pairs a destination CIDR with a target, for example 10.0.0.0/16 -> local for traffic staying inside the VPC, or 0.0.0.0/0 -> igw-id for internet-bound traffic.

When multiple routes could match a destination, AWS always uses the most specific (longest-prefix) match, not the order the routes were added in.

Take quiz
When two routes in a table could both match a packet's destination, AWS picks the route by:
A random selection each time
Alphabetical order of the target
The most specific, longest-prefix match
Whichever route was created first
A subnet with no explicit route table association uses:
The VPC's main route table
The route table of the nearest subnet
A route table copied from the default VPC
No routing at all

8. What are Security Groups?

A Security Group is a virtual, stateful firewall attached at the network interface (ENI) level, controlling what traffic is allowed in and out of the resources using it, most commonly EC2 instances.

Security Groups only support allow rules - there's no explicit deny - so anything not permitted is implicitly blocked.

Because they're stateful, a response to an allowed inbound request is automatically permitted back out, and vice versa, without needing a matching outbound rule.

An instance can belong to multiple Security Groups at once, and the effective rule set is the union of all of them; rules can also reference other Security Groups as the source or destination instead of a raw CIDR block, which is handy for tiered application designs.

Take quiz
Security Groups operate at which level?
The network interface (ENI) level
The AWS Region level
The entire VPC as a single unit
The subnet level
Because Security Groups are stateful, what happens to the response of an allowed inbound request?
It must have a matching explicit outbound allow rule
It's dropped by default
It's automatically allowed back out with no outbound rule needed
It's blocked unless a NACL allows it

9. What are Network ACLs (NACLs)?

A Network ACL is a stateless firewall that operates at the subnet boundary, evaluating every packet entering or leaving any subnet it's associated with.

Unlike Security Groups, NACLs support both allow and explicit deny rules, and they're evaluated in numbered order from lowest to highest, stopping at the first rule that matches.

Because NACLs are stateless, return traffic isn't automatically permitted - if you allow inbound traffic on an ephemeral port range, you also need a matching outbound rule, or replies get silently dropped.

Every VPC comes with a default NACL that allows all traffic; a custom NACL, by contrast, denies everything until you add explicit allow rules, so it's easy to accidentally break connectivity when locking one down.

Take quiz
NACL rules are evaluated:
All at once, with the most permissive rule winning
In reverse alphabetical order
Randomly for load distribution
In numbered order, stopping at the first match
Because NACLs are stateless, what must you remember to configure?
Nothing extra, they behave just like Security Groups
A separate NACL for every EC2 instance
A default deny rule, since none exists
Matching outbound rules for return traffic, since it isn't auto-permitted

10. What is the default VPC?

The default VPC is a pre-configured VPC that AWS automatically creates in every Region of a new account, sized as a 172.31.0.0/16 CIDR block.

It ships with a default subnet in each Availability Zone of the Region (typically a /20 per AZ), an Internet Gateway already attached, and a main route table sending 0.0.0.0/0 to that gateway, so instances launched into it get public IPs and internet access with zero networking setup.

That convenience is exactly why production environments usually avoid it: everything in the default VPC is internet-facing by default, which isn't the isolation model most real workloads want.

You can delete the default VPC and recreate one later if needed, but it must be empty of resources like ENIs first.

Take quiz
What CIDR block does AWS assign to the default VPC?
10.0.0.0/16
100.64.0.0/16
172.31.0.0/16
192.168.0.0/16
Why do production environments typically avoid using the default VPC as-is?
Its default subnets are internet-facing by default, which is often more open than desired
It only exists in the us-east-1 Region
It cannot support EC2 instances
It has no Internet Gateway attached

11. What is CIDR notation used for in VPC design?

CIDR (Classless Inter-Domain Routing) notation expresses an IP range as a base address plus a prefix length, like 10.0.0.0/16, where the prefix length tells you how many bits are fixed for the network portion.

In VPC design, the CIDR block you choose for the VPC sets the total address space available, and each subnet then gets a smaller CIDR carved from that range - a /16 gives 65,536 addresses, while a /24 gives 256.

AWS requires a VPC's CIDR block to be between /16 and /28, and subnet CIDRs must fit entirely within the VPC's range without overlapping other subnets.

Planning CIDR ranges carefully up front matters because it directly determines whether you can later peer VPCs without an overlap conflict, or attach them to the same Transit Gateway.

Take quiz
What is the smallest (largest prefix number) CIDR block size AWS allows for a VPC?
/28
/32
/16
/24
Why does careful CIDR planning matter beyond just having enough addresses?
It controls which AMIs can be launched
Overlapping CIDR ranges block later VPC peering or shared Transit Gateway attachments
It changes the hourly cost of the VPC
It determines the AWS Region the VPC runs in

12. What is VPC Peering?

VPC Peering is a direct, private networking connection between two VPCs that lets resources in either one communicate using private IP addresses, as if they were on the same network.

Traffic between peered VPCs never touches the public internet, and it can be set up between VPCs in the same account, different accounts, or even different Regions.

A peering connection is not transitive - if VPC A is peered with VPC B, and B is peered with C, A cannot reach C through B unless a separate direct peering connection is created between A and C.

Setup requires the owner of the requester VPC to send a request, and the owner of the accepter VPC to accept it, followed by route table updates on both sides pointing at the peering connection.

Take quiz
VPC Peering connections carry traffic:
Only within the same Availability Zone
Over AWS's private network, never touching the public internet
Over the public internet
Only between accounts in the same AWS Organization
If VPC A is peered with B, and B is peered with C, can A reach C through B?
Only if Transit Gateway is also attached
Only if all three VPCs are in the same Region
No, peering is not transitive - A needs a direct connection to C
Yes, peering is transitive by default

13. What is a VPC endpoint?

A VPC endpoint lets resources inside a VPC connect privately to supported AWS services, or to services published by other accounts, without routing traffic through an Internet Gateway or NAT Gateway.

Traffic to the endpoint stays entirely on the AWS network backbone rather than crossing the public internet, which improves both security posture and, in many cases, latency.

Endpoints come in two flavors: Gateway endpoints, which work by adding a route table entry, and Interface endpoints, which place an Elastic Network Interface with a private IP directly inside your subnet.

Using an endpoint means a private subnet with no NAT Gateway at all can still reach services like S3 or DynamoDB.

Take quiz
The main benefit of a VPC endpoint is that traffic to the AWS service:
Stays on AWS's private network instead of going over the public internet
Is automatically encrypted with a customer KMS key
Bypasses all IAM permission checks
Is routed through a NAT Gateway for extra security
How does an Interface endpoint technically appear inside your subnet?
As a second Internet Gateway
As an Elastic Network Interface with a private IP
As a new Availability Zone
As a new route table entry only

14. What are the types of VPC endpoints?

AWS supports two categories of VPC endpoint, and the difference is mostly in how they're implemented and which services they support.

Gateway Endpoint Interface Endpoint
Implemented as a route table target, no ENI created. Implemented as an ENI with a private IP in your subnet.
Only supports S3 and DynamoDB. Supports most other AWS services and AWS PrivateLink-published services.
Free of charge to use. Billed hourly plus per-GB data processed.
Reachable only from within the associated VPC. Reachable from on-premises via Direct Connect or VPN, since it has a routable IP.

A single VPC can use both types side by side - Gateway endpoints for S3 and DynamoDB, Interface endpoints for everything else that needs private connectivity.

Take quiz
Which AWS services can a Gateway endpoint connect to?
Only S3 and DynamoDB
Only EC2 and Lambda
Any AWS service
Only services published via PrivateLink
Which endpoint type is billed hourly plus per-GB processed?
Both are always free
Interface endpoint
Gateway endpoint
Neither, both are billed per-request only

15. What is an Elastic IP address?

An Elastic IP (EIP) is a static, public IPv4 address that you allocate to your AWS account and can associate with an EC2 instance, NAT Gateway, or network interface.

Unlike an auto-assigned public IP, an Elastic IP stays the same even if you stop and start the underlying instance, which matters for DNS records, firewall allowlists, or partner integrations that expect a fixed address.

You can remap an Elastic IP from one instance to another in seconds, which is useful for quickly replacing a failed instance without updating downstream configuration.

AWS charges for an Elastic IP that's allocated but not attached to a running resource, specifically to discourage hoarding scarce IPv4 addresses.

Take quiz
What happens to an Elastic IP when its instance is stopped and started again?
It's released back to AWS automatically
It stays associated with the account and instance
It converts to a private IP
It changes to a new random address
Why does AWS charge for an unattached Elastic IP?
It's a one-time provisioning fee, not ongoing
To fund AWS Support
To discourage hoarding a limited public IPv4 resource
Because unattached EIPs use more bandwidth

16. Define VPC Flow Logs?

VPC Flow Logs capture metadata about the IP traffic flowing to and from network interfaces in your VPC - source and destination IP, ports, protocol, byte and packet counts, and whether the traffic was accepted or rejected.

They can be enabled at the VPC, subnet, or individual ENI level, and delivered to Amazon CloudWatch Logs, Amazon S3, or Amazon Data Firehose for further processing.

Flow Logs record connection metadata only, not packet contents, so they're useful for diagnosing why traffic is being blocked, spotting unexpected traffic patterns, or feeding a SIEM, but they won't show you application-layer data.

They're a separate feature from CloudTrail, which logs API calls rather than network traffic.

Take quiz
What do VPC Flow Logs actually capture?
Connection metadata like source/destination IP, ports, and accept/reject status
Only Security Group rule changes
Full packet contents, including payload data
Only DNS queries
At which levels can VPC Flow Logs be enabled?
Only at the entire account level
Only per Region, with no finer control
Only on NAT Gateways
VPC, subnet, or individual ENI level

17. What is AWS Transit Gateway?

AWS Transit Gateway is a managed regional network hub that connects VPCs, VPN connections, and Direct Connect gateways through a single set of attachments instead of a mesh of individual connections.

Each VPC or on-premises network attaches to the Transit Gateway once, and the Transit Gateway's route tables decide which attachments can reach which other attachments, similar to how a router works between separate networks.

It scales to thousands of attachments and supports inter-Region peering between Transit Gateways, which lets you build a global network backbone without individually peering every VPC pair.

Because routing between attachments is centralized and Transit Gateway is inherently a hub, it's the standard building block for hub-and-spoke network designs at scale, where VPC Peering's non-transitive nature would otherwise require dozens or hundreds of individual peering connections.

Take quiz
Transit Gateway primarily replaces the need for:
A full mesh of individual VPC Peering connections
Security Groups on every instance
Route tables inside each subnet
Elastic IP addresses
Can Transit Gateways in different Regions be connected to each other?
No, Transit Gateway is strictly single-Region only
Yes, via inter-Region Transit Gateway peering
Only by recreating the same Transit Gateway in both Regions
Only through a third-party appliance

18. List the default VPC limits per AWS Region?

AWS enforces a set of default quotas per Region that shape how many VPC resources you can create before requesting an increase.

  • VPCs per Region: 5 (adjustable)
  • Subnets per VPC: 200 (adjustable)
  • IPv4 CIDR blocks per VPC: 5, including the primary block (adjustable up to 50)
  • Rules per Network ACL: 20 inbound and 20 outbound by default (adjustable up to 40 each)
  • Elastic IPs per Region: 5 (adjustable)

Most of these are soft limits you can raise through the Service Quotas console or a support request, but they're worth knowing before designing a large multi-VPC environment, since hitting one mid-deployment can stall an automated rollout.

Take quiz
What is the default number of VPCs allowed per Region?
200
1
5
50
What is the default maximum number of subnets in a single VPC?
50
200
20
Unlimited

19. How does traffic flow from the internet to an EC2 instance in a public subnet?

A request from the internet first hits the VPC's Internet Gateway, which performs 1:1 NAT to translate the instance's public or Elastic IP into its private IP inside the VPC.

The subnet's route table must have a route sending that traffic toward the IGW; from there, it's evaluated against the subnet's Network ACL, then the instance's Security Group, before finally reaching the instance's network interface.

The return path runs in reverse, but since Security Groups are stateful, the reply doesn't need a separate outbound rule - only the NACL does, since it evaluates each direction independently.

flowchart LR
  A["Client on internet"] --> B["Internet Gateway"]
  B --> C["Route table: 0.0.0.0/0 -> igw"]
  C --> D["Subnet Network ACL"]
  D --> E["Instance Security Group"]
  E --> F["EC2 instance"]
Take quiz
What does the Internet Gateway do to an inbound request's destination address?
Routes it to a NAT Gateway first
Encrypts it with a VPN tunnel
Nothing, it passes traffic through unmodified
Performs 1:1 NAT, translating the public/Elastic IP to the instance's private IP
Why doesn't the reply traffic need a separate outbound Security Group rule?
The NACL handles all outbound filtering instead
Reply traffic bypasses the ENI entirely
Security Groups don't filter outbound traffic at all
Security Groups are stateful, so replies to allowed traffic are automatically permitted

20. How is a NAT Gateway different from an Internet Gateway?

An Internet Gateway enables two-way traffic: it lets resources with a public IP both initiate outbound connections and accept inbound connections from the internet.

A NAT Gateway only enables one-way, outbound-initiated traffic - it lets private-subnet instances reach the internet, but nothing on the internet can initiate a new connection to them through it.

Internet Gateway NAT Gateway
Attached directly to the VPC. Deployed inside a specific public subnet.
Supports inbound and outbound traffic. Supports outbound-initiated traffic only.
Used by public subnets. Used by private subnets routing through it.
No hourly or data charge. Hourly charge plus per-GB data processing fee.

In short: the IGW is what makes a subnet public, while the NAT Gateway is what gives a private subnet limited, outbound-only internet reach.

Take quiz
Which of the two can accept a new inbound connection initiated from the internet?
Neither one
NAT Gateway
Internet Gateway
Both equally
Where is a NAT Gateway physically deployed?
Inside a public subnet
Outside the VPC, on the AWS backbone
Inside every private subnet it serves
Directly on the VPC, with no subnet association

21. What is the difference between Security Groups and Network ACLs?

Security Groups and NACLs both filter traffic, but they operate at different layers and with different statefulness, which changes how you configure each one.

Security Group Network ACL
Operates at the network interface (instance) level. Operates at the subnet boundary.
Stateful - return traffic is auto-allowed. Stateless - return traffic needs its own rule.
Allow rules only. Allow and explicit deny rules.
All rules evaluated together. Rules evaluated in numbered order, first match wins.

In practice, Security Groups do most of the fine-grained access control, while NACLs are typically used more sparingly, for coarse subnet-wide blocks like denying a known-bad CIDR range regardless of which instance it targets.

Take quiz
Which one requires you to explicitly allow the return traffic yourself?
Network ACL
Security Group
Both require it
Neither requires it
Which one can contain an explicit deny rule?
Security Group
Network ACL
Both support explicit deny
Neither supports deny rules

22. What is the difference between a NAT Gateway and a NAT instance?

Both let private-subnet resources reach the internet, but a NAT Gateway is a fully managed AWS service while a NAT instance is a regular EC2 instance running NAT software that you patch and scale yourself.

NAT Gateway NAT Instance
Fully managed by AWS, no patching. You manage the OS, patches, and scaling.
Scales automatically up to 100 Gbps. Bandwidth capped by the instance type chosen.
Cannot be used as a bastion or run other software. Can also run other software, like a bastion or proxy.
No Security Group of its own to configure. Uses a Security Group and requires disabling source/destination check.

AWS itself recommends NAT Gateway for nearly all use cases today; NAT instances mainly survive in legacy designs or where a Security Group needs to filter the NAT traffic itself, which a NAT Gateway doesn't expose.

Take quiz
Which one requires you to disable the source/destination check on the underlying resource?
NAT instance
Neither requires it
NAT Gateway
Both require it
What is one capability a NAT instance has that a NAT Gateway doesn't?
Being deployed without a public subnet
Running additional software, like acting as a bastion host too
Working across multiple Availability Zones simultaneously
Automatic bandwidth scaling to 100 Gbps

23. What is the difference between an Interface Endpoint and a Gateway Endpoint?

Both give private access to AWS services, but they're implemented completely differently under the hood, which affects cost, reach, and which services they support.

A Gateway endpoint works purely at the routing layer: AWS adds a special target to your route table, and only S3 and DynamoDB support it, at no extra cost.

An Interface endpoint is a real Elastic Network Interface with a private IP address placed inside your subnet, backed by AWS PrivateLink; it supports the vast majority of other AWS services plus custom PrivateLink-published services, and it's billed hourly plus per-GB processed.

Because an Interface endpoint has a routable private IP, it can also be reached from on-premises networks over Direct Connect or VPN - something a Gateway endpoint, being VPC-route-table-only, cannot do.

Take quiz
Which endpoint type is backed by an actual Elastic Network Interface?
Both types use an ENI
Neither uses an ENI
Gateway endpoint
Interface endpoint
Which endpoint type can be reached from an on-premises network over Direct Connect or VPN?
Both types equally
Neither type supports on-premises access
Gateway endpoint, since it uses routing
Interface endpoint, since it has a routable private IP

24. How does route table association determine whether a subnet is public or private?

A subnet has no inherent "public" or "private" flag in AWS - its behavior is entirely a function of which route table it's associated with and what that table points at.

If the associated route table has a 0.0.0.0/0 route targeting an Internet Gateway, any instance in that subnet with a public IP can reach and be reached from the internet, making it a public subnet.

If instead the 0.0.0.0/0 route targets a NAT Gateway, the subnet is private - outbound internet access works, but nothing outside can initiate a connection in.

This means you can flip a subnet's classification without touching the subnet itself, just by changing which route table it's associated with - a detail that trips people up when auditing a VPC, since the subnet console view doesn't label it "public" anywhere.

Take quiz
What single change can turn a public subnet into a private one, without modifying the subnet itself?
Re-associating the subnet with a route table that has no route to an Internet Gateway
Changing the subnet's CIDR block
Moving the subnet to a different Availability Zone
Deleting all instances in the subnet
Does the AWS console label a subnet as "public" or "private" directly on the subnet itself?
Only for subnets created via the VPC wizard
Only if Flow Logs are enabled
Yes, it's a built-in subnet attribute
No, that status is inferred from the associated route table's routes

25. Why do we use VPC Peering instead of public internet for cross-VPC communication?

Routing traffic between two VPCs over the public internet means it would need public IPs, an Internet Gateway on both sides, and Security Group rules opening ports to a public range, all of which meaningfully increases the attack surface.

VPC Peering instead lets instances communicate using their private IPs directly, with traffic carried entirely over AWS's internal backbone rather than any public path.

That has real, concrete benefits: no data egress charges for crossing to the public internet, lower and more consistent latency since it avoids public routing hops, and no need to manage public-facing endpoints or TLS termination just to let two internal services talk to each other.

It also keeps the two VPCs' internal topologies invisible to each other beyond the specific peered CIDR ranges, which is a meaningfully smaller exposure than opening resources to the internet.

Take quiz
What kind of IP addresses do instances use to communicate over a VPC Peering connection?
A special peering-only IP range
Private IPs
Elastic IPs exclusively
Public IPs only
What is one concrete downside of routing cross-VPC traffic over the public internet instead of peering?
It automatically encrypts all traffic, adding overhead
It's technically impossible to configure
It disables Flow Logs for that traffic
It requires public IPs and open Security Group rules, increasing attack surface

26. When should you choose Transit Gateway over VPC Peering?

VPC Peering makes sense for a small, stable number of VPC-to-VPC relationships - a handful of connections are easy to reason about, and Peering has no hourly cost of its own.

Transit Gateway becomes the better choice once the number of VPCs grows past roughly ten or so, because Peering's non-transitive nature means every new VPC needs a direct connection to every other VPC it must reach, growing as n(n-1)/2 connections.

Transit Gateway also wins when you need centralized routing control, shared connectivity to on-premises networks via a single VPN or Direct Connect attachment reused by many VPCs, or multi-Region connectivity through inter-Region Transit Gateway peering.

The trade-off is cost and a small amount of added latency per hop, since Transit Gateway is billed per attachment-hour and per GB processed, on top of what Peering would cost for the same traffic (which is free for same-Region peering).

Take quiz
Why does VPC Peering become hard to manage as the number of VPCs grows?
Peering has a hard limit of exactly 3 VPCs
AWS deprecates Peering after 10 VPCs
Peering only works within a single Availability Zone
Its non-transitive nature means connections grow roughly with the square of VPC count
What capability does Transit Gateway offer that plain VPC Peering does not?
Free data transfer with no per-GB charge, unlike Peering
A single shared connection point for many VPCs to reach on-premises networks
Private IP communication between VPCs
Support for overlapping CIDR ranges between all attached VPCs

27. What happens when two peered VPCs have overlapping CIDR blocks?

VPC Peering simply won't work between two VPCs whose CIDR blocks overlap, even partially - AWS blocks the peering connection from being created in that state.

The reason is routing ambiguity: if both VPCs used, say, 10.0.0.0/16, a route table entry pointing that whole range at the peering connection would also try to match local traffic, and AWS has no way to tell which destination you actually meant.

This is why CIDR planning across an organization matters well before peering is ever attempted - once a VPC is created and populated with resources, changing its primary CIDR isn't possible, though you can add a secondary CIDR block in a non-overlapping range for new resources.

The practical fix for two already-overlapping VPCs is usually to route between them through a NAT-based transit VPC or an overlay solution, since a direct peering connection is not an option.

Take quiz
Can you create a VPC Peering connection between two VPCs with overlapping CIDR blocks?
Only if the overlap is less than half the range
Yes, always, with a special override flag
No, AWS blocks peering when CIDR blocks overlap
Only within the same AWS account
Once a VPC exists with resources, can you change its primary CIDR block?
Yes, but only by deleting all subnets first
No, but you can add a non-overlapping secondary CIDR block
Yes, at any time with no restrictions
No, the only fix is deleting and recreating the AWS account

28. How is Security Group evaluation different from NACL evaluation for return traffic?

Security Groups are stateful, so they only need to evaluate the traffic direction that initiated a connection - once an inbound request is allowed, the corresponding outbound reply is automatically permitted, with no separate rule lookup.

NACLs are stateless, so they evaluate inbound and outbound traffic completely independently, as two separate rule sets, regardless of which side initiated the connection.

In practice this means an inbound allow rule on a NACL for, say, port 443, doesn't automatically permit the reply traffic going back out on an ephemeral port - you need a separate outbound rule allowing traffic on the ephemeral port range (typically 1024-65535) for replies to actually leave the subnet.

Forgetting this ephemeral-port outbound rule is one of the most common reasons a custom NACL silently breaks connectivity that Security Group rules alone would have allowed.

Take quiz
Why don't Security Groups need a separate rule for reply traffic?
Reply traffic is exempt from all VPC filtering
NACLs handle reply traffic instead
They don't filter outbound traffic at all
They are stateful and auto-permit replies to allowed connections
What is a common mistake when locking down a custom NACL?
Forgetting the outbound rule allowing ephemeral ports for reply traffic
Setting the NACL to allow all traffic by default
Forgetting to also update the Security Group
Applying the NACL to an Elastic IP directly

29. Why should you use multiple Availability Zones when designing VPC subnets?

An Availability Zone is one or more physically separate data centers within a Region, engineered so a failure in one AZ - power, cooling, or a hardware fault - doesn't take down another.

Since a subnet is confined to a single AZ, placing all of an application's subnets in just one AZ means an AZ-level outage takes the entire application down, regardless of how much redundancy exists within that AZ.

Spreading subnets, and the resources inside them, across at least two AZs lets services like an Application Load Balancer, Auto Scaling group, or Multi-AZ RDS deployment keep serving traffic by failing over to the healthy AZ automatically.

The typical pattern is a matching pair of public and private subnets per AZ - for example, a public and private subnet in us-east-1a and an identical pair in us-east-1b - so NAT Gateways, load balancers, and application tiers all have a same-AZ path that avoids unnecessary cross-AZ data transfer charges.

Take quiz
What happens if all of an application's subnets sit in a single Availability Zone?
An AZ-level outage takes down the entire application
Nothing changes, AZs don't affect availability
The application automatically fails over to another Region
AWS blocks this configuration from being created
What is the typical subnet pattern used for multi-AZ resilience?
A matching public/private subnet pair in each AZ used
One giant subnet spanning all AZs
One subnet per Region, not per AZ
A single private subnet with no public subnet at all

30. How do you troubleshoot an EC2 instance that cannot reach the internet?

Work through the path methodically rather than guessing, starting from the instance and moving outward toward the internet.

  1. Confirm the instance has a public IP (if the subnet is meant to be public) or that its route goes through a working NAT Gateway (if private).
  2. Check the subnet's route table for a 0.0.0.0/0 route pointing at the correct Internet Gateway or NAT Gateway ID.
  3. Verify the Security Group allows the relevant outbound traffic (often overlooked, since default Security Groups allow all outbound, but custom ones may not).
  4. Check the subnet's NACL for both inbound and outbound rules, remembering the ephemeral port range needs to be open in both directions.
  5. For private-subnet instances, confirm the NAT Gateway itself sits in a public subnet with its own working route to an Internet Gateway.

AWS's VPC Reachability Analyzer can automate most of this by tracing the actual path and reporting exactly which hop blocks the connection, which is faster than manually walking through the console for a complex path.

aws ec2 start-network-insights-analysis \
  --network-insights-path-id nip-0123456789abcdef0

Take quiz
What AWS tool can automatically trace a network path and identify exactly where it's blocked?
AWS Config
VPC Flow Logs
Amazon Inspector
VPC Reachability Analyzer
For a private-subnet instance with no internet access, what upstream resource should also be checked?
Whether Transit Gateway is deployed
The AMI used to launch the instance
The Elastic IP quota for the account
Whether the NAT Gateway it routes through has its own working route to an Internet Gateway

31. What is the difference between a VPC and a subnet in terms of scope?

A VPC is scoped to a single AWS Region - it exists across all the Availability Zones in that Region, but it doesn't extend into any other Region.

A subnet is scoped one level down, to a single Availability Zone within that VPC's Region - it cannot span multiple AZs, and every subnet belongs to exactly one VPC for its entire lifetime.

VPC Subnet
Scoped to one Region. Scoped to one Availability Zone.
Defines the overall CIDR block. Carves out a smaller CIDR from the VPC's range.
Holds route tables, gateways, endpoints. Associated with exactly one route table at a time.

This nesting - Region contains VPC, VPC contains subnets across AZs - is the backbone of how AWS network isolation and fault-tolerance both work at the same time.

Take quiz
A VPC's scope is limited to:
A single AWS Region
A single Availability Zone
A single subnet
The global AWS network
Can a subnet ever be reassigned to a different VPC after creation?
No, a subnet belongs to one VPC for its entire lifetime
Yes, but only within the same Availability Zone
Yes, using the VPC console's move option
Yes, if the CIDR blocks match exactly

32. How does AWS Site-to-Site VPN connect an on-premises network to a VPC?

AWS Site-to-Site VPN creates encrypted IPsec tunnels between a Virtual Private Gateway (or Transit Gateway) on the AWS side and a Customer Gateway device on the on-premises side.

Each VPN connection provisions two tunnels, terminating in different AWS Availability Zones for redundancy, and either static routes or BGP dynamic routing is used to exchange which CIDR ranges are reachable through each tunnel.

Once the tunnels are up, the VPC's route table gets routes pointing on-premises CIDR ranges at the Virtual Private Gateway, and the on-premises router gets matching routes pointing AWS-bound ranges back through the Customer Gateway.

flowchart LR
  A["On-premises network"] --> B["Customer Gateway device"]
  B -- IPsec Tunnel 1 --> C["Virtual Private Gateway - AZ1"]
  B -- IPsec Tunnel 2 --> D["Virtual Private Gateway - AZ2"]
  C --> E["VPC route table"]
  D --> E
  E --> F["VPC subnets"]

Because it runs over the public internet with encryption, Site-to-Site VPN is quicker to set up than AWS Direct Connect, though it typically has less predictable throughput and latency.

Take quiz
How many IPsec tunnels does a single Site-to-Site VPN connection provision, and why?
As many as there are on-premises routers
Just one, for simplicity
Two, terminating in different AZs for redundancy
Four, one per subnet
What underlying network does Site-to-Site VPN traffic actually travel over?
AWS's internal backbone exclusively, bypassing the internet
A satellite link provisioned by AWS
The public internet, protected by IPsec encryption
A dedicated AWS Direct Connect circuit

33. Why doesn't a private subnet have direct outbound internet access by default?

A private subnet has no route to an Internet Gateway in its route table - that's the entire definition of "private" in VPC terms, not a separate switch that needs to be turned off.

Without that route, any packet destined for a public internet address simply has nowhere to go once it leaves the local VPC range, so it's dropped rather than forwarded, regardless of Security Group or NACL settings.

This is intentional isolation: databases, internal services, and other resources that should never be reachable from, or need to reach out to, the open internet stay that way by construction, not by relying on firewall rules alone as the only line of defense.

If outbound-only internet access is actually needed, you add a route through a NAT Gateway (or NAT instance) deployed in a public subnet - the private subnet itself never gets a direct IGW route.

Take quiz
What, specifically, makes a subnet "private" rather than public?
A private-subnet flag set when it's created
The absence of a route table entry pointing to an Internet Gateway
Being placed in a specific Availability Zone
Having no Security Group attached
What is the standard way to give a private subnet outbound-only internet access?
Attach an Internet Gateway directly to the private subnet
Route its 0.0.0.0/0 traffic through a NAT Gateway in a public subnet
Disable the subnet's Network ACL entirely
Assign every instance a public IP

34. What is the difference between an Elastic IP and a standard public IP?

A standard (auto-assigned) public IP is handed out from AWS's pool when an instance launches in a subnet configured to auto-assign one, and it's released back to the pool the moment the instance is stopped or terminated.

An Elastic IP is a static address you explicitly allocate to your account, and it stays reserved for you - and keeps the same value - across stop/start cycles, until you deliberately release it.

Standard Public IP Elastic IP
Changes on stop/start. Stays fixed across stop/start.
Free while attached. Free while attached; charged if idle/unattached.
Cannot be remapped between instances. Can be remapped to another instance in seconds.

Elastic IPs are the right choice whenever an external system needs to reference your resource by a fixed address - a DNS A record, a partner's firewall allowlist, or a licensing server tied to an IP.

Take quiz
What happens to a standard auto-assigned public IP when the instance is stopped?
It's transferred to a backup instance
It converts into an Elastic IP automatically
It stays reserved for that instance indefinitely
It's released back to AWS's pool
When is an Elastic IP the clearly better choice over a standard public IP?
When the instance will never be stopped or restarted
When the subnet is private
When an external system needs a fixed, unchanging address to reference
When cost needs to be as low as possible with no exceptions

35. How do you optimize costs when using NAT Gateways in a multi-AZ VPC?

The most direct lever is reducing how much data actually flows through NAT Gateways, since the per-GB data processing charge, not the hourly fee, is usually the larger line item at scale.

  1. Add Gateway VPC endpoints for S3 and DynamoDB traffic, since that traffic is free and never needs to touch NAT at all.
  2. Add Interface endpoints for other frequently-used AWS services (like ECR, Secrets Manager, or CloudWatch Logs) if the endpoint cost is lower than the NAT data processing it would otherwise incur - this depends on traffic volume and needs a rough cost comparison.
  3. Consider one shared NAT Gateway per AZ instead of per subnet, since NAT Gateways are already sized to handle heavy throughput and multiple private subnets in the same AZ can share one.
  4. For non-production environments, a single NAT Gateway (accepting a temporary single-AZ dependency) or a scheduled NAT instance can be cheaper than fully redundant NAT Gateways, since dev/test rarely needs the same availability guarantees as production.

None of these should compromise the multi-AZ redundancy pattern in production - the goal is cutting unnecessary data volume and choosing the right number of NAT Gateways, not removing redundancy to save money.

Take quiz
Which typically drives NAT Gateway cost more at scale: the hourly charge or the per-GB data processing charge?
The per-GB data processing charge, once traffic volume is significant
The hourly charge, by a wide margin
They're always exactly equal
Neither, NAT Gateway has a flat monthly fee
Why do Gateway VPC endpoints for S3 and DynamoDB help reduce NAT Gateway cost?
They make NAT Gateways run faster
They replace the need for any Security Groups
That traffic goes through the endpoint instead of NAT, and it's free
They increase the NAT Gateway's bandwidth cap

36. What is the difference between VPC Flow Logs and CloudTrail?

These two logging services answer fundamentally different questions, and mixing them up is a common early mistake.

VPC Flow Logs AWS CloudTrail
Records network traffic metadata (IPs, ports, accept/reject). Records API calls made against AWS services.
Answers "who talked to whom over the network, and was it allowed?" Answers "who called which API, and did it succeed?"
Scoped to a VPC, subnet, or ENI. Scoped to an AWS account/Region for control-plane activity.
Useful for diagnosing blocked connections. Useful for diagnosing who created or modified a resource.

In a real investigation you often need both: CloudTrail to see that someone opened a Security Group rule, and Flow Logs to see the traffic that started flowing once that rule was opened.

Take quiz
Which service would tell you that a Security Group rule was modified, and by whom?
Both equally well
Neither logs this information
VPC Flow Logs
AWS CloudTrail
Which service would show you that a connection attempt on port 22 was rejected?
Both, identically
AWS CloudTrail
VPC Flow Logs
Neither, this requires a third-party tool

37. When should you use a Bastion Host versus AWS Systems Manager Session Manager?

A Bastion Host is an EC2 instance placed in a public subnet specifically to be an SSH/RDP jump box into private-subnet resources - it needs a Security Group opening 22 or 3389 to at least some source range, its own patching, and key management.

AWS Systems Manager Session Manager instead gives you a shell into a private instance without any inbound port open at all - the Systems Manager agent on the instance makes an outbound connection to the Systems Manager service, and your session is brokered through that, authenticated and authorized entirely through IAM.

Session Manager is the better default for most modern environments: no bastion to patch or scale, no open inbound ports to manage, and every session is automatically logged for audit through CloudTrail and optionally to S3 or CloudWatch Logs.

A Bastion Host still shows up where Session Manager's agent-based model doesn't fit - for example, connecting into a legacy on-premises-style network segment, or a non-EC2 device that can't run the SSM agent.

Take quiz
Does Session Manager require an inbound port like 22 to be open on the target instance?
Only if the instance is in a public subnet
Yes, port 22 must always be open
No, the SSM agent makes an outbound connection instead
Yes, but only port 3389
What is a scenario where a traditional Bastion Host might still be needed over Session Manager?
Whenever IAM authentication is preferred
Connecting to any standard EC2 instance
Whenever cost needs to be minimized
Connecting to a resource that can't run the SSM agent

38. How does DNS resolution work inside a VPC?

Every VPC has a built-in DNS resolver, the Amazon Route 53 Resolver, reachable at the base of the VPC's CIDR range plus two - for example 10.0.0.2 in a 10.0.0.0/16 VPC.

Two VPC-level settings control how this works: enableDnsSupport, which turns the resolver on for the VPC, and enableDnsHostnames, which controls whether instances actually get public or private DNS hostnames assigned to them.

For a plain public DNS lookup, like resolving a public website, the Resolver forwards the query out to the public DNS system; for an AWS service's private endpoint, or a Route 53 private hosted zone associated with the VPC, it resolves internally without leaving AWS's network.

flowchart LR
  A["EC2 instance"] --> B["VPC DNS Resolver at .2 address"]
  B -->|Public domain| C["Public DNS / Route 53 public zone"]
  B -->|Private hosted zone or endpoint record| D["Internal resolution, no internet"]

This is also why an Interface endpoint's Private DNS setting matters - it lets the service's normal public hostname resolve to the endpoint's private IP instead, so existing code doesn't need to change its endpoint URL at all.

Take quiz
What is the address of a VPC's built-in DNS resolver in a 10.0.0.0/16 VPC?
10.0.0.53
10.0.0.2
It has no fixed address
10.0.0.1
Which VPC setting controls whether the built-in DNS resolver is enabled at all?
enableVpcDns
enableDnsSupport
dnsResolutionMode
enableDnsHostnames

39. Explain the execution flow of a packet from a private EC2 instance to an S3 bucket using a Gateway Endpoint?

The instance issues a request to S3's standard public hostname, like my-bucket.s3.amazonaws.com, exactly as it would with no endpoint configured at all - nothing changes on the application side.

DNS resolves that hostname to one of S3's public IP ranges, but instead of that traffic needing a route to the internet, the subnet's route table has an entry matching S3's IP prefix list (a managed, AWS-updated list of S3's address ranges) with the Gateway endpoint as the target.

Because that route is more specific than a generic 0.0.0.0/0 route would be for those particular prefixes, AWS's routing layer sends the packet to the Gateway endpoint instead of out through a NAT Gateway or Internet Gateway - the private subnet never actually needs either for this traffic.

The endpoint policy attached to the Gateway endpoint is evaluated as an additional authorization layer on top of the bucket policy and IAM permissions, and the request is served entirely over AWS's internal network.

flowchart LR
  A["Private EC2 instance"] --> B["DNS resolves S3 hostname"]
  B --> C["Route table: S3 prefix list -> Gateway Endpoint"]
  C --> D["Gateway Endpoint policy evaluation"]
  D --> E["S3 bucket policy + IAM check"]
  E --> F["S3 bucket"]
Take quiz
What does the route table actually match to redirect S3 traffic to the Gateway endpoint?
A managed prefix list of S3's public IP ranges
The bucket's ARN
A wildcard 0.0.0.0/0 route
The instance's Security Group ID
Does the application code need to change its S3 hostname to use a Gateway endpoint?
Yes, it must use a special endpoint-specific hostname
No, it uses the same standard S3 hostname as always
Only if IAM permissions are also changed
Yes, it must switch to an IP address literal

40. Explain the internal working of Security Group connection tracking?

Every time a Security Group allows a new connection, the underlying hypervisor's connection-tracking layer records an entry describing that flow - source and destination IP, ports, and protocol - so it can recognize return traffic as part of the same session rather than a brand-new request.

This is exactly what makes Security Groups stateful: once the tracked entry exists, reply packets matching it are permitted automatically, without being checked against the outbound rule set again.

Tracked entries eventually expire after a period of inactivity - TCP connections are tracked until closed or timed out, and UDP "connections" (which have no real handshake) are tracked based on a shorter idle timeout, since there's no explicit close signal to rely on.

This matters operationally in a specific edge case: if you change a Security Group rule, already-established tracked connections that were allowed under the old rule can keep flowing until they naturally close, since the change doesn't necessarily terminate them immediately - only new connection attempts are evaluated against the updated rule set right away, and for some instance types existing flows are also actively re-evaluated shortly after a rule change.

Take quiz
What does connection tracking record for an allowed connection?
Source/destination IP, ports, and protocol for that flow
The IAM role attached to the instance
The instance's AMI ID
Only the Security Group's rule ID
What is a practical consequence of connection tracking when you tighten a Security Group rule?
All traffic is instantly and universally cut off
The change has no effect until the instance is rebooted
Only inbound rules are ever affected by tracking
Already-established connections may continue briefly rather than terminating the instant the rule changes

41. How can you optimize a VPC design for a multi-account AWS Organization?

The core idea is to stop treating each account's VPC as an island and instead centralize the networking pieces that don't need to be duplicated per account.

  1. Centralize egress: route all accounts' internet-bound traffic through a shared NAT Gateway or egress VPC attached via Transit Gateway, instead of paying for and managing NAT per account.
  2. Use AWS Resource Access Manager (RAM) to share subnets from a central networking account into workload accounts, so application teams get subnets to deploy into without owning VPC infrastructure themselves.
  3. Standardize on Transit Gateway as the hub, rather than a mesh of Peering connections, since the number of accounts and VPCs in an Organization tends to grow well past what Peering can reasonably manage.
  4. Reserve non-overlapping CIDR ranges per account or environment up front using IPAM (IP Address Manager), so two teams never accidentally claim the same range and block future peering or Transit Gateway attachment.
  5. Centralize inspection and logging: route traffic through a shared inspection VPC for firewall appliances, and aggregate Flow Logs from every account into one central logging account.

The net effect is that individual account teams focus on their application, while the network foundation - IP planning, egress, inspection, and connectivity - is owned and evolved centrally.

Take quiz
What AWS service is designed specifically to prevent CIDR overlap across many accounts in an Organization?
AWS Config
AWS Trusted Advisor
Amazon GuardDuty
IPAM (IP Address Manager)
What does AWS Resource Access Manager let a central networking account do?
Replace the need for Transit Gateway entirely
Automatically merge multiple AWS accounts into one
Share subnets into other accounts so they can deploy without owning VPC infrastructure
Grant root access across accounts

42. Explain the lifecycle of a VPC Peering connection request?

A peering connection moves through a defined set of states from creation to either an active connection or a terminal non-active state, and understanding these states is what makes troubleshooting a stuck peering request straightforward.

The requester initiates the connection, which enters pending-acceptance - at this point nothing flows yet, and the request simply waits for the accepter account (or the same account, for a same-account peer) to act.

If the accepter approves it, the connection moves to active, and both sides can now add routes to their route tables pointing at it. If the accepter explicitly declines it, it moves to rejected. If nobody acts within the request's time window, it moves to expired. An active connection can later be terminated by either side, moving it to deleted.

flowchart LR
  A["Requester initiates"] --> B[pending-acceptance]
  B -->|Accepter approves| C[active]
  B -->|Accepter declines| D[rejected]
  B -->|No action in time| E[expired]
  C -->|Either side deletes| F[deleted]

Being active only means the connection itself exists - traffic still won't flow until both VPCs' route tables and Security Groups are updated to actually use it, which is the step most often forgotten.

Take quiz
What state does a peering request sit in while waiting for the accepter to act?
pending-acceptance
in-review
provisioning
active
Is traffic guaranteed to flow the moment a peering connection reaches the active state?
No, both sides still need route table (and often Security Group) updates first
Yes, but only for same-account peering
No, active connections require a support ticket to enable traffic
Yes, active means traffic flows immediately with no other steps

43. How do you troubleshoot asymmetric routing issues in a VPC with multiple route tables?

Asymmetric routing happens when outbound traffic from a resource takes one path - say, through a NAT Gateway or a firewall appliance - but the return traffic takes a different path back, often bypassing that same appliance, which breaks stateful inspection or connection tracking along the way.

This most commonly shows up in VPC designs with multiple route tables per subnet tier, or where traffic is meant to flow through a centralized inspection VPC in one direction but a more direct route exists for the return path.

  1. Map the actual route tables involved for both directions of the flow, not just the one you assume is used - use describe-route-tables to confirm exactly which table each subnet is associated with.
  2. Check for a more specific route that unintentionally overrides the intended path on the return leg, since AWS always honors the longest-prefix match regardless of design intent.
  3. If a stateful appliance (like a NAT instance or third-party firewall) is involved, confirm both legs of the conversation actually traverse it - stateful devices will silently drop return traffic they never saw the outbound leg for.
  4. Use VPC Reachability Analyzer in both directions, source-to-destination and destination-to-source, since a one-directional trace won't reveal an asymmetric path.
aws ec2 describe-route-tables \
  --filters "Name=association.subnet-id,Values=subnet-0abc123" \
  --query "RouteTables[].Routes"

Take quiz
What is the core problem in asymmetric routing?
Traffic is encrypted on one leg but not the other
Outbound and return traffic take different paths, breaking stateful devices along the way
The VPC has too few Availability Zones
DNS resolves to the wrong region
Why should Reachability Analyzer be run in both directions when diagnosing this?
A one-directional trace can't reveal that the return path differs from the outbound path
Running it twice doubles the accuracy of a single trace
It's the only way to enable Flow Logs
It's required by AWS's terms of service

44. Explain the internal working of AWS Transit Gateway route propagation?

Every attachment to a Transit Gateway - a VPC, VPN, or Direct Connect gateway - is associated with one Transit Gateway route table, which controls what that attachment can send traffic to.

Route propagation is the mechanism that automatically populates a Transit Gateway route table with the CIDR ranges reachable from an attachment, without an administrator manually entering each one - a VPC attachment propagates its own CIDR block, while a VPN or Direct Connect attachment propagates whatever routes are learned dynamically via BGP.

Association and propagation are deliberately separate concepts: an attachment can propagate its routes into a Transit Gateway route table it isn't even associated with, which is exactly what enables asymmetric hub-and-spoke designs, like a shared services VPC visible to every spoke, while spokes stay isolated from each other.

flowchart LR
  A["Spoke VPC attachment"] -->|Propagates its CIDR| B["Transit Gateway route table"]
  C["VPN attachment - BGP learned routes"] -->|Propagates learned routes| B
  B -->|Associated with| D["Spoke VPC's traffic lookups"]
  B -->|Associated with| E["Another spoke's traffic lookups"]

On the VPC side, the VPC's own route table still needs a static route pointing relevant CIDR ranges at the Transit Gateway attachment - propagation only automates the Transit Gateway's internal routing table, not the VPC's own.

Take quiz
What does route propagation into a Transit Gateway route table automate?
Assigning Elastic IPs to VPC instances
Creating Security Group rules automatically
Populating the table with CIDR ranges learned from attachments, without manual entry
Encrypting all traffic between attachments
Can an attachment propagate routes into a Transit Gateway route table it isn't associated with?
No, AWS requires them to always match exactly
No, association and propagation are always the same thing
Only for VPN attachments, never for VPCs
Yes, and this separation is what enables asymmetric hub-and-spoke designs

45. What is the difference between Transit Gateway and VPC Peering at scale for a hub-and-spoke architecture?

At small scale the two can look similar - both let VPCs reach each other privately - but they diverge sharply once you're connecting more than a handful of VPCs together.

VPC Peering (mesh) Transit Gateway (hub-and-spoke)
Connections grow as n(n-1)/2 for n VPCs. One attachment per VPC, regardless of total count.
Not transitive - every pair needs its own connection. Transitive by design through the hub's route tables.
No extra hourly cost for the connection itself. Billed per attachment-hour plus per-GB processed.
Routing control is per-VPC, decentralized. Centralized routing policy across all spokes.

At 5 VPCs, a mesh of Peering connections (10 links) is manageable; at 50 VPCs, that same mesh would need 1,225 connections, which is operationally unworkable, while Transit Gateway still needs just 50 attachments and one central routing policy.

Take quiz
How many Peering connections would a full mesh of 10 VPCs require?
100
20
10
45
What makes Transit Gateway inherently transitive, unlike Peering?
It doesn't actually support transitive routing either
It uses public IPs instead of private ones
It only works within a single Availability Zone
Its centralized route tables let traffic flow between any attachments that are permitted to see each other

VPC Peering connects two entire VPC networks to each other - once peered and routed, any resource in VPC A can potentially reach any resource in VPC B's peered CIDR range, subject to Security Groups and NACLs.

AWS PrivateLink instead exposes a single specific service, not a whole network - a service provider publishes an endpoint service backed by a Network Load Balancer, and consumers connect to just that one service through an Interface endpoint in their own VPC.

This is a meaningfully different security model: PrivateLink consumers never gain any visibility into the provider's VPC topology, IP ranges, or other resources, and there's no CIDR overlap concern at all, since no VPC-to-VPC routing ever happens - the connection terminates at the specific service.

PrivateLink is the standard pattern for SaaS vendors offering private connectivity to their product, or for a platform team publishing one specific internal service to many consumer VPCs across different accounts, without exposing anything else in the provider's network.

47. Explain the execution flow of traffic through a VPC with a centralized inspection VPC architecture?

In a centralized inspection design, spoke VPCs don't route traffic directly to the internet or to each other - instead, their route tables send relevant traffic to a Transit Gateway attachment, which forwards it into a dedicated inspection VPC running firewall appliances.

The inspection VPC evaluates the traffic against its security policy, then either drops it or forwards it onward - to the internet via its own NAT/Internet Gateway for egress traffic, or back through the Transit Gateway to another spoke VPC for east-west traffic between spokes.

This requires careful Transit Gateway route table design: spoke route tables send default routes to the inspection VPC's attachment, while the inspection VPC's own route table sends default routes onward to egress infrastructure, and the return leg has to traverse the same appliance to avoid the asymmetric routing problem covered earlier.

flowchart LR
  A["Spoke VPC A"] -->|Default route| B["Transit Gateway"]
  B --> C["Inspection VPC firewall appliance"]
  C -->|Egress allowed| D["NAT/Internet Gateway"]
  C -->|Inter-spoke allowed| B
  B --> E["Spoke VPC B"]

The benefit is a single, consistently enforced policy point for all traffic leaving or moving between spokes, instead of replicating firewall rules and NAT infrastructure in every individual VPC.

Take quiz
In this architecture, where do spoke VPCs send their default route for internet-bound traffic?
To the Transit Gateway, which forwards it to the inspection VPC
Directly to their own Internet Gateway
Nowhere - spokes have no internet access at all
Directly to another spoke VPC
What is the main benefit of centralizing inspection this way?
It eliminates the need for a Transit Gateway
A single, consistent security policy point instead of duplicating firewall rules per VPC
It removes the need for any route tables
It automatically doubles available bandwidth

48. How can you optimize VPC Flow Logs for cost and security monitoring at scale?

Flow Logs at full verbosity across every ENI in a large environment generate a genuinely large volume of data, so scaling them well means being deliberate about what's captured and where it goes.

  1. Use the custom log format instead of the default fields, capturing only the fields your monitoring or SIEM actually consumes, which reduces both storage size and downstream processing cost.
  2. Send logs to S3 rather than CloudWatch Logs for high-volume, long-retention use cases, since S3 storage is materially cheaper, and use S3 lifecycle rules to transition older logs to Glacier for compliance retention.
  3. Enable Flow Logs at the VPC level rather than per-ENI where possible, since it's simpler to manage and consistently captures new resources without per-resource configuration drift.
  4. Filter to REJECT-only logs for certain use cases, like detecting scanning or misconfigured Security Groups, since rejected-traffic volume is usually far lower than the full ALL traffic capture.
  5. Aggregate logs from all accounts in an Organization into one central logging account, so security monitoring has a single place to query rather than assembling data from dozens of accounts.

The right mix depends on whether the goal is cost-efficient long-term compliance storage, active real-time threat detection, or both, since those two goals often call for different destinations and retention settings for the same underlying data.

Take quiz
Why might logging only REJECT traffic be useful for certain security use cases?
REJECT logs include full packet payloads
Rejected-traffic volume is typically much lower, making scanning/misconfiguration detection cheaper to monitor
It's the only log type AWS supports for VPCs
It captures more data than an ALL traffic log
Why is S3 often preferred over CloudWatch Logs for high-volume, long-retention Flow Logs?
S3 storage is materially cheaper, and lifecycle rules can transition old data to Glacier
S3 offers real-time alerting that CloudWatch Logs lacks
CloudWatch Logs cannot store Flow Logs at all
CloudWatch Logs has a hard 7-day retention limit

49. Explain the internal working of DNS resolution for a VPC endpoint with Private DNS enabled?

When Private DNS is enabled on an Interface endpoint, AWS automatically creates a Route 53 private hosted zone (or a record within one) matching the AWS service's standard public domain name, and associates that hosted zone with your VPC.

Because a private hosted zone takes priority over public DNS for any domain it's authoritative for, a lookup from inside the VPC for the service's normal public hostname - like secretsmanager.us-east-1.amazonaws.com - now resolves to the endpoint's private IP address instead of the service's actual public IP range.

This is what allows existing application code, SDKs, and configuration to keep using the exact same standard endpoint URL they always have, with zero code change required to start routing through the private endpoint.

flowchart LR
  A["App calls standard AWS service hostname"] --> B["VPC DNS Resolver"]
  B --> C{Private hosted zone matches domain?}
  C -- Yes, Private DNS enabled --> D["Resolves to Interface Endpoint's private IP"]
  C -- No, Private DNS disabled --> E["Resolves to service's public IP"]

Disabling Private DNS is sometimes intentional, in cases where you need to reach both the private endpoint (via its own endpoint-specific DNS name) and the public service simultaneously from the same VPC, since enabling it removes the option to resolve the standard hostname publicly.

Take quiz
What AWS resource does enabling Private DNS on an Interface endpoint automatically create or use?
A new Internet Gateway
A new Transit Gateway attachment
A second Elastic Network Interface
A Route 53 private hosted zone associated with the VPC
Why does Private DNS let existing application code work unchanged?
It disables DNS entirely, forcing hardcoded IPs
It requires the app to call a new SDK method
It rewrites the application's source code automatically
The standard public hostname now resolves privately, so no URL needs to change

50. How do you troubleshoot intermittent connectivity between two peered VPCs in different AWS Regions?

Intermittent, rather than total, failure between peered VPCs across Regions usually points to something environmental or capacity-related rather than a flat-out misconfiguration, since a hard misconfiguration would normally fail consistently.

  1. Confirm the peering connection is inter-Region (it uses encrypted AWS backbone links between Regions) and check whether either Region is showing any AWS Health Dashboard events for networking around the time of the drops.
  2. Check both VPCs' route tables for the peering connection - a route present in one direction but missing or stale in the other produces exactly this kind of asymmetric, intermittent-looking failure depending on which side initiates.
  3. Review Security Group and NACL rules on both ends for anything referencing the peer VPC's CIDR with a narrower range than intended, which can silently drop a subset of traffic while allowing the rest through.
  4. Pull VPC Flow Logs from both sides for the affected window and compare REJECT entries - a mismatch, where one side shows a clean send but the other shows a reject, usually isolates which side owns the problem.
  5. Rule out application-layer causes, like connection pool timeouts or DNS TTL issues unrelated to the network path itself, since not every "intermittent connectivity" report is actually a VPC networking problem.
aws ec2 describe-vpc-peering-connections \
  --vpc-peering-connection-ids pcx-0123456789abcdef0 \
  --region us-west-2

Take quiz
Why does intermittent (rather than total) failure often point away from a simple misconfiguration?
Intermittent failures are always caused by Security Groups specifically
Misconfigurations in AWS always resolve themselves after a few minutes
A hard misconfiguration would typically fail consistently, not intermittently
AWS guarantees all peering connections are 100% reliable
What does comparing Flow Logs from both sides of the peering connection help identify?
Which side is rejecting traffic that the other side shows as successfully sent
The billing cost of the peering connection
Whether Transit Gateway is also attached
The exact CIDR block size of each VPC
«
»

Comments & Discussions