remotion-dev/remotion · error · Error
The custom Layer ARN ${layerArn} is in region ${match[2]}, b
Error message
The custom Layer ARN ${layerArn} is in region ${match[2]}, but the function is being deployed to ${region}. What it means
validateCustomLayerArns compares the region segment of each layer ARN (regex group 2) with the region passed to deployFunction. Lambda layers are regional resources: a layer published in us-east-1 is invisible to a function in eu-west-1, so Remotion rejects the mismatch up front instead of letting the AWS API fail later.
Source
Thrown at packages/lambda/src/shared/validate-custom-layer-arns.ts:70
'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}.`);
}
seen.add(layerArn);
}
};
View on GitHub (pinned to 10db9de073)
Solutions
- Publish the layer in the target region (`aws lambda publish-layer-version --region <target>`) and use that ARN.
- Build the layer list per region, e.g. a map `{[region]: layerArn}` instead of a single constant.
Example fix
// before
const layerArn = 'arn:aws:lambda:us-east-1:123456789012:layer:libs:1';
await deployFunction({region: 'eu-west-1', customLayerArns: [layerArn]});
// after: per-region map
const layerArnsByRegion = {
'us-east-1': 'arn:aws:lambda:us-east-1:123456789012:layer:libs:1',
'eu-west-1': 'arn:aws:lambda:eu-west-1:123456789012:layer:libs:1',
};
await deployFunction({region: 'eu-west-1', customLayerArns: [layerArnsByRegion['eu-west-1']]}); Defensive patterns
Strategy: validation
Validate before calling
const bad = customLayerArns.filter((a) => !a.includes(`:lambda:${region}:`));
if (bad.length > 0) {
throw new Error(`Layer ARNs not in ${region}: ${bad.join(', ')}`);
} Type guard
const isLayerArnInRegion = (arn: string, region: string): boolean =>
new RegExp(`:lambda:${region}:\d{12}:layer:`).test(arn); Prevention
- Publish layers programmatically per region and store ARNs in a region-keyed map.
- Never reuse a hardcoded layer ARN constant across multi-region deploys.
When it happens
Trigger: Calling deployFunction({region: 'eu-west-1', customLayerArns: ['arn:aws:lambda:us-east-1:...:layer:x:1']}) — any combination where the ARN region differs from the deploy region.
Common situations: Changing the deploy region in config but forgetting to republish/update the layer ARNs; copying layer ARNs from a colleague working in another region; multi-region deploy scripts sharing one layer list.
Related errors
- Remotion-hosted Layers are not available in ${region}.
- Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:
- The custom Layer ARN ${layerArn} uses partition ${match[1]},
- Duplicate custom Layer ARN: ${layerArn}.
- ${region} is not a supported AWS region. Must be one of: ${A
AI-assisted analysis of remotion-dev/remotion@10db9de073 (2026-08-22).
Data as JSON: /api/errors/f1154f60a17c0950.
Report an issue: GitHub.