Home

Awesome

Headless browser PhantomJS AWS Lambda Layer

This layer contains PhantomJS headless browser which can be used for screen capture, page automation and headless web testing. Full feature list and use cases can be found here: For full feature list see this: https://github.com/ariya/phantomjs#use-cases

Usage

  1. Just pick up an ARN from the list below, include it in your lambda function.
  2. Add the layer binaries in PATH like this
    export PATH="/opt/phantom-js/bin/:$PATH"; # Add the layer in the path
    
  3. Use it in your program like this (We are taking a screenshot here)
    rasterize "$html_filename" "$screenshot"; # Read the html file and create screenshot
    

Layer ARN

AWS RegionLayer ARN
us-east-1arn:aws:lambda:us-east-1:699054759624:layer:phantom-js:7
us-east-2arn:aws:lambda:us-east-2:699054759624:layer:phantom-js:2
us-west-1arn:aws:lambda:us-west-1:699054759624:layer:phantom-js:2
us-west-2arn:aws:lambda:us-west-2:699054759624:layer:phantom-js:1
ap-south-1arn:aws:lambda:ap-south-1:699054759624:layer:phantom-js:1
ap-northeast-2arn:aws:lambda:ap-northeast-2:699054759624:layer:phantom-js:1
ap-southeast-1arn:aws:lambda:ap-southeast-1:699054759624:layer:phantom-js:1
ap-southeast-2arn:aws:lambda:ap-southeast-2:699054759624:layer:phantom-js:15
ap-northeast-1arn:aws:lambda:ap-northeast-1:699054759624:layer:phantom-js:1
ca-central-1arn:aws:lambda:ca-central-1:699054759624:layer:phantom-js:1
eu-central-1arn:aws:lambda:eu-central-1:699054759624:layer:phantom-js:1
eu-west-1arn:aws:lambda:eu-west-1:699054759624:layer:phantom-js:1
eu-west-2arn:aws:lambda:eu-west-2:699054759624:layer:phantom-js:1
eu-west-3arn:aws:lambda:eu-west-3:699054759624:layer:phantom-js:1
eu-north-1arn:aws:lambda:eu-north-1:699054759624:layer:phantom-js:1
sa-east-1arn:aws:lambda:sa-east-1:699054759624:layer:phantom-js:3

Note: As of now, it only supports takings screenshots using rasterize command but can be expanded to do other stuff too very easily. Pull requests are welcome.

Why Version Numbers are fucked up?

Yeah, I tried resetting them by deleting all of them. Turns out AWS don't reset them even after deleting. More here on stackoverflow