1

Can lambda be accessed privately from a vpc? Let's say I want to invoke a lambda function from a python code running on a EC2 server in a private subnet, can I invoke it without going over internet?

1
  • Hi. I updated the answer. As of today (20 Oct 2020) you can invoke lambda privately, without internet. Commented Oct 21, 2020 at 4:57

2 Answers 2

1

Update 20 Oct 2020

As of today, lambda has VPC interface endpoints:

AWS Lambda now supports AWS PrivateLink which lets you invoke Lambda functions securely from inside your virtual private cloud (VPC) or on-premises data centers without exposing traffic to the public Internet.

Previous answer which was valid at the time of making it

To my is no direct way of doing this.

Lambda VPC integration is only for lambda to access VPC resources, not for VPC resources (e.g. ec2 instance in private subnet) to invoke lambda function. The reason is that Lambda invocation can come from only AWS Lambda API.

Also since lambda does not have VPC endpoint, you can't call it from a private subnet without a NAT gateway.

Sign up to request clarification or add additional context in comments.

2 Comments

This is now possible, as of today: aws.amazon.com/blogs/aws/…
@Ben Thanks ben. That's good news. I will update my answer.
1

Yes you can, take a read at Lambda with VPC Networking.

By doing this an ENI would be created in your VPC, within the subnets that you specify. This ENI will be bound to any Lambda invocations, ensuring that network transit will only reside from these VPCs.

Once its in the VPC you could put it behind an internal ALB, allowing your Python script to perform an interaction against the ALB which will invoke the Lambda privately.

1 Comment

Thanks, I am aware of lambda vpc networking. But AFAIK when you configure the ALB with lambda as target, there is no guarantee that the traffic will flow privately. Is there a document which mentions otherwise?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.