I am developing a web app with AWS Lambda and API Gateway with Nodejs. When I run my api with localhost through serverless offline (pointing my production DB, on AWS RDS) everything works fine. However, when I deploy to AWS I get the following:
module initialization error: Error at new ConnectionManager (/var/task/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:29:15) at new PostgresDialect (/var/task/node_modules/sequelize/lib/dialects/postgres/index.js:14:30) at new Sequelize (/var/task/node_modules/sequelize/lib/sequelize.js:239:20) at Object. (/var/task/src/controllers/run-controller.js:4
I assume this means there is some issue connecting to the database. I have no issue hitting it with postman via localhost, but using my APIG url, the above error is thrown and shown in the cloudwatch logs.
Please let me know what other information I can provide!
Update Narrowing in on this a bit more, when I run a test in the lambda console against one of my functions, it shows the following:
"errorMessage": "Please install 'pg' module manually"
It seems my node modules are not available? Like I said, I'm using Serverless, does sls deploy not include node modules?
Update 2 Indeed there was an issue with the node module pg not being included in the package. I've added pg to be forced included with the following:
custom:
webpackIncludeModules:
forceInclude:
- pg
That resolves the above issue with needing to install pg manually. However, I'm now only getting timeouts from my deployed functions, but they still work locally.
rds-db is not a recognized serviceandconnect is not a recognized action... any suggestions? - Justin Kruse