Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
Switch branches/tags
Nothing to show
Clone or download
Latest commit 3d1d780 Dec 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Add demo.gif Nov 30, 2018
layer Initial commit Nov 30, 2018
.gitignore Add demo.gif Nov 30, 2018
README.md Update README.md Dec 13, 2018
handler.js Remove extra dependency Nov 30, 2018
package-lock.json Initial commit Nov 30, 2018
package.json Add package.json Dec 3, 2018
serverless.yml Initial commit Nov 30, 2018

README.md

Serverless Puppeteer using AWS Lambda Layers

Recently AWS introduced Layers which enables sharing common code between functions and working with large dependencies (such as headless chrome) much easier.

This project example returns a screenshot of page requested via ?address= query parameter.

Demo

Usage

It is very important to tell NPM to skip installing chromium from puppeteer package. To do so, installing dependencies should be done using this command:

PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install

Without this, your function size would be more than 200MB which is way too much.

After that, you can simply deploy your funciton.

serverless deploy

curl <DEPLOYED_ENDPOINT>?address=https://google.com

or apply this ARN to your function directly: arn:aws:lambda:us-east-1:085108115628:layer:chrome:6