Need help with serverless-puppeteer-layers?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

RafalWilinski
239 Stars 34 Forks 18 Commits 4 Opened issues

Description

Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️

Services available

!
?

Need anything else?

Contributors list

# 5,897
JavaScr...
Amazon ...
serverl...
aws-lam...
10 commits
# 416,940
JavaScr...
aws-lam...
headles...
Chrome
1 commit
# 422,901
JavaScr...
aws-lam...
headles...
Chrome
1 commit
# 419,853
HTML
CSS
aws-lam...
headles...
1 commit

Serverless Puppeteer using AWS Lambda Layers

Twitter: rafalwilinski

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

or

PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn

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

After that, you can simply deploy your funciton.

sls deploy

curl ?address=https://google.com

or apply this ARN to your function directly:

arn:aws:lambda:us-east-1:085108115628:layer:chrome:6

Bundling latest Chromium on your own

Prerequisites:

  • brotli
./download-latest.sh

Credits for this solution go to San Kumar

Author

👤 Rafal Wilinski

Show your support

Give a ⭐️ if this project helped you!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.