3

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

asked Apr 14, 2016 at 14:33
1

1 Answer 1

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.

answered Apr 14, 2016 at 17:27
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.