Beginner LevelCloud Computing (AWS/GCP/Azure)
What is a Virtual Private Cloud (VPC) and how do Public Subnets, Private Subnets, and NAT Gateways interact?
❓ Interview Prompt: Explain AWS VPC network isolation, CIDR blocks, Public Subnets (IGW), Private Subnets, and NAT Gateway outbound internet routing.
An Amazon VPC (Virtual Private Cloud) is a logically isolated virtual network dedicated to your AWS account.
Network Components:
1
CIDR Block: Defines the IP address range for the VPC (e.g. '10.0.0.0/16' providing 65,536 private IP addresses).
2
Public Subnet: Subnet with a route to an Internet Gateway (IGW). Resources (ALB, Bastion hosts) possess public IP addresses and can receive direct inbound internet traffic.
3
Private Subnet: Subnet with no direct route to the internet. Hosts private resources (databases, internal app servers).
4
NAT Gateway: Deployed in a Public Subnet to allow private subnet instances to initiate outbound internet requests (for software updates) while blocking all unrequested inbound connections from the internet!
Code Implementation Example
hcl
# Route table entry directing private subnet traffic through NAT Gateway
resource "aws_route_table" "private" {
vpc_id = aws_vpc.main.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.main.id # Outbound internet via NAT Gateway
}
}💡Terraform private subnet route table directing internet traffic through NAT Gateway.
🎯 Interview Key Takeaway
Public subnets route through Internet Gateways for inbound traffic; Private subnets route outbound via NAT Gateways.
#VPC#Networking#NAT Gateway#Subnets#Beginner
Back to all Cloud Computing (AWS/GCP/Azure) Questions→