ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Issues with setting up the driver on AWS Lambda #912

Closed jishnuraghu closed 1 year ago

jishnuraghu commented 1 year ago

I have a nodejs based lambda function which talks to the DB2 database. The code works fine in local. In AWS I get the following error.

"errorMessage": "libnode.so.72: cannot open shared object file: No such file or directory",
  "stackTrace": [
    "    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)",
    "    at Module.load (internal/modules/cjs/loader.js:863:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
    "    at Module.require (internal/modules/cjs/loader.js:887:19)",
    "    at require (internal/modules/cjs/helpers.js:74:18)",
    "    at bindings (/opt/nodejs/node_modules/bindings/bindings.js:112:48)",
    "    at Object.<anonymous> (/opt/nodejs/node_modules/ibm_db/lib/odbc.js:57:31)",
    "    at Module._compile (internal/modules/cjs/loader.js:999:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
    "    at Module.load (internal/modules/cjs/loader.js:863:32)"

This is what I have done so far

  1. Create a custom runtime configuration while defining the lambda function.
  2. Use nodejs 12 layer as mentioned here - https://github.com/lambci/node-custom-lambda
  3. Another layer which contains the linux based db2 drivers which is created by doing npm i from a linux machine followed by zipping to nodejs directory.
  4. License file db2consv_zs.lic is copied to the node_modules/ibm_db/installer/clidriver/license folder

Can someone help me please? @bimalkjha It will be great if the instructions to use the this in AWS Lambda is provided. Couldn't find a reliable working set anywhere.

bimalkjha commented 1 year ago

@devuser-2048 Please check node -v command is working inside AWS or not? libnode.so.72 is a nodejs library. Also, I hope you have installed make, gcc, g++(gcc-c++), python and nodejs on your AWS system.

Please share complete output of npm install ibm_db command executed on AWS. Thanks.

jishnuraghu commented 1 year ago

I didn't run these on AWS. I ran it on my Linux desktop and then created a layer out of it. In case of AWS Lambda, we don't have option to do npm install ibm_db right? Can we create the complete layer with required node runtime in local linux (Ubuntu) system?

bimalkjha commented 1 year ago

@devuser-2048 You need to login to AWS EC2 instance and check. Good to check these closed issues https://github.com/ibmdb/node-ibm_db/issues?q=is%3Aissue+is%3Aclosed+lambda which was opened for aws lambda only and users are able to run application. Installing make gcc gcc-c++ kernel-devel openssl-devel bzip2-devel on the system is a pre-requirement and node.js should also run properly. Make sure you have installed node.js of right Operating System on AWS. Thanks.

bimalkjha commented 1 year ago

@devuser-2048 We have options to run npm install ibm_db on lambda too. I can see in one post, user is running command on bash shell and in another issue, user has corrected permission of node_modules directory. But, in your case, you are getting error for libnode.so.72 library which is a node.js library and not an ibm_db library. To get libnode.so.72, you need to install libnode72 package on your system using command sudo apt install libnode72. Same issue has been reported on below links with solution: https://stackoverflow.com/questions/69378783/node-error-while-loading-shared-libraries-libnode-so-72 https://forum.edgeimpulse.com/t/error-libnode-so-72-cannot-open-shared-object-file-no-such-file-or-directory-edge-impulse-daemon/5153/2 All links says - installing libnode72 package has solved the issue. Probably you need to use AWS Lambda Console for it. Thanks.

bimalkjha commented 11 months ago

From: DevUser notifications@github.com Sent: Tuesday, July 18, 2023 12:42 PM Was able to get this working using EFS and having the required dependency libraries