Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can I call an on-VPC aws lambda from an off-VPC aws lambda but not vice versa?

So if I have two lambdas, one inside a private VPC, and one not on a VPC, calling the private lambda from inside the public lambda works but I cant call the public from the private lambda.

There's no NAT setup.

Why is this? It seems that I should not be able to call the private from the public theoretically.

like image 494
Dr. Chocolate Avatar asked Jan 10 '17 00:01

Dr. Chocolate


People also ask

Can you invoke a Lambda in a VPC?

You can call any of the Lambda API operations from your VPC. For example, you can invoke the Lambda function by calling the Invoke API from within your VPC. For the full list of Lambda APIs, see Actions in the Lambda API reference.

Can a Lambda call another Lambda in a VPC?

If your Lambda function is VPC attached, it needs to be able to communicate via your VPC to the AWS API. Lambdas do not talk to other Lambdas over the network, they initiate requests with the AWS API or an API Gateway, which passes the request on to the Lambda Function.

Can Lambda be outside of VPC?

By default, Lambda functions are not launched within a virtual private cloud (VPC), so they can only connect to public resources accessible through the internet.

How do I make Lambda available in multiple VPCs?

This is not possible with Lambda. Lambda functions can provide access only to one single VPC. If there are multiple subnets and are specified, then they must all be in the same VPC. You then can connect to the other VPCs by peering your VPCs.


1 Answers

In order to trigger a Lambda function, all that's required is for the caller to have outbound access to the Invoke AWS API. It is not necessary for the invoked Lambda function to have any open inbound ports, or any public Internet access.

So a public (non-VPC, has Internet access) Lambda function can call the Invoke API to trigger the private Lambda function, but the private VPC (no Internet access) Lambda function cannot access the Invoke API to trigger any Lambda function.

like image 194
wjordan Avatar answered Oct 22 '22 23:10

wjordan