Reputation: 233
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?
Upvotes: 1
Views: 958
Reputation: 238051
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.
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.
Upvotes: 1
Reputation: 35146
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.
Upvotes: 1