简体   繁体   中英

communicate with mongodb from aws lambda function

I have created a lambda function and executed a program which include numpy by uploading zip file and it executed successfully.

but when I connect the mongodb using public ip then it throughing exception as "time out". Please help me . thanks in advance.

The problem is that your Lambda function is unable to connect to your EC2 instance which is running MongoDB.

This is most likely a SecurityGroup issue.

You should allow your lambda VPC to connect to your EC2 instance. In essence it means that you will assign a VPC, subnet and Security group to your lambda. Afterwards you can allow the security group of the lambda to access the security group of your mongo.

Detailed instructions on how to add a vpc/subnet/sg to your lambda can be found here

You add VPC information to your Lambda function configuration using the VpcConfig parameter, either at the time you create a Lambda function (see CreateFunction), or you can add it to the existing Lambda function configuration (see UpdateFunctionConfiguration).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM