{"record":{"id":"ef9b89e5fa7b998d","repo":"remotion-dev/remotion","slug":"invalid-lambda-layer-version-arn-layerarn-exp","errorCode":null,"errorMessage":"Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:<partition>:lambda:<region>:<12-digit-account-id>:layer:<layer-name>:<numeric-version>.","messagePattern":"Invalid Lambda Layer version ARN: (.+?)\\. Expected arn:<partition>:lambda:<region>:<12-digit-account-id>:layer:<layer-name>:<numeric-version>\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-custom-layer-arns.ts","lineNumber":58,"sourceCode":"\t}\n\n\tif (customLayerArns.length + (enableLambdaInsights ? 1 : 0) > 5) {\n\t\tthrow new Error(\n\t\t\t'Lambda functions support at most 5 Layers, including the Lambda Insights Layer.',\n\t\t);\n\t}\n\n\tconst seen = new Set<string>();\n\tfor (const layerArn of customLayerArns) {\n\t\tif (typeof layerArn !== 'string' || layerArn.length === 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t'Each customLayerArns entry must be a non-empty string.',\n\t\t\t);\n\t\t}\n\n\t\tconst match = layerArn.match(layerVersionArnRegex);\n\t\tif (!match) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Invalid Lambda Layer version ARN: ${layerArn}. Expected arn:<partition>:lambda:<region>:<12-digit-account-id>:layer:<layer-name>:<numeric-version>.`,\n\t\t\t);\n\t\t}\n\n\t\tif (match[1] !== partition) {\n\t\t\tthrow new Error(\n\t\t\t\t`The custom Layer ARN ${layerArn} uses partition ${match[1]}, but region ${region} uses partition ${partition}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (match[2] !== region) {\n\t\t\tthrow new Error(\n\t\t\t\t`The custom Layer ARN ${layerArn} is in region ${match[2]}, but the function is being deployed to ${region}.`,\n\t\t\t);\n\t\t}\n\n\t\tif (seen.has(layerArn)) {\n\t\t\tthrow new Error(`Duplicate custom Layer ARN: ${layerArn}.`);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/lambda/src/shared/validate-custom-layer-arns.ts#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Append the version number: `...:layer:my-layer:1` (or whatever `aws lambda list-layer-versions` reports as LatestMatchingVersion).","Get the exact versioned ARN via `aws lambda list-layer-versions --layer-name my-layer --query 'LayerVersions[0].LayerVersionArn'`.","Remove invalid characters from the layer name; only letters, digits, hyphens and underscores are accepted."],"exampleFix":"// before\nawait deployFunction({\n  region: 'us-east-1',\n  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:remotion-libs'],\n});\n\n// after\nawait deployFunction({\n  region: 'us-east-1',\n  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:remotion-libs:1'],\n});","handlingStrategy":"type-guard","validationCode":"const layerVersionArnRegex =\n  /^arn:([a-z0-9][a-z0-9-]*):lambda:([a-z0-9-]+):(\\d{12}):layer:([A-Za-z0-9-_]+):(\\d+)$/;\nif (!customLayerArns.every((a) => layerVersionArnRegex.test(a))) {\n  throw new Error('One or more layer ARNs are not versioned layer ARNs');\n}","typeGuard":"const isLayerVersionArn = (arn: string): boolean =>\n  /^arn:[a-z0-9][a-z0-9-]*:lambda:[a-z0-9-]+:\\d{12}:layer:[A-Za-z0-9-_]+:\\d+$/.test(arn);","tryCatchPattern":null,"preventionTips":["Always capture the versioned ARN from list-layer-versions/publish-layer-version output, not the console layer list.","Automate layer publishing so version suffixes are never hand-copied."],"tags":["aws","arn","lambda-layers","validation"],"backgroundTag":"invalid-arn-format","analyzedSha":"10db9de07356446fb0edb3c3ae211369b693d18b","analyzedAt":"2026-08-22T21:45:17.748Z","contentChangedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}