🎥 Make videos programmatically with React
hosted layers
Jonny Burger4f71a291c80a
diff --git a/packages/lambda/src/admin/make-layer-public.ts b/packages/lambda/src/admin/make-layer-public.tsindex 26e3b8e09b..47800caa0f 100644--- a/packages/lambda/src/admin/make-layer-public.ts+++ b/packages/lambda/src/admin/make-layer-public.ts@@ -5,80 +5,92 @@ import {import {lambda} from 'aws-policies';import {quit} from '../cli/helpers/quit';import {AwsRegion} from '../pricing/aws-regions';-import {AWS_REGIONS} from '../regions';import {getLambdaClient} from '../shared/aws-clients';import {CURRENT_VERSION} from '../shared/constants';+import {HostedLayers} from '../shared/hosted-layers';import {LambdaArchitecture} from '../shared/validate-architecture';const runtimes: string[] = ['nodejs14.x'];const archictures: LambdaArchitecture[] = ['arm64', 'x86_64'];-const layerInfo: {- [region in AwsRegion]: {layerArn: string; version: number}[];-} = {- 'ap-northeast-1': [],- 'ap-south-1': [],- 'ap-southeast-1': [],- 'ap-southeast-2': [],- 'eu-central-1': [],- 'eu-west-1': [],- 'eu-west-2': [],- 'us-east-1': [],- 'us-east-2': [],- 'us-west-2': [],+const region: AwsRegion = 'us-east-1';++const layerInfo: HostedLayers = {+ arm64: {+ 'ap-northeast-1': [],+ 'ap-south-1': [],+ 'ap-southeast-1': [],+ 'ap-southeast-2': [],+ 'eu-central-1': [],+ 'eu-west-1': [],+ 'eu-west-2': [],+ 'us-east-1': [],+ 'us-east-2': [],+ 'us-west-2': [],+ },+ x86_64: {+ 'ap-northeast-1': [],+ 'ap-south-1': [],+ 'ap-southeast-1': [],+ 'ap-southeast-2': [],+ 'eu-central-1': [],+ 'eu-west-1': [],+ 'eu-west-2': [],+ 'us-east-1': [],+ 'us-east-2': [],+ 'us-west-2': [],+ },};const makeLayerPublic = async () => {const layers = ['remotion', 'ffmpeg', 'chromium'] as const;- for (const region of AWS_REGIONS) {- for (const architecture of archictures) {- for (const layer of layers) {- const layerName = `remotion-binaries-${layer}-${architecture}`;- const {Version, LayerArn} = await getLambdaClient(region).send(- new PublishLayerVersionCommand({- Content: {- S3Bucket: 'remotionlambda-binaries-' + region,- S3Key: `remotion-layer-${layer}-v4-${architecture}.zip`,- },- LayerName: layerName,- LicenseInfo:- layer === 'chromium'- ? 'Compiled from Chromium source. Read Chromium License: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/LICENSE'- : layer === 'ffmpeg'- ? 'Compiled from FFMPEG source. Read FFMPEG license: https://ffmpeg.org/legal.html'- : 'Contains UNIX .so files and Noto Sans font. Read Noto Sans License: https://fonts.google.com/noto/specimen/Noto+Sans/about',- CompatibleRuntimes: runtimes,- Description: CURRENT_VERSION,- })- );- await getLambdaClient(region).send(- new AddLayerVersionPermissionCommand({- Action: lambda.GetLayerVersion,- LayerName: layerName,- Principal: '*',- VersionNumber: Version,- StatementId: 'public-layer',- })- );- if (!layerInfo[region]) {- layerInfo[region] = [];- }-- if (!LayerArn) {- throw new Error('layerArn is null');- }+ for (const architecture of archictures) {+ for (const layer of layers) {+ const layerName = `remotion-binaries-${layer}-${architecture}`;+ const {Version, LayerArn} = await getLambdaClient(region).send(+ new PublishLayerVersionCommand({+ Content: {+ S3Bucket: 'remotionlambda-binaries-' + region,+ S3Key: `remotion-layer-${layer}-v4-${architecture}.zip`,+ },+ LayerName: layerName,+ LicenseInfo:+ layer === 'chromium'+ ? 'Compiled from Chromium source. Read Chromium License: https://chromium.googlesource.com/chromium/src/+/refs/heads/main/LICENSE'+ : layer === 'ffmpeg'+ ? 'Compiled from FFMPEG source. Read FFMPEG license: https://ffmpeg.org/legal.html'+ : 'Contains UNIX .so files and Noto Sans font. Read Noto Sans License: https://fonts.google.com/noto/specimen/Noto+Sans/about',+ CompatibleRuntimes: runtimes,+ Description: CURRENT_VERSION,+ })+ );+ await getLambdaClient(region).send(+ new AddLayerVersionPermissionCommand({+ Action: lambda.GetLayerVersion,+ LayerName: layerName,+ Principal: '*',+ VersionNumber: Version,+ StatementId: 'public-layer',+ })+ );+ if (!layerInfo[architecture][region]) {+ layerInfo[architecture][region] = [];+ }- if (!Version) {- throw new Error('Version is null');- }+ if (!LayerArn) {+ throw new Error('layerArn is null');+ }- layerInfo[region].push({- layerArn: LayerArn,- version: Version,- });- console.log({LayerArn, Version});+ if (!Version) {+ throw new Error('Version is null');}++ layerInfo[architecture][region].push({+ layerArn: LayerArn,+ version: Version,+ });+ console.log({LayerArn, Version});}}};diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.tsindex b40d7adcc7..9930802a3a 100644--- a/packages/lambda/src/index.ts+++ b/packages/lambda/src/index.ts@@ -57,6 +57,7 @@ import {LambdaLSInput, LambdaLsReturnType} from './functions/helpers/io';import {LambdaInternals} from './internals';import {AwsRegion} from './pricing/aws-regions';import type {RenderProgress} from './shared/constants';+import {LambdaArchitecture} from './shared/validate-architecture';export {deleteSite,@@ -113,4 +114,5 @@ export type {SimulatePermissionsOutput,GetAwsClientInput,GetAwsClientOutput,+ LambdaArchitecture,};diff --git a/packages/lambda/src/shared/hosted-layers.ts b/packages/lambda/src/shared/hosted-layers.tsindex bfe1394828..ea5032e5b2 100644--- a/packages/lambda/src/shared/hosted-layers.ts+++ b/packages/lambda/src/shared/hosted-layers.ts@@ -1,181 +1,69 @@import {AwsRegion} from '../pricing/aws-regions';+import {LambdaArchitecture} from './validate-architecture';export const REMOTION_HOSTED_LAYER_ARN = `arn:aws:lambda:*:678892195805:layer:remotion-binaries-*`;-export const hostedLayers: {- [key in AwsRegion]: {- layerArn: string;- version: number;- }[];-} = {- 'ap-northeast-1': [- {- layerArn:- 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-remotion',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-northeast-1:678892195805:layer:remotion-binaries-chromium',- version: 13,- },- ],- 'ap-south-1': [- {- layerArn:- 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-remotion',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-south-1:678892195805:layer:remotion-binaries-chromium',- version: 13,- },- ],- 'ap-southeast-1': [- {- layerArn:- 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-remotion',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-southeast-1:678892195805:layer:remotion-binaries-chromium',- version: 13,- },- ],- 'ap-southeast-2': [- {- layerArn:- 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-remotion',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-ffmpeg',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:ap-southeast-2:678892195805:layer:remotion-binaries-chromium',- version: 13,- },- ],- 'eu-central-1': [- {- layerArn:- 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-remotion',- version: 36,- },- {- layerArn:- 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 36,- },- {- layerArn:- 'arn:aws:lambda:eu-central-1:678892195805:layer:remotion-binaries-chromium',- version: 36,- },- ],- 'eu-west-1': [- {- layerArn:- 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-remotion',- version: 14,- },- {- layerArn:- 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 14,- },- {- layerArn:- 'arn:aws:lambda:eu-west-1:678892195805:layer:remotion-binaries-chromium',- version: 14,- },- ],- 'eu-west-2': [- {- layerArn:- 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-remotion',- version: 14,- },- {- layerArn:- 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-ffmpeg',- version: 14,- },- {- layerArn:- 'arn:aws:lambda:eu-west-2:678892195805:layer:remotion-binaries-chromium',- version: 14,- },- ],- 'us-east-1': [- {- layerArn:- 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-remotion',- version: 20,- },- {- layerArn:- 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-ffmpeg',- version: 18,- },- {- layerArn:- 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-chromium',- version: 16,- },- ],- 'us-east-2': [- {- layerArn:- 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-remotion',- version: 15,- },- {- layerArn:- 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-ffmpeg',- version: 15,- },- {- layerArn:- 'arn:aws:lambda:us-east-2:678892195805:layer:remotion-binaries-chromium',- version: 15,- },- ],- 'us-west-2': [- {- layerArn:- 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-remotion',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-ffmpeg',- version: 13,- },- {- layerArn:- 'arn:aws:lambda:us-west-2:678892195805:layer:remotion-binaries-chromium',- version: 13,- },- ],+export type HostedLayers = {+ [architecture in LambdaArchitecture]: {+ [region in AwsRegion]: {layerArn: string; version: number}[];+ };+};++export const hostedLayers: HostedLayers = {+ arm64: {+ 'ap-northeast-1': [],+ 'ap-south-1': [],+ 'ap-southeast-1': [],+ 'ap-southeast-2': [],+ 'eu-central-1': [],+ 'eu-west-1': [],+ 'eu-west-2': [],+ 'us-east-1': [+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-remotion-arm64',+ version: 2,+ },+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-ffmpeg-arm64',+ version: 2,+ },+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-chromium-arm64',+ version: 2,+ },+ ],+ 'us-east-2': [],+ 'us-west-2': [],+ },+ x86_64: {+ 'ap-northeast-1': [],+ 'ap-south-1': [],+ 'ap-southeast-1': [],+ 'ap-southeast-2': [],+ 'eu-central-1': [],+ 'eu-west-1': [],+ 'eu-west-2': [],+ 'us-east-1': [+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-remotion-x86_64',+ version: 2,+ },+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-ffmpeg-x86_64',+ version: 2,+ },+ {+ layerArn:+ 'arn:aws:lambda:us-east-1:678892195805:layer:remotion-binaries-chromium-x86_64',+ version: 2,+ },+ ],+ 'us-east-2': [],+ 'us-west-2': [],+ },};