{"record":{"id":"f1154f60a17c0950","repo":"remotion-dev/remotion","slug":"the-custom-layer-arn-layerarn-is-in-region-ma","errorCode":null,"errorMessage":"The custom Layer ARN ${layerArn} is in region ${match[2]}, but the function is being deployed to ${region}.","messagePattern":"The custom Layer ARN (.+?) is in region (.+?), but the function is being deployed to (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-custom-layer-arns.ts","lineNumber":70,"sourceCode":"\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}.`);\n\t\t}\n\n\t\tseen.add(layerArn);\n\t}\n};\n","sourceCodeStart":52,"sourceCodeEnd":82,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/lambda/src/shared/validate-custom-layer-arns.ts#L52-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst layerArn = 'arn:aws:lambda:us-east-1:123456789012:layer:libs:1';\nawait deployFunction({region: 'eu-west-1', customLayerArns: [layerArn]});\n\n// after: per-region map\nconst layerArnsByRegion = {\n  'us-east-1': 'arn:aws:lambda:us-east-1:123456789012:layer:libs:1',\n  'eu-west-1': 'arn:aws:lambda:eu-west-1:123456789012:layer:libs:1',\n};\nawait deployFunction({region: 'eu-west-1', customLayerArns: [layerArnsByRegion['eu-west-1']]});","handlingStrategy":"validation","validationCode":"const bad = customLayerArns.filter((a) => !a.includes(`:lambda:${region}:`));\nif (bad.length > 0) {\n  throw new Error(`Layer ARNs not in ${region}: ${bad.join(', ')}`);\n}","typeGuard":"const isLayerArnInRegion = (arn: string, region: string): boolean =>\n  new RegExp(`:lambda:${region}:\\d{12}:layer:`).test(arn);","tryCatchPattern":null,"preventionTips":["Publish layers programmatically per region and store ARNs in a region-keyed map.","Never reuse a hardcoded layer ARN constant across multi-region deploys."],"tags":["aws","arn","region","lambda-layers"],"backgroundTag":"arn-region-mismatch","analyzedSha":"10db9de07356446fb0edb3c3ae211369b693d18b","analyzedAt":"2026-08-22T21:45:17.748Z","contentChangedAt":"2026-08-22T21:45:17.748Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}