0

I'm trying to connect to MongoDB-Atlas using Lambda. Locally the code runs perfectly, but using AWS Lambda I get errors related to SSL dependencies (I think...).

I want to use mongodump, so I added the latest version of mongodump binary, version r3.6.3, and I also added libssl.so.1.0.0, libsasl2.so.3, libgo.so.9 and libcrypto.so.1.0.0. All of them are in the root of the folder that I uploaded to Lambda.

This is how my relevant mongo query inside the code looks like:

mongodump -d test -u adminUser -p "notmyrealpassword" -o "/tmp/FriApr062018_1523037710445/" --authenticationDatabase admin --ssl --port 27017 -h "host0.mongodb.net,host1.mongodb.net,host2.mongodb.net"

This is how the folder looks like:

index.js  libcrypto.so.1.0.0  libgo.so.9  libsasl2.so.3  libssl.so.1.0.0  mongodump  node_modules  package.json

When I try to run it using Lambda I get this error (again, the code runs fine on a local machine):

/var/task/mongodump: /var/task/libssl.so.1.0.0: no version information available (required by /var/task/mongodump)
/var/task/mongodump: /var/task/libcrypto.so.1.0.0: no version information available (required by /var/task/mongodump)
Tal Delbari
  • 121
  • 2
  • 4

1 Answers1

0

You'll need to set the LD_LIBRARY_PATH environment variable to the directory that contains your shared object files, so mongodump knows where to find them. See this Stack Exchange answer for other ways to tell mongodump where to look for shared object files. Edit - It looks like it's able to find the shared objects, just not run them, so this probably isn't the problem.

If you have errors after mongodump is able to find them, double check that your shared object files are built in an environment compatible with the currently used Amazon Linux AMI that Lambda functions run in.

From the no version information available error and a StackOverflow answer about what that error means, it sounds like the OpenSSL libssl and libcrypto shared objects were likely built using a major.minor.patch version that's greater than what's available on the Amazon Linux AMI. As a result, you'll probably need to build them yourself so that they're compatible in the target OS. This article discusses a few reasonable ways to do that. It's for a python project, but should be adaptable to building the C modules as well.

Tom
  • 1,660
  • 8
  • 16
  • If I understand correctly, your solution is for a situation when mongodump can't locate the files. However, in my case the files are remote and mongodump is able to find them and save them, but when i'm using lambda it is unable to connect... – Tal Delbari Apr 23 '18 at 12:02
  • That's a good point; my first paragraph would be applicable if it were a `No such file or directory` error instead. I've updated my answer with some more details that may help you fix the `no version information available` error specifically. – Tom Apr 24 '18 at 04:53