4

I premise I'm not a systemist nor network engineer. I'm trying to invoke a lambda function from another lambda function in the same vpc. My network configuration is:

  • 1 vpc
  • 1 public subnet and 1 private subnet
  • 2 route tables
  • 1 internet gateway
  • 1 security group

My lambda:

  • is attached to both subnets and to sec group;
  • connects to db and retrieves data;
  • invokes lambda function to send push notification.

But when the first one tries to invoke the second aws returns timeout exception. My idea is that the first one "can't see" the second.

How can I solve the problem?

Thanks

2 Answers 2

3

This is actually going to be as a result of the first Lambda (which is configured to use a VPC) has no outbound internet connectivity.

Ensure that you have either a NAT Gateway or a NAT instance that are attached to the route table(s) of the associated subnets.

If your function needs internet access, use network address translation (NAT). Connecting a function to a public subnet doesn't give it internet access or a public IP address.

You will need to remove the attachment to the public subnet as a Lambda cannot be assigned a public IP, therefore it cannot use an Internet Gateway.

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

9 Comments

Yes it will be charged
So the only free solution is to include the second lambda code in the first, right? Maybe with a function in a separate file
So either have your Lambda not in a VPC (if it does not need to connect to VPC resources), or yes you would need to merge the code
I think lambda needs VPC to connect to rds mysql
I sincerly don't understand why two lambdas in the same vpc have to exit to internet and enter again in the vpc to call each other
|
1

If the first Lambda function is invoked asynchronously, it can specify a Destination for sending an event at the completion of execution.

The destination can be another AWS Lambda function. This invocation is triggered by the AWS service and does not require Internet access from the first Lambda function (and is therefore cheaper than using a NAT Gateway).

See: Configuring destinations for asynchronous invocation

(I haven't tried it myself, but it should work!)

Comments

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.