Want to connect one AWS lambda which is in VPC to another lambda which is not in VPC but in same region and account.
Code of caller lambda "lambda_1":
@Override public String handleRequest(final Object input, final Context context) { logger.log(context.getFunctionName() + " invoked");
final AWSLambda client = AWSLambdaClientBuilder.standard().withRegion(Regions.EU_WEST_2).build(); final InvokeRequest request = new InvokeRequest(); request.withFunctionName("lambda_2").withPayload("JSON data as String").withInvocationType(InvocationType.RequestResponse); logger.log("Lambda is about to invoke"); final InvokeResult response = client.invoke(request); logger.log(context.getFunctionName() + " returned"); return input.toString();
}
AWS java sdk for lambda is used through maven dependency
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-lambda</artifactId>
<version>1.11.681</version>
</dependency>
- Allow: lambda:InvokeFunction is given to lambda_1 for lambda_2
- Code of callee lambda "lambda_2":
@Override public String handleRequest(final Object input, final Context context) {
logger.log(context.getFunctionName() + " invoked");
logger.log(context.getFunctionName() + " returned");
return input.toString();
}
- Logs get created for lambda_1 till Lambda is about to invoke line, execution doesn't go further and times up.
- Enough time and memory has been set for lambda_1, lambda_2 as 2 min 198 MB and 1 min 128 MB respectively.
- But Unable to call lambda_2 and even not getting any kind of error at runtime, kindly help thanks