Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
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
It is very important to tell NPM to skip installing chromium from
puppeteerpackage. 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.
or apply this ARN to your function directly:
Credits for this solution go to San Kumar
👤 Rafal Wilinski
Give a ⭐️ if this project helped you!