Skip to content

🎥 Make videos programmatically with React

remove cleanup command

Jonny Burgerada2e16e4815
diff --git a/packages/lambda/src/admin/make-layer-public.ts b/packages/lambda/src/admin/make-layer-public.ts
index 40be7f159e..852f411311 100644
--- a/packages/lambda/src/admin/make-layer-public.ts
+++ b/packages/lambda/src/admin/make-layer-public.ts
@@ -36,7 +36,7 @@ const layerInfo: {
'us-west-2': [],
};
-export const makeLayerPublic = async () => {
+const makeLayerPublic = async () => {
const layers = ['remotion', 'ffmpeg', 'chromium'] as const;
for (const region of AWS_REGIONS) {
for (const layer of layers) {
diff --git a/packages/lambda/src/cleanup/cleanup-lambdas.ts b/packages/lambda/src/cleanup/cleanup-lambdas.ts
deleted file mode 100644
index 7458b86f0b..0000000000
--- a/packages/lambda/src/cleanup/cleanup-lambdas.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import {AwsRegion} from '..';
-import {deleteFunction} from '../api/delete-function';
-import {getFunctions} from '../api/get-functions';
-
-export const cleanupLambdas = async ({
- onBeforeDelete,
- onAfterDelete,
- region,
-}: {
- region: AwsRegion;
- onBeforeDelete?: (lambdaName: string) => void;
- onAfterDelete?: (lambdaName: string) => void;
-}) => {
- const remotionLambdas = await getFunctions({region, compatibleOnly: false});
- if (remotionLambdas.length === 0) {
- return;
- }
-
- for (const lambda of remotionLambdas) {
- onBeforeDelete?.(lambda.functionName);
- await deleteFunction({
- region,
- functionName: lambda.functionName,
- });
- onAfterDelete?.(lambda.functionName);
- }
-
- await cleanupLambdas({region, onBeforeDelete, onAfterDelete});
-};
diff --git a/packages/lambda/src/cleanup/s3-buckets.ts b/packages/lambda/src/cleanup/s3-buckets.ts
deleted file mode 100644
index aafd46a90b..0000000000
--- a/packages/lambda/src/cleanup/s3-buckets.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import {DeleteBucketCommand} from '@aws-sdk/client-s3';
-import {cleanItems} from '../api/clean-items';
-import {getRemotionS3Buckets} from '../api/get-buckets';
-import {lambdaLs} from '../functions/helpers/io';
-import {AwsRegion} from '../pricing/aws-regions';
-import {getS3Client} from '../shared/aws-clients';
-
-const cleanBucket = async ({
- region,
- bucket,
- onAfterItemDeleted,
- onBeforeItemDeleted,
- expectedBucketOwner,
-}: {
- region: AwsRegion;
- bucket: string;
- onAfterItemDeleted: (data: {bucketName: string; itemName: string}) => void;
- onBeforeItemDeleted: (data: {bucketName: string; itemName: string}) => void;
- expectedBucketOwner: string | null;
-}) => {
- let list = await lambdaLs({
- bucketName: bucket,
- prefix: '',
- region,
- expectedBucketOwner,
- });
- while (list.length > 0) {
- await cleanItems({
- list: list.map((l) => l.Key as string),
- region,
- bucket,
- onAfterItemDeleted,
- onBeforeItemDeleted,
- });
- list = await lambdaLs({
- bucketName: bucket,
- prefix: '',
- region,
- expectedBucketOwner,
- });
- }
-
- await getS3Client(region).send(
- new DeleteBucketCommand({
- Bucket: bucket,
- })
- );
-};
-
-export const cleanUpBuckets = async ({
- region,
- onBeforeBucketDeleted,
- onAfterBucketDeleted,
- onAfterItemDeleted,
- onBeforeItemDeleted,
- expectedBucketOwner,
-}: {
- region: AwsRegion;
- onBeforeBucketDeleted?: (bucketName: string) => void;
- onAfterItemDeleted?: (data: {bucketName: string; itemName: string}) => void;
- onBeforeItemDeleted?: (data: {bucketName: string; itemName: string}) => void;
- onAfterBucketDeleted?: (bucketName: string) => void;
- expectedBucketOwner: string | null;
-}) => {
- const {remotionBuckets} = await getRemotionS3Buckets(region);
- if (remotionBuckets.length === 0) {
- return;
- }
-
- for (const bucket of remotionBuckets) {
- onBeforeBucketDeleted?.(bucket.name);
- await cleanBucket({
- region,
- bucket: bucket.name,
- onAfterItemDeleted: onAfterItemDeleted ?? (() => undefined),
- onBeforeItemDeleted: onBeforeItemDeleted ?? (() => undefined),
- expectedBucketOwner,
- });
- onAfterBucketDeleted?.(bucket.name);
- }
-
- await cleanUpBuckets({
- region,
- onAfterBucketDeleted,
- onBeforeBucketDeleted,
- expectedBucketOwner,
- });
-};
diff --git a/packages/lambda/src/cli/cleanup.ts b/packages/lambda/src/cli/cleanup.ts
deleted file mode 100644
index 6dfd3c7b82..0000000000
--- a/packages/lambda/src/cli/cleanup.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import {CliInternals} from '@remotion/cli';
-import {getRemotionS3Buckets} from '../api/get-buckets';
-import {getFunctions} from '../api/get-functions';
-import {cleanupLambdas} from '../cleanup/cleanup-lambdas';
-import {cleanUpBuckets} from '../cleanup/s3-buckets';
-import {AwsRegion} from '../pricing/aws-regions';
-import {chunk} from '../shared/chunk';
-import {BINARY_NAME} from '../shared/constants';
-import {getAccountId} from '../shared/get-account-id';
-import {getAwsRegion} from './get-aws-region';
-import {Log} from './log';
-
-export const CLEANUP_COMMAND = 'cleanup';
-export const CLEANUP_LAMBDAS_SUBCOMMAND = 'lambdas';
-const CLEANUP_S3_BUCKETS_SUBCOMMAND = 'buckets';
-
-const cleanupLambdaCommand = async (region: AwsRegion) => {
- await cleanupLambdas({
- region,
- onAfterDelete: (lambdaName: string) =>
- Log.info(CliInternals.chalk.blue(`Deleted ${lambdaName}`)),
- });
- Log.info('All Remotion-related lambdas deleted.');
-};
-
-const cleanupBucketsCommand = async (region: AwsRegion) => {
- await cleanUpBuckets({
- region,
- onBeforeBucketDeleted: (bucketName) => {
- Log.info(`Deleting items of ${bucketName}`);
- },
- onAfterItemDeleted: ({itemName}) => {
- Log.info(CliInternals.chalk.gray(` Deleting item ${itemName}`));
- },
- onAfterBucketDeleted: (bucketName: string) =>
- Log.info(CliInternals.chalk.blue(`Deleted bucket ${bucketName}.`)),
- expectedBucketOwner: await getAccountId({region}),
- });
- Log.info('All Remotion-related buckets deleted.');
-};
-
-export const cleanupCommand = async (args: string[]) => {
- const region = getAwsRegion();
- if (args[0] === CLEANUP_LAMBDAS_SUBCOMMAND) {
- await cleanupLambdaCommand(getAwsRegion());
- return;
- }
-
- if (args[0] === CLEANUP_S3_BUCKETS_SUBCOMMAND) {
- await cleanupBucketsCommand(getAwsRegion());
- return;
- }
-
- const fetching = CliInternals.createOverwriteableCliOutput();
- fetching.update('Fetching AWS account...');
-
- const [{remotionBuckets}, lambdas] = await Promise.all([
- getRemotionS3Buckets(region),
- getFunctions({region, compatibleOnly: false}),
- ]);
- if (remotionBuckets.length === 0 && lambdas.length === 0) {
- fetching.update(
- `Your AWS account in ${region} contains no following Remotion-related resources.\n`
- );
- return;
- }
-
- fetching.update(
- `Your AWS account in ${region} contains the following Remotion-related resources:\n\n`
- );
- if (remotionBuckets.length !== 0) {
- Log.info(
- `${remotionBuckets.length} ${
- remotionBuckets.length === 1 ? 'bucket' : 'buckets'
- }:`
- );
- Log.info(
- `${chunk(remotionBuckets, 2)
- .map((b) =>
- CliInternals.chalk.blue(
- b.map((a) => a.name.padEnd(40, ' ')).join(' ')
- )
- )
- .join('\n')}`
- );
-
- Log.info(
- CliInternals.chalk.gray(
- `Run \`${BINARY_NAME} ${CLEANUP_COMMAND} ${CLEANUP_S3_BUCKETS_SUBCOMMAND}\` to permanently delete S3 buckets`
- )
- );
- Log.info();
- }
-
- if (lambdas.length > 0) {
- Log.info(
- `${lambdas.length} ${lambdas.length === 1 ? 'lambda' : 'lambdas'}:`
- );
- Log.info(
- `${chunk(lambdas, 2)
- .map((b) =>
- CliInternals.chalk.blue(
- b.map((a) => (a.functionName ?? '').padEnd(40, ' ')).join(' ')
- )
- )
- .join('\n')}`
- );
- Log.info(
- CliInternals.chalk.gray(
- `Run \`${BINARY_NAME} ${CLEANUP_COMMAND} ${CLEANUP_LAMBDAS_SUBCOMMAND}\` to permanently delete lambdas`
- )
- );
- Log.info();
- }
-};
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 3000d9349f..3216b63ff8 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -21,7 +21,7 @@ export type MultiRenderProgress = {
cleanupInfo: CleanupInfo | null;
};
-export const makeInvokeProgress = (
+const makeInvokeProgress = (
invokeProgress: LambdaInvokeProgress,
totalSteps: number
) => {
@@ -42,7 +42,7 @@ export const makeInvokeProgress = (
].join(' ');
};
-export const makeChunkProgress = ({
+const makeChunkProgress = ({
chunkProgress,
invokeProgress,
totalSteps,
@@ -70,7 +70,7 @@ export const makeChunkProgress = ({
].join(' ');
};
-export const makeEncodingProgress = ({
+const makeEncodingProgress = ({
encodingProgress,
chunkProgress,
totalSteps,
@@ -98,7 +98,7 @@ export const makeEncodingProgress = ({
].join(' ');
};
-export const makeCleanupProgress = (
+const makeCleanupProgress = (
cleanupInfo: CleanupInfo | null,
totalSteps: number
) => {
@@ -119,10 +119,7 @@ export const makeCleanupProgress = (
].join(' ');
};
-export const makeDownloadProgess = (
- totalSteps: number,
- downloadedYet: boolean
-) => {
+const makeDownloadProgess = (totalSteps: number, downloadedYet: boolean) => {
return [
'💾',
`(5/${totalSteps})`,
diff --git a/packages/lambda/src/cli/commands/sites/ls.ts b/packages/lambda/src/cli/commands/sites/ls.ts
index 00b37349db..55f3f9f06a 100644
--- a/packages/lambda/src/cli/commands/sites/ls.ts
+++ b/packages/lambda/src/cli/commands/sites/ls.ts
@@ -1,7 +1,6 @@
import {CliInternals} from '@remotion/cli';
import {Log} from '@remotion/cli/dist/log';
import {getSites} from '../../../api/get-sites';
-import {makeS3ServeUrl} from '../../../shared/make-s3-url';
import {quietFlagProvided} from '../../args';
import {getAwsRegion} from '../../get-aws-region';
import {dateString} from '../../helpers/date-string';
diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.ts
index dab3f2559e..b16ca361fe 100644
--- a/packages/lambda/src/cli/help.ts
+++ b/packages/lambda/src/cli/help.ts
@@ -1,9 +1,9 @@
import {CliInternals} from '@remotion/cli';
import {BINARY_NAME} from '../shared/constants';
-import {CLEANUP_COMMAND} from './cleanup';
import {FUNCTIONS_COMMAND} from './commands/functions';
import {RENDER_COMMAND} from './commands/render/render';
import {STILL_COMMAND} from './commands/still';
+import {SITES_COMMAND} from './commands/sites';
import {Log} from './log';
const packagejson = require('../../package.json');
@@ -24,15 +24,11 @@ export const printHelp = () => {
Log.info(`${BINARY_NAME} ${STILL_COMMAND} <s3-url> <composition-id>`);
Log.info(CliInternals.chalk.gray('Render a still image in the cloud.'));
- Log.info();
- Log.info(`${BINARY_NAME} ${CLEANUP_COMMAND}`);
- Log.info(
- CliInternals.chalk.gray(
- 'Delete Remotion-related infrastructure from your AWS account.'
- )
- );
-
Log.info();
Log.info(`${BINARY_NAME} ${FUNCTIONS_COMMAND}`);
Log.info(CliInternals.chalk.gray('Deploy and manage AWS Lambda functions.'));
+
+ Log.info();
+ Log.info(`${BINARY_NAME} ${SITES_COMMAND}`);
+ Log.info(CliInternals.chalk.gray('Deploy and manage Remotion projects.'));
};
diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.ts
index 369cb3cbe6..850a37979d 100644
--- a/packages/lambda/src/cli/helpers/find-function-name.ts
+++ b/packages/lambda/src/cli/helpers/find-function-name.ts
@@ -1,8 +1,9 @@
import {getFunctions} from '../../api/get-functions';
import {BINARY_NAME, CURRENT_VERSION} from '../../shared/constants';
-import {CLEANUP_COMMAND, CLEANUP_LAMBDAS_SUBCOMMAND} from '../cleanup';
import {FUNCTIONS_COMMAND} from '../commands/functions';
import {FUNCTIONS_DEPLOY_SUBCOMMAND} from '../commands/functions/deploy';
+import {FUNCTIONS_LS_SUBCOMMAND} from '../commands/functions/ls';
+import {FUNCTIONS_RM_SUBCOMMAND} from '../commands/functions/rm';
import {getAwsRegion} from '../get-aws-region';
import {Log} from '../log';
@@ -39,7 +40,7 @@ export const findFunctionName = async () => {
);
Log.info(`Delete extraneous lambda functions in your AWS console or run`);
Log.info(
- ` npx ${BINARY_NAME} ${CLEANUP_COMMAND} ${CLEANUP_LAMBDAS_SUBCOMMAND}`
+ ` npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RM_SUBCOMMAND} $(npx ${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_LS_SUBCOMMAND} -q) -y`
);
Log.info('to delete all lambda functions.');
process.exit(1);
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index 87f4607059..00bcb1346b 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -1,7 +1,6 @@
import {CliInternals} from '@remotion/cli';
import {checkCredentials} from '../shared/check-credentials';
import {parsedLambdaCli} from './args';
-import {cleanupCommand, CLEANUP_COMMAND} from './cleanup';
import {functionsCommand, FUNCTIONS_COMMAND} from './commands/functions';
import {policiesCommand, POLICIES_COMMAND} from './commands/policies/policies';
import {ROLE_SUBCOMMAND} from './commands/policies/role';
@@ -48,10 +47,6 @@ const matchCommand = async (args: string[]) => {
return functionsCommand(args.slice(1));
}
- if (args[0] === CLEANUP_COMMAND) {
- return cleanupCommand(args.slice(1));
- }
-
if (args[0] === POLICIES_COMMAND) {
return policiesCommand(args.slice(1));
}
diff --git a/packages/lambda/src/functions/helpers/get-browser-instance.ts b/packages/lambda/src/functions/helpers/get-browser-instance.ts
index 4fa6ae2ddf..80d2b16988 100644
--- a/packages/lambda/src/functions/helpers/get-browser-instance.ts
+++ b/packages/lambda/src/functions/helpers/get-browser-instance.ts
@@ -51,12 +51,3 @@ export const closeBrowser = async () => {
await Promise.all(pages.map((p) => p.close()));
}
};
-
-export const quitBrowser = async () => {
- if (!_browserInstance) {
- return;
- }
-
- await _browserInstance.close();
- _browserInstance = null;
-};
diff --git a/packages/lambda/src/functions/helpers/inspect-errors.ts b/packages/lambda/src/functions/helpers/inspect-errors.ts
index 87e5438a68..bf3da9530d 100644
--- a/packages/lambda/src/functions/helpers/inspect-errors.ts
+++ b/packages/lambda/src/functions/helpers/inspect-errors.ts
@@ -4,7 +4,10 @@ import {AwsRegion} from '../../pricing/aws-regions';
import {getErrorKeyPrefix} from '../../shared/constants';
import {streamToString} from '../../shared/stream-to-string';
import {lambdaReadFile} from './io';
-import {errorIsOutOfSpaceError} from './is-enosp-err';
+import {
+ errorIsOutOfSpaceError,
+ isErrInsufficientResourcesErr,
+} from './is-enosp-err';
import {EnhancedErrorInfo, LambdaErrorInfo} from './write-lambda-error';
const FAILED_TO_LAUNCH_TOKEN = 'Failed to launch browser.';
@@ -28,6 +31,10 @@ const getExplanation = (stack: string) => {
return 'Your lambda function reached the 512MB storage limit. Reduce the amount of space needed per lambda function. Feel free to reach out to #lambda Discord for help';
}
+ if (isErrInsufficientResourcesErr(stack)) {
+ return 'The lambda ran out of memory. Deploy a new function with more memory.';
+ }
+
return null;
};
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index 46e6e864c8..bb4741dd75 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -33,7 +33,7 @@ type Options = {
expectedBucketOwner: string;
};
-export const innerStillHandler = async (
+const innerStillHandler = async (
lambdaParams: LambdaPayload,
options: Options
) => {
diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.ts
index 86c7037509..c5037ffefd 100644
--- a/packages/lambda/src/index.ts
+++ b/packages/lambda/src/index.ts
@@ -1,7 +1,11 @@
import {deleteFunction} from './api/delete-function';
import {deleteSite} from './api/delete-site';
import {deployFunction} from './api/deploy-function';
-import {deploySite} from './api/deploy-site';
+import {
+ deploySite,
+ DeploySiteInput,
+ DeploySiteReturnType,
+} from './api/deploy-site';
import {downloadVideo} from './api/download-video';
import {getFunctionInfo} from './api/get-function-info';
import {getFunctions} from './api/get-functions';
@@ -19,6 +23,7 @@ import {LambdaInternals} from './internals';
import {AwsRegion} from './pricing/aws-regions';
import type {RenderProgress} from './shared/constants';
import {estimatePrice} from './pricing/calculate-price';
+import {LambdaLSInput, LambdaLsReturnType} from './functions/helpers/io';
export {
deleteSite,
@@ -39,4 +44,11 @@ export {
LambdaInternals,
renderStillOnLambda,
};
-export type {AwsRegion, RenderProgress};
+export type {
+ AwsRegion,
+ RenderProgress,
+ DeploySiteInput,
+ DeploySiteReturnType,
+ LambdaLsReturnType,
+ LambdaLSInput,
+};