Serverless Chrome contains everything you need to get started running headless Chrome on AWS Lambda (possibly Azure and GCP Functions soon).
The aim of this project is to provide the scaffolding for using Headless Chrome during a serverless function invocation. Serverless Chrome takes care of building and bundling the Chrome binaries and making sure Chrome is running when your serverless function executes. In addition, this project also provides a few example services for common patterns (e.g. taking a screenshot of a page, printing to PDF, some scraping, etc.)
Why? Because it's neat. It also opens up interesting possibilities for using the Chrome DevTools Protocol (and tools like Chromeless or Puppeteer) in serverless architectures and doing testing/CI, web-scraping, pre-rendering, etc.
- Quick Start
- The Project
- Documentation & Resources
- Articles & Tutorials
- Projects & Companies using serverless-chrome
- Change log
- Prior Art
"Bla bla bla! I just want to start coding!" No problem:
Using AWS Lambda, the quickest way to get started is with the Serverless-framework CLI.
serverless globally (
npm install -g serverless) and then:
serverless create -u https://github.com/adieuadieu/serverless-chrome/tree/master/examples/serverless-framework/aws
Then, you must configure your AWS credentials either by defining
AWS_SECRET_ACCESS_KEY environmental variables, or
using an AWS profile. You can read more about this on the
Serverless Credentials Guide.
In short, either:
export AWS_ACCESS_KEY_ID=<your-key-here> export AWS_SECRET_ACCESS_KEY=<your-secret-key-here>
Then, to deploy the service and all of its functions:
npm run deploy
Further details are available in the Serverless Lambda example.
This project contains:
- @serverless-chrome/lambda NPM package
A standalone module for AWS Lambda which bundles and launches Headless Chrome with support for local development. For use with—but not limited to—tools like Apex, Claudia.js, SAM Local, or Serverless.
- serverless-plugin-chrome NPM package
A plugin for Serverless-framework services which takes care of everything for you. You just write the code to drive Chrome.
- Example functions
- Serverless-framework AWS Lambda Node.js functions
- Serverless-framework AWS Lambda Node.js functions using
- Build Automation &
Build and release tooling shell scripts and Dockerfile for automating the build/release of headless Chrome for serverless environments (AWS Lambda).
A collection of example functions for different providers and frameworks.
- Print to PDF
- Capture Screenshot
- Page-load Request Logger
Documentation & Resources
Building Headless Chrome/Chromium
- Automated, regularly prebuilt binaries can be found on the
- adieuadieu/headless-chromium-for-aws-lambda Docker image
- Documentation on building your own binaries
- Medium article on how to do build from scratch. This was the origin of this project.
npm test. Each package also contains it's own integration tests
which can be run with
npm run test:integration.
Articles & Tutorials
A collection of articles and tutorials written by others on using serverless-chrome
- AWS DevOps Blog — UI Testing at Scale with AWS Lambda
- Running puppeteer and headless chrome on AWS lambda with Serverless
- Will it blend? Or how to run Google Chrome in AWS Lambda
- Running Selenium and Headless Chrome on AWS Lambda
- AWS Lambda上のheadless chromeをPythonで動かす
- AWS Lambda上でpuppeteerを動かして、スクレイピングする
- serverless-chrome で日本語を表示できるようにする
Can't get Selenium / ChromeDriver to workMake sure that the versions of serverless-chrome, chromedriver, and Selenium are compatible. More details in [#133](https://github.com/adieuadieu/serverless-chrome/issues/133#issuecomment-382743975).
- Support for Google Cloud Functions
- Example for Apex
- Example for Claudia.js
- DOM manipulation and scraping example handler
- Support for Azure Functions
- Headless Firefox
Projects & Companies using serverless-chrome
Tell us about your project on the Wiki!
See the CHANGELOG
OMG. Yes. Plz, halp meeee.
This project was inspired in various ways by the following projects: