Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RafalWilinski/serverless-puppeteer-layers
Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
https://github.com/RafalWilinski/serverless-puppeteer-layers
aws-lambda chrome headless layers puppeteer serverless
Last synced: 11 days ago
JSON representation
Serverless Framework + AWS Lambda Layers + Puppeteer = ❤️
- Host: GitHub
- URL: https://github.com/RafalWilinski/serverless-puppeteer-layers
- Owner: RafalWilinski
- Created: 2018-11-30T09:22:33.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-05T03:51:46.000Z (over 3 years ago)
- Last Synced: 2024-10-31T12:05:22.737Z (13 days ago)
- Topics: aws-lambda, chrome, headless, layers, puppeteer, serverless
- Language: JavaScript
- Homepage: https://dynobase.com
- Size: 80.9 MB
- Stars: 274
- Watchers: 7
- Forks: 36
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-layers - `RafalWilinski/serverless-puppeteer-layers`
README
# Serverless Puppeteer using AWS Lambda Layers
> Recently AWS introduced [Layers](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-lambda-now-supports-custom-runtimes-and-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](assets/demo.gif?raw=true '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:
```sh
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install
```or
```sh
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.
```sh
sls deploycurl ?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`
```sh
./download-latest.sh
```Credits for this solution go to [San Kumar](https://github.com/san-kumar)
### Author
👤 **Rafal Wilinski**
- Twitter: [@rafalwilinski](https://twitter.com/rafalwilinski)
- Github: [@RafalWilinski](https://github.com/RafalWilinski)### Show your support
Give a ⭐️ if this project helped you!