remotion-dev/remotion · error · Error

The custom Layer ARN ${layerArn} uses partition ${match[1]},

Error message

The custom Layer ARN ${layerArn} uses partition ${match[1]}, but region ${region} uses partition ${partition}.

What it means

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.

Source

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

	}

	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}.`);
		}

		seen.add(layerArn);
	}
};

View on GitHub (pinned to 10db9de073)

Solutions

  1. Publish the same layer content in the target partition's account and use those ARNs (`arn:aws-cn:lambda:cn-north-1:...`).
  2. Partition your deploy configuration by environment so China/GovCloud deploys get their own layer list.

Example fix

// before: deploying to China with commercial ARNs
await deployFunction({
  region: 'cn-north-1',
  customLayerArns: ['arn:aws:lambda:us-east-1:123456789012:layer:libs:1'],
});

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

Strategy: validation

Validate before calling

const partitionOf = (region: string) =>
  region.startsWith('cn-') ? 'aws-cn' : region.startsWith('us-gov-') ? 'aws-us-gov' : 'aws';
const want = partitionOf(region);
if (!customLayerArns.every((a) => a.startsWith(`arn:${want}:lambda:`))) {
  throw new Error(`All layer ARNs must be in the ${want} partition`);
}

Type guard

const isLayerArnInPartition = (arn: string, partition: string): boolean =>
  arn.startsWith(`arn:${partition}:lambda:`);

Prevention

When it happens

Trigger: 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.

Common situations: Reusing a global-region layer list when deploying into AWS China or GovCloud; copying layer ARNs from documentation written for the commercial partition.

Related errors


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