0

I have set up the local Lambda function (in Python) on my machine with the help of the SAM app and I also have installed the local MongoDB. I want to make a connection between the locally created Lambda function and MongoDB local.

My first question is "Is that possible to connect local MongoDB with local Lambda function?" If yes, then please elaborate on how to do it? Any guide or tutorial will be appreciated.

M Rehan
  • 13
  • 3
  • 1
    What programming language are you using? – Mark Sailes Jun 15 '22 at 12:40
  • I am using Python. – M Rehan Jun 15 '22 at 12:59
  • https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach – Alex Blex Jun 15 '22 at 13:29
  • @AlexBlex your suggested solution isn't relevant to my query. – M Rehan Jun 15 '22 at 13:38
  • Aren't you trying to connect from SAM docker to local mongo on the host system? It is possible, and there are answers for different hosts OS, as it really depends. BTW, welcome to stackoverflow, we don't ask recommendations for 3rd party libraries, tools, or tutorials here. – Alex Blex Jun 15 '22 at 13:56

1 Answers1

1

You can if you have mongoDB running in a docker container, I just recently figured this out the hard way.

docker pull mongo
docker run mongo

and then set the databaseuri for pymongo to mongodb://172.17.0.1:27017/'and it should connect.