Skip to content

fartashh/lambda-screenshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-Screenshot

A simple working example of an AWS Lambda Screenshot service using Node and PhantomJS. Owes a debt to lambda-node-phantom by Tyler Pachal.

Running locally

You can run this locally using lambda-local.

npm install aws-sdk -save
npm install -g lambda-local

You'll also have to export your AWS credentials if you want to save to S3:

export AWS_ACCESS_KEY_ID=whatever
export AWS_SECRET_ACCESS_KEY=whatever

And you'll want to manually set the phantom binary in index.js to the OSX version if you're using OSX (sorry):

var PHANTOM_BINARY = 'phantomjs_osx';

Finally, once all that is done:

lambda-local -l index.js -h handler -e ./local-input.json -t 30

Running on AWS Lambda

Few things:

  1. Zip up index.js, phantom-script.js and phantomjs_linux-x86_64 and upload them as a zipfile to Lambda. Be sure the PHANTOM_BINARY variable in index.js is set to phantomjs_linux-x86_64.

  2. Set the function's role to lambda_s3_exec_role so it can interface with S3.

  3. Choose the "CloudWatch Events - Schedule" event source if you want to run it on something resembling a cron.

Questions?

Contact Fartash: [email protected]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published