Interview Prep/Networking/Cloud networking: VPC, firewalls, NAT, VPN and proxies

A Lambda function attached to a VPC can reach RDS but times out on any call to the internet.

IntermediateTroubleshootingCloud networking: VPC, firewalls, NAT, VPN and proxies
Answer

Likely causes → Lambda ENIs in a VPC never get public IPs, even in a public subnet. Internet access needs the function in private subnets with a route to a NAT gateway (or VPC endpoints for AWS services).

Diagnose →

aws lambda get-function-configuration --function-name <fn> --query 'VpcConfig'
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=<subnet-id>

Fix → Move the function to private subnets with 0.0.0.0/0 → nat-xxxx, allow outbound in its SG, and add VPC endpoints for AWS APIs it calls (S3, DynamoDB, Secrets Manager) to avoid NAT costs.

Prevent → Only attach Lambda to a VPC when it needs private resources, and use a standard "private subnets with NAT" pattern when you do.

All Networking questions Roadmap: Networking for DevOps

More on Cloud networking: VPC, firewalls, NAT, VPN and proxies