Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.43 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.43 KB

PhantomJS wrapper for AWS Lambda

Simplify the usage of PhantomJS on AWS Lambda

$ npm install phantomjs-lambda-pack --save

Usage

'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!!');
    });
};

To Do

  1. Support phantomjs versioning, currently it just uses the latest of phatomjs-prebuilt
  2. Better support in the local environments, currently phantomjs needs to be installed in the path
  3. Check if the lambda memory requirements are met.

Notes

Use more memory at least 1024 and a timeout greater than 180 seconds Make sure to zip up the entire directory and ship it

Example

Basic Version Check using Serverless

Thanks

PhantomJS

AWS Lambda

PhantomJS-Prebuilt

Serverless