Lambda Nodejs one line of code

Job ID: 31154142

Budget: $30 – $250 AUD

I am trying to get Ganache-CLI working on AWS Lambda. I've got a layer created with ganache-cli as a node module. I have a Lambda function using nodejs, which attempts to call the ganache module using exec().
The call hangs - it never completes, and then the lambda function reaches max duration and emits a timeout error.

This line appears to be the problem:
exec("node /opt/nodejs/node_modules/ganache-cli/cli.js", (error, stdout, stderr) => {

It seems like something simple is missing, but I don't know what it is.
I can supply you with the Lambda layer, and function code.
Please use your own AWS account to test and debug.

A successful outcome is when you run the basic default command to launch ganache: "node ganache-cli", and see the default output, which is something like:
"Ganache CLI v14" etc.

Please supply me with the working code at the end of your work.
That's all I need.

Lambda nodejs code that I am currently using:

exports.handler = async (event) => {
const promise = new Promise(function(resolve, reject) {
exec("node /opt/nodejs/node_modules/ganache-cli/cli.js", (error, stdout, stderr) => {
if (error) {
console.error(`error: ${error.message}`);
return 'Error running ganache.';
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return 'Error running ganache.';
}
console.log(`stdout: ${stdout}`);
return 'Executed ganache successfully.';
})
})
return promise
}


This line appears to be the problem:
exec("node /opt/nodejs/node_modules/ganache-cli/cli.js", (error, stdout, stderr) => {

Ganache module is installed via a Lambda layer at:
/opt/nodejs/node_modules/ganache-cli
Related categories: JavaScript Linux Amazon Web Services Node.js Aws Lambda