Mongodb timeout error on AWS Lambda

Alright, at least we have a clue to follow.

There is this statement on the following page: Manage Connections with AWS Lambda — MongoDB Atlas

Don’t define a new MongoClient object each time you invoke your function. Doing so causes the driver to create a new database connection with each function call. This can be expensive and can result in your application exceeding database connection limits.

if you haven’t tried it yet, check if it helps.