How to get headless Chrome running on AWS Lambda
An adventure in getting Chrome (read: Chromium) to run “serverless-ly” from compiling it to deploying it on AWS Lambda.
TL;DR
- Headless Chrome is a thing.
- You can run it on AWS Lambda (with some effort).
- This article walks you through how to compile and run it on Lambda.
- I created the serverless-chrome project so that you can immediately start using headless Chrome on Lambda instead of reading the rest of this article.
- Introduction
- Building headless Chrome for AWS Lambda
- Using headless Chrome in a Lambda function
- Is running Chrome on Lambda a good idea?
Introduction
I’ve done a number of projects in the past which, in some way, made use of PhantomJS. Usually something along the lines of testing, scraping, or for generating PDFs. When I came across NightmareJS (think CasperJS but with Electron instead of PhantomJS and less emphasis on testing) a few days ago, I wondered, “Can I use this to generate PDFs from a URL?” The answer to that was yes; with the .pdf() method. I’m a fan of AWS Lambda, “serverless” and FaaS in general and as a result the next thing I wondered was whether or not I could run NightmareJS on Lambda.