How to use phantomjs 2.0 in AWS Lambda

i folded phantom binary system from https://github.com/bprodoehl/phantomjs/releases/ , check my local host perfectly.

and create aws function lambda

exports.handler = function (event, context) {
    var path = require("path");
    var Process = require("child_process");

    Process.exec(path.join(__dirname,"./bin/phantomjs")+" --version", function (err, data) {
        if (err) {
            console.log(err.message);
            context.fail(err.stack);
        } else {
            context.succeed(data);
        }

    })
}

but when the test in lambda, always got

{"errorMessage":"Error: Command failed: /bin/sh: /var/task/bin/phantomjs: Permission denied

    at ChildProcess.exithandler (child_process.js:658:15)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Socket.<anonymous> (child_process.js:979:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)"}

Does anyone have an idea? thanks

+4
source share
1 answer

, , Lambda " ", . , , , , PhantomJs ( + ), , , , .

, https://PhantomJsCloud.com . (: )

Lambda, : https://github.com/justengland/phantom-lambda-template

+2

Source: https://habr.com/ru/post/1614408/


All Articles