- 最新
- 投票最多
- 评论最多
SAM local invoke runs in a Docker container so you'll need to configure it so the Lambda in the Docker container can connect to localhost of the machine.
The way you configure this will depend on what OS you are running, you can refer to this closed issue for aws-sam-cli for more information. Here is also the Docker documentation if you are using Docker-for-mac or Docker-for-Windows or Docker-for-Linux.
I have resolved my issue. Whenever we are trying to connect our locally created SAM app with local MongoDB then we should set up our MongoDB on Docker. Then set the IP address of the container to the connection string.
Initially, I was trying this with localhost:
client = pymongo.MongoClient('mongodb://localhost:27017/')
What to change? We only have to use the IP address of the dockerized MonogoDB, and it will look like this:
client = pymongo.MongoClient('mongodb://172.17.0.2:27017/')
相关内容
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 10 个月前