AWS › Lambda & Serverless
How does Lambda support running functions within a VPC, and what performance considerations does this introduce compared to functions that do not need VPC access?
AdvancedAnswer
Lambda functions can be configured to run within a specific VPC, which is necessary when the function needs to access resources like an RDS database or ElastiCache cluster that are not publicly accessible, and while modern Lambda VPC networking has significantly improved cold start performance compared to older implementations, functions still need properly configured subnets with sufficient available IP addresses and appropriate route tables if they also need outbound internet access through a NAT Gateway.
aws lambda update-function-configuration --function-name my-function --vpc-config SubnetIds=subnet-12345,SecurityGroupIds=sg-12345Real-world example A Lambda function needing to query a private RDS database is configured to run within the same VPC as that database, using a properly sized subnet to avoid IP address exhaustion issues during periods of high concurrent execution.