While migrating some AWS Lambda Functions between AWS
accounts, I had to do the inevitable: re-create the Layers
for the respective functions. While doing so, I remembered
that there are a handful of public layers that I used in
production environments in the past (e.g.
chrome-aws-lambda
, wkhtmltopdf
)
that I never had to compile, add to AWS, etc.
This got me thinking that the layers I'm using for my functions might be useful for others. So I'm going to list them below (along with their public ARN so that anyone can use them). You'll also find a bit of context when required (e.g. object instantiation instructions).
I'll try and maintain this page as I add more NPM libraries to my AWS Lambda Functions, or if I use other public Layers.
Node.js 18
or Node.js 20
. Public
region availablity is currently limited to
us-west-2
. Please email me if you'd like any of
the layers available in another region:
onassar@gmail.com
cheerio v1.0.0-rc10
- Library name: Cheerio JS (GitHub, NPM, website)
-
Version:
v1.0.0-rc10
- Description: HTML parsing
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:cheerio-v1_0_0-rc10:5
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import cheerio from '/opt/node_modules/cheerio/lib/index.js';
export const handler = async function(event, context, callback) {
cheerio.load('content');
};
chromium v119.0.2
- Library name: Chromium (GitHub, NPM, website)
-
Version:
v119.0.2
- Description: Open source browser
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:chromium-v119_0_2:1
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: This ARN is using a specifically compiled one by @Sparticuz
- Instantiation:
import chromium from "@sparticuz/chromium";
export const handler = async function(event, context, callback) {
console.log(await chromium.executablePath());
};
follow-redirects v1.14.6
- Library name: Follow Redirects (GitHub, NPM)
-
Version:
v1.14.6
- Description: Redirect following
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:follow_redirects-v1_14_6:5
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import pkg from '/opt/node_modules/follow-redirects/index.js';
const {http, https} = pkg;
export const handler = async function(event, context, callback) {
https.request(url, options, callback);
};
jszip v3.10.1
- Library name: JSZip (GitHub, NPM, website)
-
Version:
v3.10.1
- Description: Create, read and edit .zip files
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:jszip-v3_10_1:5
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import * as JSZip from '/opt/node_modules/jszip/lib/index.js';
export const handler = async function(event, context, callback) {
var zip = new JSZip.default();
};
puppeteer-core v21.5.1
- Library name: Puppeteer Core (GitHub, NPM, website)
-
Version:
v21.5.1
- Description: Helper library for working with Chrome / Chromium
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:puppeteer_core-v21_5_1:1
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import puppeteer from "puppeteer-core";
export const handler = async function(event, context, callback) {
var browser = await puppeteer.launch({...});
};
sharp v0.29.3
- Library name: Sharp (GitHub, NPM, website)
-
Version:
v0.29.3
- Description: High performance Node.js image processing
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:sharp-v0_29_3:5
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import sharp from '/opt/node_modules/sharp/lib/index.js';
export const handler = async function(event, context, callback) {
await sharp(data).resize(width).toBuffer().then(function(buffer) {
...
});
};
sugar v2.0.6
- Library name: Sugar.js (GitHub, NPM, website)
-
Version:
v2.0.6
- Description: Library for working with native objects
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:sugar-v2_0_6:5
-
AWS Region:
us-west-2
- Maintained by me: ✅
- Notes: (none)
- Instantiation:
import Sugar from 'sugar';
import SugarLocales from 'sugar/locales/index.js';
export const handler = async function(event, context, callback) {
var parsedDate = Sugar.Date.create('dateTime');
};
wkhtmltox v0.12.6
- Library name: wkhtmltopdf (GitHub, NPM, website)
-
Version:
v0.12.6
- Description: Utility to convert HTML to PDF
-
ARN:
arn:aws:lambda:us-west-2:339713137814:layer:wkhtmltox-v0_12_6_4:1
-
AWS Region:
us-west-2
- Maintained by me: ✅
-
Notes: This library is also known as
wkhtmltopdf
. It also includes the librarywkhtmltoimage
. This Layer exposes these libraries within the request, which can be made using child_process. - Instantiation:
var command = '/opt/bin/wkhtmltopdf ' + (inputPath) + ' - | cat',
properties = {
encoding: 'buffer',
maxBuffer: 1024 * 1024 * 10
};
child_process.exec(command, properties, function(error, stdout, stderr) {
...
});
amazon_linux_fonts (n/a)
- Library name: Amazon Linux Fonts
-
Version:
(n/a)
- Description: Library to help render fonts within AWS
-
ARN:
arn:aws:lambda:us-west-2:347599033421:layer:amazon_linux_fonts:1
-
AWS Region:
us-west-2
- Maintained by me: ❌
- Notes: Nothing required here, other than adding the Layer to your Lambda Function.
- Instantiation: (n/a)
Command to share layer:
Below is a sample bash command to share a Layer (I couldn't
find the option in the AWS console to do so). You may need
to change /usr/bin/aws
to aws
or
something similar.
AWS_ACCESS_KEY_ID={{key}} AWS_SECRET_ACCESS_KEY={{secret}} /usr/bin/aws lambda add-layer-version-permission \
--layer-name {{layerName}} \
--principal '*' \
--action lambda:GetLayerVersion \
--version-number {{layerVersion}} \
--statement-id public \
--region {{region}}