Attach Wit VPC

By default, the lambda function can not access the VPC resources. It is deployed outside of the VPC. Even we attach it along with the VPC, it will get the access to the VPC resources, but by default can not access the internet.

Access Resources

To get access to our VPC resources it uses ENI and access the VPC resources through it.

Access Internet

When it EC2 Instance, we can deploy it in a public subnet and it will get a public IP along with the internet access. But when it comes to Lambda function, even though we connect it with the public subnet ENI, it will not get a public IP and also not get the internet access.

To make sure a lambda function can access internet from the VPC we have to

After getting public internet access, we can access other AWS resource using public internet or using the AWS Private net (VPC Endpoints)