Simplify the usage of PhantomJS on AWS Lambda
$ npm install phantomjs-lambda-pack --save
'use strict';
const phantomjsLambdaPack = require('phantomjs-lambda-pack');
const exec = phantomjsLambdaPack.exec;
exports.handler = (event, context, callback) => {
exec('-v', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`phantom version: ${stdout}`);
console.log(`Should have no error: ${stderr}`);
callback(error, 'fin!!');
});
};
- Support phantomjs versioning, currently it just uses the latest of phatomjs-prebuilt
- Better support in the local environments, currently phantomjs needs to be installed in the path
- Check if the lambda memory requirements are met.
Use more memory at least 1024 and a timeout greater than 180 seconds Make sure to zip up the entire directory and ship it