Closed tychodev321 closed 2 years ago
Turns out the issue was that on AWS I was passing in an incorrect APP_NAME variable when the database is being created. I corrected the APP_NAME variable and the database query works as expected. Lots of lessons learned here for myself...
Bug
I have a FastAPI setup with Odmantic and Mangum. I use Mangum when the API is deployed to AWS Lambda, and when I run the API locally I use "python app.py". Locally, I have no issues reading and writing data to my MongoDB Atlas cluster using Odmantic. When I run the same code in AWS Lambda, I don't get any results from the database, it always returns None. I don't get any errors as well, I am not able to tell if there is an issue with the connection or the AWS Lambda environment.
The AWS Lambda is not in a VPC and I am using Serverless Framework and the Amazon 2 Linux Docker Image to deploy the code.
Current Behavior
Reads using Odmantic on AWS Lambda returns no data and no error message.
Expected behavior
For reads with Odmantic to return an item from the database or raise an error.
Environment
Locally - Everything works as expected. AWS Lambda - I see no item returned or error is thrown.
Code
Poetry
Database Engine Class
Movie Object
Resource Class
App.py
Serverless Framework Yaml