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.

Marco Lüthy
14 min readMar 17, 2017

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.
  1. Introduction
  2. Building headless Chrome for AWS Lambda
  3. Using headless Chrome in a Lambda function
  4. 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.

--

--

Marco Lüthy

Hi there! I’m Marco. I write mostly about software development, sometimes about books I’ve read, and occasionally something else to keep things interesting.