user3395339
user3395339

Reputation: 21

Lambda to access MongoDB of EC2

Here, I am having Lambda & EC2 Instance both are under same VPC & Subnet.

Both are having to save security group with the rule to allow inbound connection from same security group for all ports. Lambda is not able to access MongoDB when it is inside VPC.

If I try to take it out from VPC and open port for 0.0.0.0/0 then only it works.

I need the solution for this...

Upvotes: 2

Views: 811

Answers (1)

strongjz
strongjz

Reputation: 4491

Lambda needs an IAM role to manage the ENI to access the VPC.

AWS Lambda (AWS service role) – This role grants AWS Lambda permissions to assume the role.

AWSLambdaVPCAccessExecutionRole (access permissions policy) – This is the policy that you attach to the role. The policy grants permissions for the EC2 actions that AWS Lambda needs to manage ENIs. You can view this AWS managed policy in IAM console.

http://docs.aws.amazon.com/lambda/latest/dg/vpc.html

http://docs.aws.amazon.com/lambda/latest/dg/vpc-ec-create-iam-role.html

Upvotes: 1

Related Questions