{"record":{"id":"fcd856aa74708d05","repo":"remotion-dev/remotion","slug":"the-custom-layer-arn-layerarn-uses-partition","errorCode":null,"errorMessage":"The custom Layer ARN ${layerArn} uses partition ${match[1]}, but region ${region} uses partition ${partition}.","messagePattern":"The custom Layer ARN (.+?) uses partition (.+?), but region (.+?) uses partition (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/lambda/src/shared/validate-custom-layer-arns.ts","lineNumber":64,"sourceCode":"\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}.`);\n\t\t}\n\n\t\tseen.add(layerArn);\n\t}\n};\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/remotion-dev/remotion/blob/10db9de07356446fb0edb3c3ae211369b693d18b/packages/lambda/src/shared/validate-custom-layer-arns.ts#L46-L82","documentation":"After the ARN passes the format regex, validateCustomLayerArns compares the ARN's partition (regex group 1) with the partition of the deploy region reported by getAwsRegionMetadata. Lambda layers are per-partition resources, so a layer from the commercial `aws` partition cannot be attached to a function in `aws-cn` (or aws-us-gov), and vice versa.","triggerScenarios":"Deploying to cn-north-1 with `arn:aws:lambda:...` layer ARNs, or deploying to us-gov-west-1 with commercial ARNs; mixing a China-account layer into a global deploy script.","commonSituations":"Reusing a global-region layer list when deploying into AWS China or GovCloud; copying layer ARNs from documentation written for the commercial partition.","solutions":["Publish the same layer content in the target partition's account and use those ARNs (`arn:aws-cn:lambda:cn-north-1:...`).","Partition your deploy configuration by environment so China/GovCloud deploys get their own layer list."],"exampleFix":"// before: deploying to China with commercial ARNs\nawait deployFunction({\n  region: 'cn-north-1',\n  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:libs:1'],\n});\n\n// after\nawait deployFunction({\n  region: 'cn-north-1',\n  customLayerArns: ['arn:aws-cn:lambda:cn-north-1:123456789012:layer:libs:1'],\n});","handlingStrategy":"validation","validationCode":"const partitionOf = (region: string) =>\n  region.startsWith('cn-') ? 'aws-cn' : region.startsWith('us-gov-') ? 'aws-us-gov' : 'aws';\nconst want = partitionOf(region);\nif (!customLayerArns.every((a) => a.startsWith(`arn:${want}:lambda:`))) {\n  throw new Error(`All layer ARNs must be in the ${want} partition`);\n}","typeGuard":"const isLayerArnInPartition = (arn: string, partition: string): boolean =>\n  arn.startsWith(`arn:${partition}:lambda:`);","tryCatchPattern":null,"preventionTips":["Keep separate layer ARN configs per partition (aws / aws-cn / aws-us-gov).","Add a config lint that cross-checks deploy region prefix against layer ARN prefix."],"tags":["aws","arn","partition","aws-china","lambda-layers"],"backgroundTag":"arn-partition-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"}