Interview Prep/AWS/ECS, EKS, ECR and Lambda

A Lambda function was moved into a VPC, and now every AWS SDK call hangs until timeout.

IntermediateTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → Lambda ENIs in a VPC never get public IPs, even in public subnets. Without a NAT gateway or VPC endpoints, the function cannot reach AWS APIs or the internet.

Diagnose →

aws lambda get-function-configuration --function-name worker --query 'VpcConfig'
aws ec2 describe-route-tables --filters Name=association.subnet-id,Values=subnet-0priv --query 'RouteTables[].Routes'

Fix →

  1. Put the function in private subnets with a route to a NAT gateway
  2. Or add interface or gateway endpoints for the services it calls (S3, DynamoDB gateway endpoints are free)
  3. Allow outbound 443 in the function's SG

Prevent → Only attach Lambda to a VPC when it needs private resources, and always pair that with endpoints or NAT.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda