Deploying AWS resources inside an Amazon VPC can be helpful when you do not want to expose your Lambda function over the internet or if you want your Lambda function to securely access your VPC resources. By default, the Lambda function is deployed in a non-VPC environment. To enable a Lambda function to access other AWS resources deployed in a private VPC, it is essential to provide details such as VPC, subnets, and security groups at the time of configuring it. VPC details are used by the Lambda function to create an Elastic Network Interface (ENI) to connect securely with other private VPCs.
When a Lambda function requires internet access, rather than deploying it in a public subnet, deploy it in a VPC in a private subnet with a Network Address Translation (NAT) gateway...