0

I have two simple lambda functions. Lambda 1 is invoking lambda 2 (both do a simple print for text).

If both lambdas are outside of a VPC then the invocation succeeds, however as soon as I set them both in to access a VPC (I need to test within a VPC as the full process will be wtihin a VPC) the invocation times out.

Do I have to give my lambda access to the internet to be able invoke a second lambda within the same VPC?

3
  • An AWS Lambda invokes a second lambda via the AWS API which is external, the calling lambda will need an outbound path to the internet to be able to access the API Commented Jun 4, 2019 at 5:54
  • How is Lambda1 invoked? How does Lambda1 invoke Lambda2? When you say "you put them both in a VPC" Lambdas are serverless and they can't be "put" inside of your VPCs. Can you please add more details of exactly how your Lambdas are invoked and the setup of your VPC and we can help you troubleshoot and solve this problem. Commented Jun 4, 2019 at 7:27
  • @Taterhead - At the moment the lambda is invoked by the test button in the AWS lambda dashboard (I am just trying to get a very basic process to work before I put the more complicated code into the functions. In regard to 'put', that is probably a poor choice of words on my part, 'access' would probably be a better choice of word. Commented Jun 4, 2019 at 9:17

2 Answers 2

1

If your lambda functions are inside a VPC you need to configure your both lambda functions into private subnet not public subnet. That is the AWS recommended way.

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

1 Comment

Thanks @Visuddha. I will have a read of the doucmentation and see if I can get it to work.
0

If you are invoking the second Lambda from the first using Amazon API Gateway, then your Lambda will need to have access to the internet. Follow this guide to configure a NAT Gateway (last step).

regarding the VPC: in order to connect to your VPC and access resources there, the Lambdas must reside in the same region as your VPC and also be configured access to your VPC.

Please follow the steps provided in this AWS Guide: Configuring a Lambda Function to Access Resources in an Amazon VPC. This guide advises to use AWS CLI commands to do this and does not show how to configure it through the console.

You will need to be familiar with Amazon networking particulars (VPCs, Security Groups and Subnets), IAM security for the VPC and have a CLI environment setup. You are going to grant the Lambda Function access to this VPC using IDs and IAM execution roles via the CLI.

1 Comment

Both lambdas are both configured to have permissions to execute resources within the VPC via IAM (first lambda also have the invokeLamba polict attached to it). The first lambda has also been set up to use a security group specfically created to be able provide an outbound path to the internet so that can access the AWS API to be able to invoke the second lambda

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.