Note: It's a best practice to place Lambda functions in an Amazon VPC only if the function must access other resources in the Amazon VPC.
Grant internet access to a Lambda function in an Amazon VPC
Internet access from a private subnet requires NAT. To grant internet access to a Lambda function that's connected to an Amazon VPC, route its outbound traffic to a NAT gateway or NAT instance in a public subnet. Make sure that the NAT gateway or NAT instance has a route to an internet gateway.
Associate the NAT gateway or instance with an Elastic IP address
Associate an Elastic IP address with the public NAT gateway or instance. The NAT gateway or instance replaces the source IP address of the instances with the Elastic IP address. This Elastic IP address can be assumed as the static IP address for the Lambda function.
Note:
It's a best practice to create multiple subnets across different Availability Zones. This practice creates redundancy and allows the Lambda service to maintain high availability for your function.
Elastic IP addresses can be associated only with a public NAT gateway or instance. They can't be associated with a private NAT gateway or instance.
The default quota limit for Elastic IP addresses per public NAT gateway is 2. However, you can request a quota increase up to 8. For more information, see Elastic IP addresses.