Skip to content

🎥 Make videos programmatically with React

still works

Jonny Burger12b4d8770015
diff --git a/packages/lambda/src/api/bucket-exists.ts b/packages/lambda/src/api/bucket-exists.ts
index 32e0b42401..d326466fd1 100644
--- a/packages/lambda/src/api/bucket-exists.ts
+++ b/packages/lambda/src/api/bucket-exists.ts
@@ -1,5 +1,5 @@
import {GetBucketLocationCommand} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
export const bucketExistsInRegion = async ({
diff --git a/packages/lambda/src/api/clean-items.ts b/packages/lambda/src/api/clean-items.ts
index 9201a28ac5..ed4a0a9fe7 100644
--- a/packages/lambda/src/api/clean-items.ts
+++ b/packages/lambda/src/api/clean-items.ts
@@ -1,5 +1,5 @@
import {DeleteObjectCommand} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
import {pLimit} from '../shared/p-limit';
diff --git a/packages/lambda/src/api/create-bucket.ts b/packages/lambda/src/api/create-bucket.ts
index 5ced8510b1..1d50f25eaa 100644
--- a/packages/lambda/src/api/create-bucket.ts
+++ b/packages/lambda/src/api/create-bucket.ts
@@ -4,7 +4,7 @@ import {
DeletePublicAccessBlockCommand,
PutBucketAclCommand,
} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
export const createBucket = async ({
diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.ts
index f2e375bae0..fd349a4f6d 100644
--- a/packages/lambda/src/api/create-function.ts
+++ b/packages/lambda/src/api/create-function.ts
@@ -12,10 +12,10 @@ import {
} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {AwsRegion} from '@remotion/serverless/client';
import {readFileSync} from 'node:fs';
import {VERSION} from 'remotion/version';
import {LOG_GROUP_PREFIX} from '../defaults';
+import type {AwsRegion} from '../regions';
import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';
import {hostedLayers, v5HostedLayers} from '../shared/hosted-layers';
import {lambdaInsightsExtensions} from '../shared/lambda-insights-extensions';
diff --git a/packages/lambda/src/api/delete-function.ts b/packages/lambda/src/api/delete-function.ts
index cc19690eaf..2a34a04a12 100644
--- a/packages/lambda/src/api/delete-function.ts
+++ b/packages/lambda/src/api/delete-function.ts
@@ -1,5 +1,5 @@
import {DeleteFunctionCommand} from '@aws-sdk/client-lambda';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getLambdaClient} from '../shared/aws-clients';
export type DeleteFunctionInput = {
diff --git a/packages/lambda/src/api/delete-render.ts b/packages/lambda/src/api/delete-render.ts
index e202aa1332..6f90e0f4c4 100644
--- a/packages/lambda/src/api/delete-render.ts
+++ b/packages/lambda/src/api/delete-render.ts
@@ -1,8 +1,9 @@
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {rendersPrefix} from '../defaults';
import {getExpectedOutName} from '../functions/helpers/expected-out-name';
import {getOverallProgressS3} from '../functions/helpers/get-overall-progress-s3';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
+import type {AwsRegion} from '../regions';
import {getAccountId} from '../shared/get-account-id';
import {cleanItems} from './clean-items';
@@ -10,7 +11,7 @@ export type DeleteRenderInput = {
region: AwsRegion;
bucketName: string;
renderId: string;
- customCredentials?: CustomCredentials;
+ customCredentials?: CustomCredentials<AwsRegion>;
};
/**
diff --git a/packages/lambda/src/api/delete-site.ts b/packages/lambda/src/api/delete-site.ts
index 259526fd75..f4027210d1 100644
--- a/packages/lambda/src/api/delete-site.ts
+++ b/packages/lambda/src/api/delete-site.ts
@@ -1,6 +1,6 @@
-import type {AwsRegion} from '@remotion/serverless/client';
import {getSitesKey} from '../defaults';
import {lambdaLs} from '../functions/helpers/io';
+import type {AwsRegion} from '../regions';
import {getAccountId} from '../shared/get-account-id';
import {cleanItems} from './clean-items';
diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.ts
index d3d9a624b5..417848f3f5 100644
--- a/packages/lambda/src/api/deploy-function.ts
+++ b/packages/lambda/src/api/deploy-function.ts
@@ -1,9 +1,9 @@
import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
-import type {AwsRegion} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
import {VERSION} from 'remotion/version';
import {getFunctions} from '../api/get-functions';
+import type {AwsRegion} from '../regions';
import {
DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
DEFAULT_EPHEMERAL_STORAGE_IN_MB,
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.ts
index f17c7afb57..97b82fbe7b 100644
--- a/packages/lambda/src/api/deploy-site.ts
+++ b/packages/lambda/src/api/deploy-site.ts
@@ -2,9 +2,9 @@ import {type GitSource, type WebpackOverrideFn} from '@remotion/bundler';
import type {ToOptions} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
-import type {AwsRegion} from '@remotion/serverless/client';
import fs from 'node:fs';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
+import type {AwsRegion} from '../regions';
import {bundleSite} from '../shared/bundle-site';
import {getSitesKey} from '../shared/constants';
import {getAccountId} from '../shared/get-account-id';
diff --git a/packages/lambda/src/api/download-media.ts b/packages/lambda/src/api/download-media.ts
index 60b2b4a4a7..2776e646fe 100644
--- a/packages/lambda/src/api/download-media.ts
+++ b/packages/lambda/src/api/download-media.ts
@@ -1,11 +1,12 @@
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import path from 'node:path';
import {getExpectedOutName} from '../functions/helpers/expected-out-name';
import {getOverallProgressS3} from '../functions/helpers/get-overall-progress-s3';
import type {LambdaReadFileProgress} from '../functions/helpers/read-with-progress';
import {lambdaDownloadFileWithProgress} from '../functions/helpers/read-with-progress';
+import type {AwsRegion} from '../regions';
import {getAccountId} from '../shared/get-account-id';
export type DownloadMediaInput = {
@@ -14,7 +15,7 @@ export type DownloadMediaInput = {
renderId: string;
outPath: string;
onProgress?: LambdaReadFileProgress;
- customCredentials?: CustomCredentials;
+ customCredentials?: CustomCredentials<AwsRegion>;
logLevel?: LogLevel;
};
diff --git a/packages/lambda/src/api/estimate-price.ts b/packages/lambda/src/api/estimate-price.ts
index fd651b3325..0bdcc2004a 100644
--- a/packages/lambda/src/api/estimate-price.ts
+++ b/packages/lambda/src/api/estimate-price.ts
@@ -1,6 +1,6 @@
-import type {AwsRegion} from '@remotion/serverless/client';
import {MIN_EPHEMERAL_STORAGE_IN_MB} from '../defaults';
import {pricing} from '../pricing/price-per-1-s';
+import type {AwsRegion} from '../regions';
import {validateAwsRegion} from '../shared/validate-aws-region';
import {validateDiskSizeInMb} from '../shared/validate-disk-size-in-mb';
import {validateMemorySize} from '../shared/validate-memory-size';
diff --git a/packages/lambda/src/api/get-aws-client.ts b/packages/lambda/src/api/get-aws-client.ts
index 18bf972756..75da798cb1 100644
--- a/packages/lambda/src/api/get-aws-client.ts
+++ b/packages/lambda/src/api/get-aws-client.ts
@@ -12,7 +12,7 @@ import {getServiceClient} from '../shared/aws-clients';
export type GetAwsClientInput<T extends keyof ServiceMapping> = {
region: AwsRegion;
service: T;
- customCredentials?: CustomCredentials | null;
+ customCredentials?: CustomCredentials<AwsRegion> | null;
};
type SdkMapping = {
diff --git a/packages/lambda/src/api/get-buckets.ts b/packages/lambda/src/api/get-buckets.ts
index e46dca88be..72b83d41f3 100644
--- a/packages/lambda/src/api/get-buckets.ts
+++ b/packages/lambda/src/api/get-buckets.ts
@@ -1,6 +1,6 @@
import {GetBucketLocationCommand, ListBucketsCommand} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '@remotion/serverless/client';
import {REMOTION_BUCKET_PREFIX} from '../defaults';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
import {parseBucketName} from '../shared/validate-bucketname';
diff --git a/packages/lambda/src/api/get-function-info.ts b/packages/lambda/src/api/get-function-info.ts
index 38c854b86e..f7cdc985cd 100644
--- a/packages/lambda/src/api/get-function-info.ts
+++ b/packages/lambda/src/api/get-function-info.ts
@@ -1,6 +1,6 @@
import {GetFunctionCommand} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getLambdaClient} from '../shared/aws-clients';
import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../shared/constants';
import {getFunctionVersion} from '../shared/get-function-version';
diff --git a/packages/lambda/src/api/get-functions.ts b/packages/lambda/src/api/get-functions.ts
index c3d8b990b2..437892af73 100644
--- a/packages/lambda/src/api/get-functions.ts
+++ b/packages/lambda/src/api/get-functions.ts
@@ -1,8 +1,8 @@
import type {FunctionConfiguration} from '@aws-sdk/client-lambda';
import {ListFunctionsCommand} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
+import type {AwsRegion} from '../regions';
import {getLambdaClient} from '../shared/aws-clients';
import {
DEFAULT_EPHEMERAL_STORAGE_IN_MB,
diff --git a/packages/lambda/src/api/get-or-create-bucket.ts b/packages/lambda/src/api/get-or-create-bucket.ts
index fd1f4ce88c..c953335e5c 100644
--- a/packages/lambda/src/api/get-or-create-bucket.ts
+++ b/packages/lambda/src/api/get-or-create-bucket.ts
@@ -1,4 +1,5 @@
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {REMOTION_BUCKET_PREFIX} from '../shared/constants';
import {applyLifeCyleOperation} from '../shared/lifecycle-rules';
import {makeBucketName} from '../shared/validate-bucketname';
@@ -8,13 +9,13 @@ import {getRemotionS3Buckets} from './get-buckets';
type GetOrCreateBucketInputInner = {
region: AwsRegion;
enableFolderExpiry: boolean | null;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
};
export type GetOrCreateBucketInput = {
region: AwsRegion;
enableFolderExpiry?: boolean;
- customCredentials?: CustomCredentials;
+ customCredentials?: CustomCredentials<AwsRegion>;
};
export type GetOrCreateBucketOutput = {
diff --git a/packages/lambda/src/api/get-regions.ts b/packages/lambda/src/api/get-regions.ts
index 024188ce28..6b3360eaf6 100644
--- a/packages/lambda/src/api/get-regions.ts
+++ b/packages/lambda/src/api/get-regions.ts
@@ -1,6 +1,5 @@
-import type {AwsRegion} from '@remotion/serverless/client';
-import {DEFAULT_AWS_REGIONS} from '@remotion/serverless/client';
-import {AWS_REGIONS} from '../regions';
+import type {AwsRegion} from '../regions';
+import {AWS_REGIONS, DEFAULT_AWS_REGIONS} from '../regions';
type Options = {
enabledByDefaultOnly?: boolean;
diff --git a/packages/lambda/src/api/get-render-progress.ts b/packages/lambda/src/api/get-render-progress.ts
index 9b2fd67fb5..813d357336 100644
--- a/packages/lambda/src/api/get-render-progress.ts
+++ b/packages/lambda/src/api/get-render-progress.ts
@@ -1,6 +1,7 @@
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {callLambda} from '../shared/call-lambda';
import type {RenderProgress} from '../shared/constants';
import {getRenderProgressPayload} from './make-lambda-payload';
@@ -11,7 +12,7 @@ export type GetRenderProgressInput = {
renderId: string;
region: AwsRegion;
logLevel?: LogLevel;
- s3OutputProvider?: CustomCredentials;
+ s3OutputProvider?: CustomCredentials<AwsRegion>;
};
/**
diff --git a/packages/lambda/src/api/get-sites.ts b/packages/lambda/src/api/get-sites.ts
index abcaf4c4c9..44ca605589 100644
--- a/packages/lambda/src/api/get-sites.ts
+++ b/packages/lambda/src/api/get-sites.ts
@@ -1,5 +1,5 @@
-import type {AwsRegion} from '@remotion/serverless/client';
import {lambdaLs} from '../functions/helpers/io';
+import type {AwsRegion} from '../regions';
import {getSitesKey} from '../shared/constants';
import {getAccountId} from '../shared/get-account-id';
import {makeS3ServeUrl} from '../shared/make-s3-url';
diff --git a/packages/lambda/src/api/iam-validation/simulate-rule.ts b/packages/lambda/src/api/iam-validation/simulate-rule.ts
index a99c71cbfb..980bfa8775 100644
--- a/packages/lambda/src/api/iam-validation/simulate-rule.ts
+++ b/packages/lambda/src/api/iam-validation/simulate-rule.ts
@@ -1,5 +1,5 @@
import {SimulatePrincipalPolicyCommand} from '@aws-sdk/client-iam';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../../regions';
import {getIamClient} from '../../shared/aws-clients';
export type EvalDecision = 'allowed' | 'explicitDeny' | 'implicitDeny';
diff --git a/packages/lambda/src/api/iam-validation/simulate.ts b/packages/lambda/src/api/iam-validation/simulate.ts
index 394515c21d..50c8ab2f4d 100644
--- a/packages/lambda/src/api/iam-validation/simulate.ts
+++ b/packages/lambda/src/api/iam-validation/simulate.ts
@@ -1,5 +1,5 @@
import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../../regions';
import {getStsClient} from '../../shared/aws-clients';
import type {EvalDecision, SimulationResult} from './simulate-rule';
import {simulateRule} from './simulate-rule';
diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.ts
index 2b3c9a21c4..72d683fce8 100644
--- a/packages/lambda/src/api/make-lambda-payload.ts
+++ b/packages/lambda/src/api/make-lambda-payload.ts
@@ -56,7 +56,7 @@ export type InnerRenderMediaOnLambdaInput = {
framesPerLambda: number | null;
logLevel: LogLevel;
frameRange: FrameRange | null;
- outName: OutNameInput | null;
+ outName: OutNameInput<AwsRegion> | null;
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
scale: number;
@@ -123,7 +123,7 @@ export const makeLambdaRenderMediaPayload = async ({
deleteAfter,
colorSpace,
preferLossless,
-}: InnerRenderMediaOnLambdaInput): Promise<LambdaStartPayload> => {
+}: InnerRenderMediaOnLambdaInput): Promise<LambdaStartPayload<AwsRegion>> => {
const actualCodec = validateLambdaCodec(codec);
validateServeUrl(serveUrl);
validateFramesPerLambda({
@@ -198,7 +198,7 @@ export const getRenderProgressPayload = ({
renderId,
s3OutputProvider,
logLevel,
-}: GetRenderProgressInput): LambdaStatusPayload => {
+}: GetRenderProgressInput): LambdaStatusPayload<AwsRegion> => {
return {
type: ServerlessRoutines.status,
bucketName,
@@ -233,7 +233,7 @@ export const makeLambdaRenderStillPayload = async ({
offthreadVideoCacheSizeInBytes,
deleteAfter,
}: RenderStillOnLambdaNonNullInput): Promise<
- LambdaPayloads[ServerlessRoutines.still]
+ LambdaPayloads<AwsRegion>[ServerlessRoutines.still]
> => {
if (quality) {
throw new Error(
diff --git a/packages/lambda/src/api/mock-functions.ts b/packages/lambda/src/api/mock-functions.ts
index 856dd8a54f..789803ddbf 100644
--- a/packages/lambda/src/api/mock-functions.ts
+++ b/packages/lambda/src/api/mock-functions.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import type {FunctionInfo} from './get-function-info';
export let mockFunctionsStore: (FunctionInfo & {
diff --git a/packages/lambda/src/api/presign-url.ts b/packages/lambda/src/api/presign-url.ts
index 1096f548ec..43ba214762 100644
--- a/packages/lambda/src/api/presign-url.ts
+++ b/packages/lambda/src/api/presign-url.ts
@@ -1,6 +1,6 @@
import {GetObjectCommand, HeadObjectCommand} from '@aws-sdk/client-s3';
import {getSignedUrl} from '@aws-sdk/s3-request-presigner';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
import {validateBucketName} from '../shared/validate-bucketname';
import {validatePresignExpiration} from '../shared/validate-presign-expiration';
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index 9b21f3c85e..732e35f6d7 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -10,7 +10,6 @@ import type {
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
import type {
- AwsRegion,
DownloadBehavior,
LambdaCodec,
OutNameInput,
@@ -18,6 +17,7 @@ import type {
WebhookOption,
} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {callLambda} from '../shared/call-lambda';
import {
getCloudwatchMethodUrl,
@@ -50,7 +50,7 @@ export type RenderMediaOnLambdaInput = {
maxRetries?: number;
framesPerLambda?: number;
frameRange?: FrameRange;
- outName?: OutNameInput;
+ outName?: OutNameInput<AwsRegion>;
chromiumOptions?: Omit<ChromiumOptions, 'enableMultiProcessOnLinux'>;
scale?: number;
everyNthFrame?: number;
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index 9747996e5b..e7d55f5488 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -5,13 +5,14 @@ import type {
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
-import type {AwsRegion, DownloadBehavior} from '@remotion/serverless/client';
+import type {DownloadBehavior} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
import type {ReceivedArtifact} from '../functions/helpers/overall-render-progress';
import type {RenderStillLambdaResponsePayload} from '../functions/still';
import {callLambdaWithStreaming} from '../shared/call-lambda';
import type {OutNameInput, Privacy} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import type {CostsInfo} from '../shared/constants';
import {DEFAULT_MAX_RETRIES} from '../shared/constants';
import {
@@ -38,7 +39,7 @@ type OptionalParameters = {
*/
quality?: never;
frame: number;
- outName: OutNameInput | null;
+ outName: OutNameInput<AwsRegion> | null;
chromiumOptions: ChromiumOptions;
downloadBehavior: DownloadBehavior;
forceWidth: number | null;
diff --git a/packages/lambda/src/api/upload-dir.ts b/packages/lambda/src/api/upload-dir.ts
index dd45e53dcd..0817314c88 100644
--- a/packages/lambda/src/api/upload-dir.ts
+++ b/packages/lambda/src/api/upload-dir.ts
@@ -1,9 +1,10 @@
import {Upload} from '@aws-sdk/lib-storage';
-import type {AwsRegion, Privacy} from '@remotion/serverless/client';
+import type {Privacy} from '@remotion/serverless/client';
import mimeTypes from 'mime-types';
import type {Dirent} from 'node:fs';
import {createReadStream, promises as fs} from 'node:fs';
import path from 'node:path';
+import type {AwsRegion} from '../regions';
import {getS3Client} from '../shared/aws-clients';
import {makeS3Key} from '../shared/make-s3-key';
import {pLimit} from '../shared/p-limit';
diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.ts
index 49abdac139..9c62dbb68c 100644
--- a/packages/lambda/src/cli/args.ts
+++ b/packages/lambda/src/cli/args.ts
@@ -1,8 +1,8 @@
import {CliInternals} from '@remotion/cli';
import type {BrowserSafeApis} from '@remotion/renderer/client';
-import type {DeleteAfter} from '../client';
+import type {AwsRegion, DeleteAfter} from '../client';
-import type {AwsRegion, Privacy} from '@remotion/serverless/client';
+import type {Privacy} from '@remotion/serverless/client';
type LambdaCommandLineOptions = {
help: boolean;
diff --git a/packages/lambda/src/cli/get-aws-region.ts b/packages/lambda/src/cli/get-aws-region.ts
index da13fc5d5b..0e2b58fdda 100644
--- a/packages/lambda/src/cli/get-aws-region.ts
+++ b/packages/lambda/src/cli/get-aws-region.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {DEFAULT_REGION} from '../shared/constants';
import {isInsideLambda} from '../shared/is-in-lambda';
import {validateAwsRegion} from '../shared/validate-aws-region';
diff --git a/packages/lambda/src/client.ts b/packages/lambda/src/client.ts
index 7ea3632db3..96e015144d 100644
--- a/packages/lambda/src/client.ts
+++ b/packages/lambda/src/client.ts
@@ -27,12 +27,12 @@ import type {RenderProgress} from './shared/constants';
import type {WebhookPayload} from './shared/invoke-webhook';
export {CustomCredentials, DeleteAfter} from '@remotion/serverless/client';
-export type {AwsRegion} from '@remotion/serverless/client';
export {
GetAwsClientInput,
GetAwsClientOutput,
getAwsClient,
} from './api/get-aws-client';
+export type {AwsRegion} from './regions';
export {
deleteRender,
getCompositionsOnLambda,
diff --git a/packages/lambda/src/functions/aws-implementation.ts b/packages/lambda/src/functions/aws-implementation.ts
index c032be8a01..398a2ad0e0 100644
--- a/packages/lambda/src/functions/aws-implementation.ts
+++ b/packages/lambda/src/functions/aws-implementation.ts
@@ -1,5 +1,5 @@
import type {ProviderSpecifics} from '@remotion/serverless';
-import type {AwsRegion} from '../client';
+import type {AwsRegion} from '../regions';
import {getCurrentRegionInFunction} from './helpers/get-current-region';
if (
@@ -19,4 +19,5 @@ export const awsImplementation: ProviderSpecifics<AwsRegion> = {
return '/opt/bin/chromium';
},
getCurrentRegionInFunction,
+ regionType: 'us-east-1',
};
diff --git a/packages/lambda/src/functions/compositions.ts b/packages/lambda/src/functions/compositions.ts
index 45502b6c1c..eda23807a0 100644
--- a/packages/lambda/src/functions/compositions.ts
+++ b/packages/lambda/src/functions/compositions.ts
@@ -14,7 +14,7 @@ type Options = {
};
export const compositionsHandler = async <Region extends string>(
- lambdaParams: LambdaPayload,
+ lambdaParams: LambdaPayload<Region>,
options: Options,
providerSpecifics: ProviderSpecifics<Region>,
) => {
diff --git a/packages/lambda/src/functions/helpers/create-post-render-data.ts b/packages/lambda/src/functions/helpers/create-post-render-data.ts
index e90e2bd7cc..7a29547f04 100644
--- a/packages/lambda/src/functions/helpers/create-post-render-data.ts
+++ b/packages/lambda/src/functions/helpers/create-post-render-data.ts
@@ -1,5 +1,5 @@
-import type {AwsRegion} from '@remotion/serverless/client';
import {estimatePrice} from '../../api/estimate-price';
+import type {AwsRegion} from '../../regions';
import type {PostRenderData, RenderMetadata} from '../../shared/constants';
import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../../shared/constants';
import {
diff --git a/packages/lambda/src/functions/helpers/expected-out-name.ts b/packages/lambda/src/functions/helpers/expected-out-name.ts
index b0e8ce05a6..f9970066db 100644
--- a/packages/lambda/src/functions/helpers/expected-out-name.ts
+++ b/packages/lambda/src/functions/helpers/expected-out-name.ts
@@ -9,9 +9,9 @@ import {customOutName, outName, outStillName} from '../../defaults';
import {validateOutname} from '../../shared/validate-outname';
import {getCustomOutName} from './get-custom-out-name';
-export const getCredentialsFromOutName = (
- name: OutNameInput | null,
-): CustomCredentials | null => {
+export const getCredentialsFromOutName = <Region extends string>(
+ name: OutNameInput<Region> | null,
+): CustomCredentials<Region> | null => {
if (typeof name === 'string') {
return null;
}
@@ -27,11 +27,11 @@ export const getCredentialsFromOutName = (
return name.s3OutputProvider ?? null;
};
-export const getExpectedOutName = (
+export const getExpectedOutName = <Region extends string>(
renderMetadata: RenderMetadata,
bucketName: string,
- customCredentials: CustomCredentials | null,
-): OutNameOutput => {
+ customCredentials: CustomCredentials<Region> | null,
+): OutNameOutput<Region> => {
const outNameValue = getCustomOutName({
customCredentials,
renderMetadata,
diff --git a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
index 5b959b61cf..fba71c1dbc 100644
--- a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
+++ b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
@@ -1,5 +1,6 @@
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {ROLE_NAME} from '../../api/iam-validation/suggested-policy';
+import type {AwsRegion} from '../../regions';
import type {RenderMetadata} from '../../shared/constants';
import {getExpectedOutName} from './expected-out-name';
import {getOutputUrlFromMetadata} from './get-output-url-from-metadata';
@@ -18,7 +19,7 @@ export const findOutputFileInBucket = async ({
region: AwsRegion;
renderMetadata: RenderMetadata;
bucketName: string;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}): Promise<OutputFileMetadata | null> => {
if (!renderMetadata) {
throw new Error('unexpectedly did not get renderMetadata');
diff --git a/packages/lambda/src/functions/helpers/get-current-region.ts b/packages/lambda/src/functions/helpers/get-current-region.ts
index 95bf658181..1acf893894 100644
--- a/packages/lambda/src/functions/helpers/get-current-region.ts
+++ b/packages/lambda/src/functions/helpers/get-current-region.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../../regions';
import {isInsideLambda} from '../../shared/is-in-lambda';
export const getCurrentRegionInFunction = () => {
diff --git a/packages/lambda/src/functions/helpers/get-custom-out-name.ts b/packages/lambda/src/functions/helpers/get-custom-out-name.ts
index 88c2fb5aba..e2baa344f7 100644
--- a/packages/lambda/src/functions/helpers/get-custom-out-name.ts
+++ b/packages/lambda/src/functions/helpers/get-custom-out-name.ts
@@ -4,13 +4,13 @@ import type {
} from '@remotion/serverless/client';
import type {RenderMetadata} from '../../defaults';
-export const getCustomOutName = ({
+export const getCustomOutName = <Region extends string>({
renderMetadata,
customCredentials,
}: {
renderMetadata: RenderMetadata;
- customCredentials: CustomCredentials | null;
-}): OutNameInput | null => {
+ customCredentials: CustomCredentials<Region> | null;
+}): OutNameInput<Region> | null => {
if (!renderMetadata.outName) {
return null;
}
diff --git a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts b/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
index da69ccdfc4..f6a4ebb055 100644
--- a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
+++ b/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
@@ -1,12 +1,13 @@
import type {CustomCredentials} from '@remotion/serverless/client';
import type {RenderMetadata} from '../../defaults';
+import type {AwsRegion} from '../../regions';
import {getExpectedOutName} from './expected-out-name';
import {getCurrentRegionInFunction} from './get-current-region';
export const getOutputUrlFromMetadata = (
renderMetadata: RenderMetadata,
bucketName: string,
- customCredentials: CustomCredentials | null,
+ customCredentials: CustomCredentials<AwsRegion> | null,
) => {
const {key, renderBucketName} = getExpectedOutName(
renderMetadata,
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index 4d29d38778..02c3a2e2b2 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -1,6 +1,7 @@
import {RenderInternals} from '@remotion/renderer';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
+import type {AwsRegion} from '../../regions';
import type {CleanupInfo, RenderProgress} from '../../shared/constants';
import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../../shared/constants';
import {truthy} from '../../shared/truthy';
@@ -15,7 +16,7 @@ import {makeTimeoutError} from './make-timeout-error';
import {lambdaRenderHasAudioVideo} from './render-has-audio-video';
import type {EnhancedErrorInfo} from './write-lambda-error';
-export const getProgress = async ({
+export const getProgress = async <Region extends string>({
bucketName,
renderId,
expectedBucketOwner,
@@ -30,7 +31,7 @@ export const getProgress = async ({
region: AwsRegion;
memorySizeInMb: number;
timeoutInMilliseconds: number;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<Region> | null;
}): Promise<RenderProgress> => {
const overallProgress = await getOverallProgressS3({
renderId,
diff --git a/packages/lambda/src/functions/helpers/io.ts b/packages/lambda/src/functions/helpers/io.ts
index 1fe90da46a..dcf6ee9010 100644
--- a/packages/lambda/src/functions/helpers/io.ts
+++ b/packages/lambda/src/functions/helpers/io.ts
@@ -7,7 +7,6 @@ import {
PutObjectCommand,
} from '@aws-sdk/client-s3';
import type {
- AwsRegion,
CustomCredentials,
DownloadBehavior,
Privacy,
@@ -15,6 +14,7 @@ import type {
import mimeTypes from 'mime-types';
import type {ReadStream} from 'node:fs';
import type {Readable} from 'stream';
+import type {AwsRegion} from '../../regions';
import {getS3Client} from '../../shared/aws-clients';
import {getContentDispositionHeader} from '../../shared/content-disposition-header';
@@ -88,7 +88,7 @@ export const lambdaDeleteFile = async ({
region: AwsRegion;
bucketName: string;
key: string;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}) => {
await getS3Client(region, customCredentials).send(
new DeleteObjectCommand({
@@ -98,7 +98,7 @@ export const lambdaDeleteFile = async ({
);
};
-type LambdaWriteFileInput = {
+type LambdaWriteFileInput<Region extends string> = {
bucketName: string;
key: string;
body: ReadStream | string | Uint8Array;
@@ -106,10 +106,10 @@ type LambdaWriteFileInput = {
privacy: Privacy;
expectedBucketOwner: string | null;
downloadBehavior: DownloadBehavior | null;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<Region> | null;
};
-const tryLambdaWriteFile = async ({
+const tryLambdaWriteFile = async <Region extends string>({
bucketName,
key,
body,
@@ -118,8 +118,11 @@ const tryLambdaWriteFile = async ({
expectedBucketOwner,
downloadBehavior,
customCredentials,
-}: LambdaWriteFileInput): Promise<void> => {
- await getS3Client(region, customCredentials).send(
+}: LambdaWriteFileInput<Region>): Promise<void> => {
+ await getS3Client(
+ region,
+ customCredentials as CustomCredentials<AwsRegion>,
+ ).send(
new PutObjectCommand({
Bucket: bucketName,
Key: key,
@@ -139,8 +142,8 @@ const tryLambdaWriteFile = async ({
);
};
-export const lambdaWriteFile = async (
- params: LambdaWriteFileInput & {
+export const lambdaWriteFile = async <Region extends string>(
+ params: LambdaWriteFileInput<Region> & {
retries?: number;
},
): Promise<void> => {
@@ -198,7 +201,7 @@ export const lambdaHeadCommand = async ({
bucketName: string;
key: string;
region: AwsRegion;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}): Promise<{
LastModified?: Date | undefined;
ContentLength?: number | undefined;
diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.ts
index 89c8d72611..ac66f9c930 100644
--- a/packages/lambda/src/functions/helpers/merge-chunks.ts
+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts
@@ -7,6 +7,7 @@ import type {
SerializedInputProps,
} from '@remotion/serverless/client';
import fs from 'fs';
+import type {AwsRegion} from '../../regions';
import type {PostRenderData, RenderMetadata} from '../../shared/constants';
import {cleanupProps} from './cleanup-props';
import {concatVideos} from './concat-videos';
@@ -18,7 +19,9 @@ import {lambdaWriteFile} from './io';
import type {OverallProgressHelper} from './overall-render-progress';
import {timer} from './timer';
-export const mergeChunksAndFinishRender = async (options: {
+export const mergeChunksAndFinishRender = async <
+ Region extends string,
+>(options: {
bucketName: string;
renderId: string;
expectedBucketOwner: string;
@@ -29,7 +32,7 @@ export const mergeChunksAndFinishRender = async (options: {
numberOfGifLoops: number | null;
audioCodec: AudioCodec | null;
renderBucketName: string;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<Region> | null;
downloadBehavior: DownloadBehavior;
key: string;
privacy: Privacy;
@@ -108,7 +111,7 @@ export const mergeChunksAndFinishRender = async (options: {
const {url: outputUrl} = getOutputUrlFromMetadata(
options.renderMetadata,
options.bucketName,
- options.customCredentials,
+ options.customCredentials as CustomCredentials<AwsRegion>,
);
const postRenderData = createPostRenderData({
diff --git a/packages/lambda/src/functions/helpers/read-with-progress.ts b/packages/lambda/src/functions/helpers/read-with-progress.ts
index 1adcc3a38b..2ca4dd4b75 100644
--- a/packages/lambda/src/functions/helpers/read-with-progress.ts
+++ b/packages/lambda/src/functions/helpers/read-with-progress.ts
@@ -2,7 +2,8 @@ import {GetObjectCommand} from '@aws-sdk/client-s3';
import {getSignedUrl} from '@aws-sdk/s3-request-presigner';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
+import type {AwsRegion} from '../../regions';
import {getS3Client} from '../../shared/aws-clients';
export type LambdaReadFileProgress = (progress: {
@@ -27,7 +28,7 @@ export const lambdaDownloadFileWithProgress = async ({
expectedBucketOwner: string;
outputPath: string;
onProgress: LambdaReadFileProgress;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
logLevel: LogLevel;
}): Promise<{sizeInBytes: number; to: string}> => {
const client = getS3Client(region, customCredentials);
diff --git a/packages/lambda/src/functions/helpers/stream-renderer.ts b/packages/lambda/src/functions/helpers/stream-renderer.ts
index 8ba0b633cb..ab075cdb6e 100644
--- a/packages/lambda/src/functions/helpers/stream-renderer.ts
+++ b/packages/lambda/src/functions/helpers/stream-renderer.ts
@@ -20,7 +20,7 @@ type StreamRendererResponse =
shouldRetry: boolean;
};
-const streamRenderer = ({
+const streamRenderer = <Region extends string>({
payload,
functionName,
outdir,
@@ -29,7 +29,7 @@ const streamRenderer = ({
logLevel,
onArtifact,
}: {
- payload: LambdaPayload;
+ payload: LambdaPayload<Region>;
functionName: string;
outdir: string;
overallProgress: OverallProgressHelper;
@@ -178,7 +178,7 @@ const streamRenderer = ({
});
};
-export const streamRendererFunctionWithRetry = async ({
+export const streamRendererFunctionWithRetry = async <Region extends string>({
payload,
files,
functionName,
@@ -187,7 +187,7 @@ export const streamRendererFunctionWithRetry = async ({
logLevel,
onArtifact,
}: {
- payload: LambdaPayload;
+ payload: LambdaPayload<Region>;
functionName: string;
outdir: string;
overallProgress: OverallProgressHelper;
diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.ts
index 6bf87d1916..82f7e200e3 100644
--- a/packages/lambda/src/functions/index.ts
+++ b/packages/lambda/src/functions/index.ts
@@ -34,7 +34,7 @@ const innerHandler = async <Region extends string>({
context,
providerSpecifics,
}: {
- params: LambdaPayload;
+ params: LambdaPayload<Region>;
responseWriter: ResponseStreamWriter;
context: RequestContext;
providerSpecifics: ProviderSpecifics<Region>;
@@ -293,7 +293,7 @@ export type OrError<T> =
};
export const routine = async <Region extends string>(
- params: LambdaPayload,
+ params: LambdaPayload<Region>,
responseStream: ResponseStream,
context: RequestContext,
providerSpecifics: ProviderSpecifics<Region>,
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index b48fbec81a..b973b3e789 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -3,12 +3,16 @@ import type {EmittedArtifact, LogOptions} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
import type {ProviderSpecifics} from '@remotion/serverless';
import {forgetBrowserEventLoop, getBrowserInstance} from '@remotion/serverless';
-import type {LambdaPayload} from '@remotion/serverless/client';
+import type {
+ CustomCredentials,
+ LambdaPayload,
+} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
import {existsSync, mkdirSync, rmSync} from 'fs';
import {join} from 'path';
import {VERSION} from 'remotion/version';
import {type EventEmitter} from 'stream';
+import type {AwsRegion} from '../regions';
import {
compressInputProps,
decompressInputProps,
@@ -60,7 +64,7 @@ const innerLaunchHandler = async <Region extends string>({
providerSpecifics,
}: {
functionName: string;
- params: LambdaPayload;
+ params: LambdaPayload<Region>;
options: Options;
overallProgress: OverallProgressHelper;
registerCleanupTask: (cleanupTask: CleanupTask) => void;
@@ -225,7 +229,7 @@ const innerLaunchHandler = async <Region extends string>({
const progressEveryNthFrame = Math.ceil(chunks.length / 15);
const lambdaPayloads = chunks.map((chunkPayload) => {
- const payload: LambdaPayload = {
+ const payload: LambdaPayload<Region> = {
type: ServerlessRoutines.renderer,
frameRange: chunkPayload,
serveUrl: params.serveUrl,
@@ -329,7 +333,7 @@ const innerLaunchHandler = async <Region extends string>({
);
const output = await findOutputFileInBucket({
bucketName: params.bucketName,
- customCredentials,
+ customCredentials: customCredentials as CustomCredentials<AwsRegion>,
renderMetadata,
region: getCurrentRegionInFunction(),
});
@@ -468,7 +472,7 @@ const innerLaunchHandler = async <Region extends string>({
type CleanupTask = () => Promise<unknown>;
export const launchHandler = async <Region extends string>(
- params: LambdaPayload,
+ params: LambdaPayload<Region>,
options: Options,
providerSpecifics: ProviderSpecifics<Region>,
): Promise<{
diff --git a/packages/lambda/src/functions/progress.ts b/packages/lambda/src/functions/progress.ts
index 31d863e5a6..4ad24055da 100644
--- a/packages/lambda/src/functions/progress.ts
+++ b/packages/lambda/src/functions/progress.ts
@@ -11,8 +11,8 @@ type Options = {
retriesRemaining: number;
};
-export const progressHandler = async (
- lambdaParams: LambdaPayload,
+export const progressHandler = async <Region extends string>(
+ lambdaParams: LambdaPayload<Region>,
options: Options,
): Promise<RenderProgress> => {
if (lambdaParams.type !== ServerlessRoutines.status) {
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index 2658842d0b..09ea6999bc 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -43,7 +43,7 @@ const renderHandler = async <Region extends string>({
onStream,
platformImplementation: providerSpecifics,
}: {
- params: LambdaPayload;
+ params: LambdaPayload<Region>;
options: Options;
logs: BrowserLog[];
onStream: OnStream;
@@ -393,7 +393,7 @@ export const rendererHandler = async <Region extends string>({
providerSpecifics,
requestContext,
}: {
- params: LambdaPayload;
+ params: LambdaPayload<Region>;
options: Options;
onStream: OnStream;
requestContext: RequestContext;
diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.ts
index 6f886fd610..48c33d269a 100644
--- a/packages/lambda/src/functions/start.ts
+++ b/packages/lambda/src/functions/start.ts
@@ -19,7 +19,10 @@ type Options = {
timeoutInMilliseconds: number;
};
-export const startHandler = async (params: LambdaPayload, options: Options) => {
+export const startHandler = async <Region extends string>(
+ params: LambdaPayload<Region>,
+ options: Options,
+) => {
if (params.type !== ServerlessRoutines.start) {
throw new TypeError('Expected type start');
}
@@ -70,7 +73,7 @@ export const startHandler = async (params: LambdaPayload, options: Options) => {
customCredentials: null,
});
- const payload: LambdaPayload = {
+ const payload: LambdaPayload<Region> = {
type: ServerlessRoutines.launch,
framesPerLambda: params.framesPerLambda,
composition: params.composition,
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index 12c0de13be..e352bfe92f 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -5,7 +5,10 @@ import {
getBrowserInstance,
type ProviderSpecifics,
} from '@remotion/serverless';
-import type {LambdaPayload} from '@remotion/serverless/client';
+import type {
+ CustomCredentials,
+ LambdaPayload,
+} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
import fs from 'node:fs';
import path from 'node:path';
@@ -13,6 +16,7 @@ import {NoReactInternals} from 'remotion/no-react';
import {VERSION} from 'remotion/version';
import {estimatePrice} from '../api/estimate-price';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
+import type {AwsRegion} from '../regions';
import {cleanupSerializedInputProps} from '../shared/cleanup-serialized-input-props';
import {decompressInputProps} from '../shared/compress-props';
import type {CostsInfo, RenderMetadata} from '../shared/constants';
@@ -42,7 +46,7 @@ import {getTmpDirStateIfENoSp} from './helpers/write-lambda-error';
import type {OnStream} from './streaming/streaming';
type Options<Region extends string> = {
- params: LambdaPayload;
+ params: LambdaPayload<Region>;
renderId: string;
expectedBucketOwner: string;
onStream: OnStream;
@@ -321,7 +325,7 @@ const innerStillHandler = async <Region extends string>({
const {key: outKey, url} = getOutputUrlFromMetadata(
renderMetadata,
bucketName,
- customCredentials,
+ customCredentials as CustomCredentials<AwsRegion>,
);
const payload: RenderStillLambdaResponsePayload = {
diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.ts
index a469d64b22..88a884cfd3 100644
--- a/packages/lambda/src/index.ts
+++ b/packages/lambda/src/index.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import type {DeleteFunctionInput} from './api/delete-function';
import {deleteFunction} from './api/delete-function';
import type {DeleteRenderInput} from './api/delete-render';
@@ -70,6 +70,7 @@ import type {
LambdaErrorInfo,
} from './functions/helpers/write-lambda-error';
import {LambdaInternals} from './internals';
+import type {AwsRegion} from './regions';
import type {RenderProgress} from './shared/constants';
import type {WebhookPayload} from './shared/invoke-webhook';
diff --git a/packages/lambda/src/pricing/price-per-1-s.ts b/packages/lambda/src/pricing/price-per-1-s.ts
index 1855c323a7..7a03e118d2 100644
--- a/packages/lambda/src/pricing/price-per-1-s.ts
+++ b/packages/lambda/src/pricing/price-per-1-s.ts
@@ -1,6 +1,6 @@
// From https://calculator.aws/pricing/2.0/meteredUnitMaps/lambda/USD/current/lambda.json
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
export const pricing: {
[key in AwsRegion]: {
diff --git a/packages/lambda/src/regions.ts b/packages/lambda/src/regions.ts
index 8715bcf446..8bbae45f60 100644
--- a/packages/lambda/src/regions.ts
+++ b/packages/lambda/src/regions.ts
@@ -1,3 +1,45 @@
-import {AWS_REGIONS} from '@remotion/serverless/client';
+export const DEFAULT_AWS_REGIONS = [
+ 'eu-central-1',
+ 'eu-west-1',
+ 'eu-west-2',
+ 'eu-west-3',
+ 'eu-north-1',
+ 'us-east-1', // N. Virginia
+ 'us-east-2', // Ohio;
+ 'us-west-1',
+ 'us-west-2', // Oregon
+ 'ap-south-1',
+ 'ap-southeast-1',
+ 'ap-southeast-2',
+ 'ap-northeast-1',
+ 'ap-northeast-2',
+ 'ap-northeast-3',
+ 'ca-central-1',
+ 'sa-east-1',
+] as const;
-export {AWS_REGIONS};
+export const AWS_REGIONS = [
+ 'eu-central-1',
+ 'eu-west-1',
+ 'eu-west-2',
+ 'eu-west-3',
+ 'eu-south-1',
+ 'eu-north-1',
+ 'us-east-1', // N. Virginia
+ 'us-east-2', // Ohio;
+ 'us-west-1',
+ 'us-west-2', // Oregon
+ 'af-south-1',
+ 'ap-south-1',
+ 'ap-east-1',
+ 'ap-southeast-1',
+ 'ap-southeast-2',
+ 'ap-northeast-1',
+ 'ap-northeast-2',
+ 'ap-northeast-3',
+ 'ca-central-1',
+ 'me-south-1',
+ 'sa-east-1',
+] as const;
+
+export type AwsRegion = (typeof AWS_REGIONS)[number];
diff --git a/packages/lambda/src/shared/aws-clients.ts b/packages/lambda/src/shared/aws-clients.ts
index 41dfe26adf..b7b214dac5 100644
--- a/packages/lambda/src/shared/aws-clients.ts
+++ b/packages/lambda/src/shared/aws-clients.ts
@@ -5,8 +5,9 @@ import {S3Client} from '@aws-sdk/client-s3';
import {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';
import {STSClient} from '@aws-sdk/client-sts';
import {fromIni} from '@aws-sdk/credential-providers';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {random} from 'remotion/no-react';
+import type {AwsRegion} from '../regions';
import {checkCredentials} from './check-credentials';
import {MAX_FUNCTIONS_PER_RENDER} from './constants';
import {isInsideLambda} from './is-in-lambda';
@@ -100,7 +101,7 @@ const getCredentialsHash = ({
service,
}: {
region: AwsRegion;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
service: keyof ServiceMapping;
}): string => {
const hashComponents: {[key: string]: unknown} = {};
@@ -158,7 +159,7 @@ export const getServiceClient = <T extends keyof ServiceMapping>({
}: {
region: AwsRegion;
service: T;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}): ServiceMapping[T] => {
const Client = (() => {
if (service === 'cloudwatch') {
@@ -252,7 +253,7 @@ export const getCloudWatchLogsClient = (
export const getS3Client = (
region: AwsRegion,
- customCredentials: CustomCredentials | null,
+ customCredentials: CustomCredentials<AwsRegion> | null,
): S3Client => {
return getServiceClient({
region: customCredentials?.region ?? region,
diff --git a/packages/lambda/src/shared/call-lambda.ts b/packages/lambda/src/shared/call-lambda.ts
index 7477f9025f..3a41efd6c5 100644
--- a/packages/lambda/src/shared/call-lambda.ts
+++ b/packages/lambda/src/shared/call-lambda.ts
@@ -8,7 +8,6 @@ import {
InvokeWithResponseStreamCommand,
} from '@aws-sdk/client-lambda';
import type {
- AwsRegion,
LambdaPayloads,
ServerlessRoutines,
} from '@remotion/serverless/client';
@@ -23,6 +22,7 @@ import {
formatMap,
messageTypeIdToMessageType,
} from '../functions/streaming/streaming';
+import type {AwsRegion} from '../regions';
import {getLambdaClient} from './aws-clients';
import type {LambdaReturnValues} from './return-values';
@@ -31,7 +31,7 @@ const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
type Options<T extends ServerlessRoutines> = {
functionName: string;
type: T;
- payload: Omit<LambdaPayloads[T], 'type'>;
+ payload: Omit<LambdaPayloads<AwsRegion>[T], 'type'>;
region: AwsRegion;
timeoutInTest: number;
};
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index b138f2d9ac..1edf10d002 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -4,7 +4,6 @@ import type {
VideoImageFormat,
} from '@remotion/renderer';
import type {
- AwsRegion,
CustomCredentials,
CustomCredentialsWithoutSensitiveData,
DeleteAfter,
@@ -17,6 +16,7 @@ import type {
import type {ChunkRetry} from '../functions/helpers/get-retry-stats';
import type {ReceivedArtifact} from '../functions/helpers/overall-render-progress';
import type {EnhancedErrorInfo} from '../functions/helpers/write-lambda-error';
+import type {AwsRegion} from '../regions';
import type {ExpensiveChunk} from './get-most-expensive-chunks';
export const MIN_MEMORY = 512;
@@ -61,10 +61,10 @@ export type OutNameInputWithoutCredentials =
s3OutputProvider?: CustomCredentialsWithoutSensitiveData;
};
-export type OutNameOutput = {
+export type OutNameOutput<Region extends string> = {
renderBucketName: string;
key: string;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<Region> | null;
};
export const getSitesKey = (siteId: string) => `sites/${siteId}`;
@@ -74,11 +74,11 @@ export const outStillName = (renderId: string, imageFormat: StillImageFormat) =>
`${rendersPrefix(renderId)}/out.${imageFormat}`;
export const artifactName = (renderId: string, name: string) =>
`${rendersPrefix(renderId)}/artifacts/${name}`;
-export const customOutName = (
+export const customOutName = <Region extends string>(
renderId: string,
bucketName: string,
- name: OutNameInput,
-): OutNameOutput => {
+ name: OutNameInput<Region>,
+): OutNameOutput<Region> => {
if (typeof name === 'string') {
return {
renderBucketName: bucketName,
diff --git a/packages/lambda/src/shared/convert-to-serve-url.ts b/packages/lambda/src/shared/convert-to-serve-url.ts
index c3b4b6ae50..000ec758bd 100644
--- a/packages/lambda/src/shared/convert-to-serve-url.ts
+++ b/packages/lambda/src/shared/convert-to-serve-url.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {DOCS_URL} from './docs-url';
export const convertToServeUrl = ({
diff --git a/packages/lambda/src/shared/get-account-id.ts b/packages/lambda/src/shared/get-account-id.ts
index f330123900..fea7c106dc 100644
--- a/packages/lambda/src/shared/get-account-id.ts
+++ b/packages/lambda/src/shared/get-account-id.ts
@@ -1,5 +1,5 @@
import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {getStsClient} from './aws-clients';
import {validateAwsRegion} from './validate-aws-region';
diff --git a/packages/lambda/src/shared/get-function-version.ts b/packages/lambda/src/shared/get-function-version.ts
index 8c736fc8e4..058aebfc64 100644
--- a/packages/lambda/src/shared/get-function-version.ts
+++ b/packages/lambda/src/shared/get-function-version.ts
@@ -1,6 +1,6 @@
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
import {callLambda} from './call-lambda';
import {COMMAND_NOT_FOUND} from './constants';
diff --git a/packages/lambda/src/shared/hosted-layers.ts b/packages/lambda/src/shared/hosted-layers.ts
index 30e1e8c527..fd6d838c2e 100644
--- a/packages/lambda/src/shared/hosted-layers.ts
+++ b/packages/lambda/src/shared/hosted-layers.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
export const REMOTION_HOSTED_LAYER_ARN = `arn:aws:lambda:*:678892195805:layer:remotion-binaries-*`;
diff --git a/packages/lambda/src/shared/lambda-insights-extensions.ts b/packages/lambda/src/shared/lambda-insights-extensions.ts
index 51dcff31fa..0d3ec19ac2 100644
--- a/packages/lambda/src/shared/lambda-insights-extensions.ts
+++ b/packages/lambda/src/shared/lambda-insights-extensions.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
export const lambdaInsightsExtensions: {[region in AwsRegion]: string} = {
'us-east-1':
diff --git a/packages/lambda/src/shared/lifecycle-rules.ts b/packages/lambda/src/shared/lifecycle-rules.ts
index fcfb9a7a82..985ab656a4 100644
--- a/packages/lambda/src/shared/lifecycle-rules.ts
+++ b/packages/lambda/src/shared/lifecycle-rules.ts
@@ -2,12 +2,13 @@ import {
DeleteBucketLifecycleCommand,
PutBucketLifecycleConfigurationCommand,
} from '@aws-sdk/client-s3';
-import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import type {CustomCredentials} from '@remotion/serverless/client';
import {
createLifeCycleInput,
deleteLifeCycleInput,
} from '../functions/helpers/apply-lifecyle';
import {getLifeCycleRules} from '../functions/helpers/lifecycle';
+import type {AwsRegion} from '../regions';
import {getS3Client} from './aws-clients';
const createLCRules = async ({
@@ -17,7 +18,7 @@ const createLCRules = async ({
}: {
bucketName: string;
region: AwsRegion;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}) => {
const lcRules = getLifeCycleRules();
// create the lifecyle rules
@@ -46,7 +47,7 @@ const deleteLCRules = async ({
}: {
bucketName: string;
region: AwsRegion;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}) => {
const deleteCommandInput = deleteLifeCycleInput({
bucketName,
@@ -73,7 +74,7 @@ export const applyLifeCyleOperation = async ({
enableFolderExpiry: boolean | null;
bucketName: string;
region: AwsRegion;
- customCredentials: CustomCredentials | null;
+ customCredentials: CustomCredentials<AwsRegion> | null;
}) => {
if (enableFolderExpiry === null) {
return;
diff --git a/packages/lambda/src/shared/make-s3-url.ts b/packages/lambda/src/shared/make-s3-url.ts
index 41a3617d5d..d1cbfcb7e7 100644
--- a/packages/lambda/src/shared/make-s3-url.ts
+++ b/packages/lambda/src/shared/make-s3-url.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
export const makeS3ServeUrl = ({
bucketName,
diff --git a/packages/lambda/src/shared/validate-aws-region.ts b/packages/lambda/src/shared/validate-aws-region.ts
index 988c6c2c05..919411c873 100644
--- a/packages/lambda/src/shared/validate-aws-region.ts
+++ b/packages/lambda/src/shared/validate-aws-region.ts
@@ -1,5 +1,5 @@
-import type {AwsRegion} from '@remotion/serverless/client';
-import {AWS_REGIONS} from '@remotion/serverless/client';
+import type {AwsRegion} from '../regions';
+import {AWS_REGIONS} from '../regions';
export function validateAwsRegion(
region: unknown,
diff --git a/packages/serverless/src/client.ts b/packages/serverless/src/client.ts
index c30ff8d29f..4eb76d505f 100644
--- a/packages/serverless/src/client.ts
+++ b/packages/serverless/src/client.ts
@@ -18,4 +18,3 @@ export {
type WebhookOption,
} from './constants';
export {inputPropsKey, resolvedPropsKey} from './input-props-keys';
-export {AWS_REGIONS, AwsRegion, DEFAULT_AWS_REGIONS} from './region';
diff --git a/packages/serverless/src/constants.ts b/packages/serverless/src/constants.ts
index 55410d4a0b..3e6b81fe1a 100644
--- a/packages/serverless/src/constants.ts
+++ b/packages/serverless/src/constants.ts
@@ -12,7 +12,6 @@ import type {
X264Preset,
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
-import type {AwsRegion} from './region';
// Needs to be in sync with renderer/src/options/delete-after.ts#L7
export const expiryDays = {
@@ -38,18 +37,19 @@ export type CustomCredentialsWithoutSensitiveData = {
endpoint: string;
};
-export type CustomCredentials = CustomCredentialsWithoutSensitiveData & {
- accessKeyId: string | null;
- secretAccessKey: string | null;
- region?: AwsRegion;
-};
+export type CustomCredentials<Region extends string> =
+ CustomCredentialsWithoutSensitiveData & {
+ accessKeyId: string | null;
+ secretAccessKey: string | null;
+ region?: Region;
+ };
-export type OutNameInput =
+export type OutNameInput<Region extends string> =
| string
| {
bucketName: string;
key: string;
- s3OutputProvider?: CustomCredentials;
+ s3OutputProvider?: CustomCredentials<Region>;
};
export type SerializedInputProps =
@@ -103,16 +103,16 @@ export type WebhookOption = Prettify<
>)
>;
-export type LambdaStatusPayload = {
+export type LambdaStatusPayload<Region extends string> = {
type: ServerlessRoutines.status;
bucketName: string;
renderId: string;
version: string;
logLevel: LogLevel;
- s3OutputProvider?: CustomCredentials;
+ s3OutputProvider?: CustomCredentials<Region>;
};
-export type LambdaStartPayload = {
+export type LambdaStartPayload<Region extends string> = {
rendererFunctionName: string | null;
type: ServerlessRoutines.start;
serveUrl: string;
@@ -132,7 +132,7 @@ export type LambdaStartPayload = {
privacy: Privacy;
logLevel: LogLevel;
frameRange: FrameRange | null;
- outName: OutNameInput | null;
+ outName: OutNameInput<Region> | null;
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
scale: number;
@@ -157,12 +157,12 @@ export type LambdaStartPayload = {
preferLossless: boolean;
};
-export type LambdaPayloads = {
+export type LambdaPayloads<Region extends string> = {
info: {
type: ServerlessRoutines.info;
logLevel: LogLevel;
};
- start: LambdaStartPayload;
+ start: LambdaStartPayload<Region>;
launch: {
rendererFunctionName: string | null;
type: ServerlessRoutines.launch;
@@ -185,7 +185,7 @@ export type LambdaPayloads = {
privacy: Privacy;
logLevel: LogLevel;
frameRange: FrameRange | null;
- outName: OutNameInput | null;
+ outName: OutNameInput<Region> | null;
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
scale: number;
@@ -207,7 +207,7 @@ export type LambdaPayloads = {
colorSpace: ColorSpace | null;
preferLossless: boolean;
};
- status: LambdaStatusPayload;
+ status: LambdaStatusPayload<Region>;
renderer: {
concurrencyPerLambda: number;
type: ServerlessRoutines.renderer;
@@ -268,7 +268,7 @@ export type LambdaPayloads = {
frame: number;
privacy: Privacy;
logLevel: LogLevel;
- outName: OutNameInput | null;
+ outName: OutNameInput<Region> | null;
timeoutInMilliseconds: number;
chromiumOptions: ChromiumOptions;
scale: number;
@@ -295,4 +295,5 @@ export type LambdaPayloads = {
};
};
-export type LambdaPayload = LambdaPayloads[ServerlessRoutines];
+export type LambdaPayload<Region extends string> =
+ LambdaPayloads<Region>[ServerlessRoutines];
diff --git a/packages/serverless/src/info.ts b/packages/serverless/src/info.ts
index 9261d641d2..2699fd13ca 100644
--- a/packages/serverless/src/info.ts
+++ b/packages/serverless/src/info.ts
@@ -2,7 +2,9 @@ import {VERSION} from 'remotion/version';
import type {LambdaPayload} from './constants';
import {ServerlessRoutines} from './constants';
-export const infoHandler = (lambdaParams: LambdaPayload) => {
+export const infoHandler = <Region extends string>(
+ lambdaParams: LambdaPayload<Region>,
+) => {
if (lambdaParams.type !== ServerlessRoutines.info) {
throw new TypeError('Expected info type');
}
diff --git a/packages/serverless/src/provider-implementation.ts b/packages/serverless/src/provider-implementation.ts
index 57738d5250..a323a35432 100644
--- a/packages/serverless/src/provider-implementation.ts
+++ b/packages/serverless/src/provider-implementation.ts
@@ -1,4 +1,5 @@
export type ProviderSpecifics<Region extends string> = {
getChromiumPath: () => string;
getCurrentRegionInFunction: () => Region;
+ regionType: Region;
};
diff --git a/packages/serverless/src/region.ts b/packages/serverless/src/region.ts
deleted file mode 100644
index 8bbae45f60..0000000000
--- a/packages/serverless/src/region.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-export const DEFAULT_AWS_REGIONS = [
- 'eu-central-1',
- 'eu-west-1',
- 'eu-west-2',
- 'eu-west-3',
- 'eu-north-1',
- 'us-east-1', // N. Virginia
- 'us-east-2', // Ohio;
- 'us-west-1',
- 'us-west-2', // Oregon
- 'ap-south-1',
- 'ap-southeast-1',
- 'ap-southeast-2',
- 'ap-northeast-1',
- 'ap-northeast-2',
- 'ap-northeast-3',
- 'ca-central-1',
- 'sa-east-1',
-] as const;
-
-export const AWS_REGIONS = [
- 'eu-central-1',
- 'eu-west-1',
- 'eu-west-2',
- 'eu-west-3',
- 'eu-south-1',
- 'eu-north-1',
- 'us-east-1', // N. Virginia
- 'us-east-2', // Ohio;
- 'us-west-1',
- 'us-west-2', // Oregon
- 'af-south-1',
- 'ap-south-1',
- 'ap-east-1',
- 'ap-southeast-1',
- 'ap-southeast-2',
- 'ap-northeast-1',
- 'ap-northeast-2',
- 'ap-northeast-3',
- 'ca-central-1',
- 'me-south-1',
- 'sa-east-1',
-] as const;
-
-export type AwsRegion = (typeof AWS_REGIONS)[number];