0
votes

On AWS, I created a new lambda function. I added a role to the lambda that has the policy, AWSLambdaVPCAccessExecutionRole. I placed the lambda in the same VPC as my EC2 instance and made sure the security group assigned to the lambda and EC2 instance have the same default VPC security group created by AWS which allows all traffic within the vpc. On my EC2 instance, I have a tomcat app running on port 8080. I tried to hit the URL by two methods in my lambda function:

  1. Using my load balancer, which has the same assigned security group
  2. Hitting the IP address of the EC2 box with port 8080

Both of these options do not work for the lambda function. I tried it on my local computer and it is fine.

Any suggestions?

Security Group for Inbound

  • Type = All Traffic
  • Protocol = All
  • Port Range = All
  • Source = Group ID of Security Group
1
Did you also create the Service role so lamda can assume the role? docs.aws.amazon.com/lambda/latest/dg/…strongjz
Yes, I verified this by going to the role, then Trust Relationships, clicked edit and under service, I had the following: "Service": "lambda.amazonaws.com"Ashwin Jacob
It should work as you have described. Could you please Edit your question and add the configuration of the Inbound Security Group on the EC2 instance?John Rotenstein
Added it to the original questionsAshwin Jacob

1 Answers

0
votes

has the security group 8080 port open to internet?

To connect Lambdas with VPC you can't use the default VPC, you have to create one with a nat gateway.

EDIT: Only if the Lambda fucntion needs to access to internet and VPC.