- Newest
- Most votes
- Most comments
Yes, when you attach a Lambda function to a VPC without internet access, it will lose connection to both ECR repositories and the internet in general. By default, Lambda functions have access to the public internet, but when you attach a function to a VPC, it can only access resources available within that VPC.
For your Lambda function to continue accessing ECR repositories while being connected to a VPC, you would need to implement one of these solutions:
-
Configure your VPC to have internet access by setting up a NAT Gateway in a public subnet and configuring the route table of your private subnet to route internet-bound traffic through the NAT Gateway.
-
Create VPC endpoints for the AWS services you need to access, including ECR. This allows your Lambda function to privately access these services without traversing the public internet.
It's important to note that Lambda functions don't actually run in your VPC - they run in the Lambda service VPC. When you configure a Lambda for VPC access, AWS creates an Elastic Network Interface (ENI) in your VPC and routes all the Lambda's network traffic via that ENI. This is why the function loses direct internet access when attached to a VPC without proper internet connectivity configuration.
Sources
Giving Lambda functions access to resources in an Amazon VPC - AWS Lambda
Connecting Lambda inside a VPC to resources outside a VPC | AWS re:Post
About API Gateway Websocket and Lambda Invoke in VPC | AWS re:Post
Relevant content
asked 2 years ago
