I am new to AWS Lambda. I am trying to invoke a basic "Hello World" shell script from an AWS Lambda function coded in node.js.
run.js file contains the following:
#!/bin/bash
echo "Hello, World!"
I have also coded the function by storign it in an index.js file containing the following:
var exec = require('child_process').exec;
exports.handler = function(event, context) {
exec('./run.sh' , function(error, stdout) {
context.done(error, stdout);
});
};
I have created a zip file containing both files and have uploaded it to AWS Lambda console by creating a new Lambda function and granting it a lambda_basic_execution role.
I was expecting to be able to see the Hello World, have tried variations of this code but so far have been unable to call a shell script from an AWS Lambda function.
Thanks in advance!
Andy
-
1Have you read this? aws.amazon.com/blogs/compute/running-executables-in-aws-lambdaMark B– Mark B2016年04月14日 14:39:54 +00:00Commented Apr 14, 2016 at 14:39
1 Answer 1
Lambda only supports child_process.spawn and child_process.spawnSync. Try changing your call to child_process.exec and that should fix it for you.
Comments
Explore related questions
See similar questions with these tags.