AWS Lambda and VPC Configuration
Instruction: How does configuring AWS Lambda with a VPC affect its behavior, and what are the benefits?
Updated
Official answer
For ordinary Lambda Event Functions, execution already occurs in a Lambda-managed VPC. Configuring a customer VPC gives the function connectivity to selected private resources through Hyperplane network interfaces; it does not move the execution host into a customer-managed subnet.
For example, to access a private RDS database, select suitable subnets and a function security group. Permit the database port from that security group at the database, and verify routes, DNS and credentials. The function's execution role needs the required network-interface permissions for VPC configuration.
VPC attachment changes outbound connectivity. A public subnet does not give the function a public IP address or internet access. For IPv4 internet access, use an appropriate private-subnet route through a NAT gateway or other supported egress design. Supported VPC endpoints can provide private access to AWS services; their policies, DNS and routing still matter. IPv6 has separate dual-stack requirements.
VPC attachment does not by itself restrict the Lambda invocation API, an API Gateway endpoint or a function URL. Configure invocation and application authorization separately. Choose VPC access because of resource reachability or network policy, then evaluate latency, availability and networking cost; it is not an automatic performance or security improvement.