Getting headless Chrome to run on AWS Lambda Node

Today I needed to update a couple Lambda functions from the Node 8 runtime to use the Node 10.x runtime. These functions required headless Chrome because they are used to take screenshots. Unfortunately, moving from the Node 8 runtime to 10x runtime is not a simple as it sounds, because AWS have decided to change the Linux environment which now excludes some files that Chromium requires to run.

As a reminder to myself, and for anyone else who might find it useful, I thought I’d document my setup here in a blog post. This post will assume you have the Serverless CLI set up and successfully deploying to AWS.


Getting WebSockets working with Node, and Elastic Beanstalk

Update December 12th 2021
This article only applies to Elastic Beanstalk environments using the old 'Node.js running on 64bit Amazon Linux' platform branch. Websockets work by default for Amazon Linux 2 environments.

This is something that took me nearly a year to get working. Not full time obviously, but every now and then I would make another attempt at getting it working after the trauma of the previous attempt had faded. None of the examples that people had provided worked for me, and some were out dated and no longer applied. And of course the AWS documentation provided no help whatsoever.

I decided to share my configuration in the hope that it will help someone else. Here is a list of the technologies I am using:

  • The app is a NodeJS app running on 6.11.X, soon to be 8.4.X
  • Using the Express server framework and for WebSockets
  • Using AWS Elastic Beanstalk
  • Nginx with reverse proxy to NodeJS
  • Using the newer Application Load Balancer
  • HTTPS is enabled
  • Front and back end running on same domain