Skip to content

LayerVersion

Source: src/AWS/Lambda/LayerVersion.ts

A version of a Lambda layer — a zip archive of libraries, a custom runtime, or other dependencies that Lambda extracts into /opt alongside your function code.

Layer versions are immutable, so changing the content or any publish setting publishes a new version under the same layer and retires the one it supersedes. layerVersionArn and version therefore change on update; layerName and layerArn stay put.

Package a Local Directory

// ./layers/deps contains nodejs/node_modules/...
const deps = yield* LayerVersion("Deps", {
path: "./layers/deps",
compatibleRuntimes: ["nodejs22.x"],
});

Publish an Existing Archive

const layer = yield* LayerVersion("Ffmpeg", {
path: "./dist/ffmpeg-layer.zip",
description: "static ffmpeg build",
compatibleArchitectures: ["arm64"],
});

Publish From S3

const layer = yield* LayerVersion("BigLayer", {
s3: {
bucket,
key: "layers/big-layer.zip",
},
});
const fn = yield* Function("Handler", {
main: import.meta.resolve("./handler.ts"),
layers: [deps],
});