remotion-dev/remotion · error · TypeError

Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:

Error message

Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:<partition>:lambda:<region>:<12-digit-account-id>:layer:<layer-name>:<numeric-version>.

What it means

Each customLayerArns entry must match the full Lambda layer version ARN pattern `arn:<partition>:lambda:<region>:<12-digit-account>:layer:<name>:<version>` (see layerVersionArnRegex in validate-custom-layer-arns.ts). This TypeError fires when the string does not match, most commonly because the trailing numeric version segment is missing or the account ID is not exactly 12 digits.

Source

Thrown at packages/lambda/src/shared/validate-custom-layer-arns.ts:58

	}

	if (customLayerArns.length + (enableLambdaInsights ? 1 : 0) > 5) {
		throw new Error(
			'Lambda functions support at most 5 Layers, including the Lambda Insights Layer.',
		);
	}

	const seen = new Set<string>();
	for (const layerArn of customLayerArns) {
		if (typeof layerArn !== 'string' || layerArn.length === 0) {
			throw new TypeError(
				'Each customLayerArns entry must be a non-empty string.',
			);
		}

		const match = layerArn.match(layerVersionArnRegex);
		if (!match) {
			throw new TypeError(
				`Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:<partition>:lambda:<region>:<12-digit-account-id>:layer:<layer-name>:<numeric-version>.`,
			);
		}

		if (match[1] !== partition) {
			throw new Error(
				`The custom Layer ARN ${layerArn} uses partition ${match[1]}, but region ${region} uses partition ${partition}.`,
			);
		}

		if (match[2] !== region) {
			throw new Error(
				`The custom Layer ARN ${layerArn} is in region ${match[2]}, but the function is being deployed to ${region}.`,
			);
		}

		if (seen.has(layerArn)) {
			throw new Error(`Duplicate custom Layer ARN: ${layerArn}.`);

View on GitHub (pinned to 10db9de073)

Solutions

  1. Append the version number: `...:layer:my-layer:1` (or whatever `aws lambda list-layer-versions` reports as LatestMatchingVersion).
  2. Get the exact versioned ARN via `aws lambda list-layer-versions --layer-name my-layer --query 'LayerVersions[0].LayerVersionArn'`.
  3. Remove invalid characters from the layer name; only letters, digits, hyphens and underscores are accepted.

Example fix

// before
await deployFunction({
  region: 'us-east-1',
  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:remotion-libs'],
});

// after
await deployFunction({
  region: 'us-east-1',
  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:remotion-libs:1'],
});
Defensive patterns

Strategy: type-guard

Validate before calling

const layerVersionArnRegex =
  /^arn:([a-z0-9][a-z0-9-]*):lambda:([a-z0-9-]+):(\d{12}):layer:([A-Za-z0-9-_]+):(\d+)$/;
if (!customLayerArns.every((a) => layerVersionArnRegex.test(a))) {
  throw new Error('One or more layer ARNs are not versioned layer ARNs');
}

Type guard

const isLayerVersionArn = (arn: string): boolean =>
  /^arn:[a-z0-9][a-z0-9-]*:lambda:[a-z0-9-]+:\d{12}:layer:[A-Za-z0-9-_]+:\d+$/.test(arn);

Prevention

When it happens

Trigger: Passing a layer ARN without a version suffix such as `arn:aws:lambda:us-east-1:123456789012:layer:my-layer` (regex requires `:<number>` at the end), a layer name containing dots or other characters outside [A-Za-z0-9-_], or an account ID with the wrong digit count.

Common situations: Copying the layer ARN from the AWS console Layers list, which shows the un-versioned base ARN; forgetting the `:1` version after publishing; using an ARN with an organization path segment inside the layer name.

Related errors


AI-assisted analysis of remotion-dev/remotion@10db9de073 (2026-08-22). Data as JSON: /api/errors/ef9b89e5fa7b998d. Report an issue: GitHub.