Skip to content

🎥 Make videos programmatically with React

functions rmall command

Jonny Burger06f9500c43ae
diff --git a/packages/docs/docs/lambda/cli/functions.md b/packages/docs/docs/lambda/cli/functions.md
index 2fc0fb2951..e41a6af1fe 100644
--- a/packages/docs/docs/lambda/cli/functions.md
+++ b/packages/docs/docs/lambda/cli/functions.md
@@ -36,7 +36,7 @@ Deployed as remotion-render-2021-12-17-2048mb-120sec
### `--region`
-The [AWS region](/docs/lambda/region-selection) to select. Both project and function should be in this region.
+The [AWS region](/docs/lambda/region-selection) to select.
### `--memory`
@@ -79,7 +79,7 @@ remotion-render-2021-12-15-2048mb-240sec 2021-12-15 2048
### `--region`
-The [AWS region](/docs/lambda/region-selection) to select. Both project and function should be in this region.
+The [AWS region](/docs/lambda/region-selection) to select.
### `--quiet`, `-q`
@@ -112,7 +112,47 @@ Deleted!
### `--region`
-The [AWS region](/docs/lambda/region-selection) to select. Both project and function should be in this region.
+The [AWS region](/docs/lambda/region-selection) to select.
+
+### `--yes`, `-y`
+
+Skips confirmation.
+
+## rmall
+
+```
+npx remotion lambda functions rmall
+```
+
+Removes all functions in a region from your AWS infrastructure.
+
+<details>
+<summary>
+Example output
+</summary>
+<pre>
+<br/>
+Function name: remotion-render-2021-12-16-2048mb-240sec<br/>
+Memory: 2048MB<br/>
+Timeout: 120sec<br/>
+Version: 2021-12-16<br/>
+Delete? (Y/n): Y<br/>
+Deleted!
+<br/>
+Function name: remotion-render-2021-12-18-2048mb-240sec<br/>
+Memory: 2048MB<br/>
+Timeout: 120sec<br/>
+Version: 2021-12-16<br/>
+Delete? (Y/n): Y<br/>
+Deleted!
+<br/>
+
+</pre>
+</details>
+
+### `--region`
+
+The [AWS region](/docs/lambda/region-selection) to select.
### `--yes`, `-y`
diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.ts
index ba17ecb8bc..60d0bcef14 100644
--- a/packages/lambda/src/cli/commands/functions/index.ts
+++ b/packages/lambda/src/cli/commands/functions/index.ts
@@ -5,6 +5,7 @@ import {quit} from '../../helpers/quit';
import {functionsDeploySubcommand, FUNCTIONS_DEPLOY_SUBCOMMAND} from './deploy';
import {functionsLsCommand, FUNCTIONS_LS_SUBCOMMAND} from './ls';
import {functionsRmCommand, FUNCTIONS_RM_SUBCOMMAND} from './rm';
+import {functionsRmallCommand, FUNCTIONS_RMALL_SUBCOMMAND} from './rmall';
export const FUNCTIONS_COMMAND = 'functions';
@@ -25,6 +26,9 @@ const printFunctionsHelp = () => {
`${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RM_SUBCOMMAND} <function-name>`
);
Log.info(CliInternals.chalk.gray('Delete a Lambda function'));
+ Log.info('');
+ Log.info(`${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_RMALL_SUBCOMMAND}`);
+ Log.info(CliInternals.chalk.gray('Delete all functions in selected region'));
};
export const functionsCommand = (args: string[]) => {
@@ -36,6 +40,10 @@ export const functionsCommand = (args: string[]) => {
return functionsRmCommand(args.slice(1));
}
+ if (args[0] === FUNCTIONS_RMALL_SUBCOMMAND) {
+ return functionsRmallCommand();
+ }
+
if (args[0] === FUNCTIONS_DEPLOY_SUBCOMMAND) {
return functionsDeploySubcommand();
}
diff --git a/packages/lambda/src/cli/commands/functions/rmall.ts b/packages/lambda/src/cli/commands/functions/rmall.ts
new file mode 100644
index 0000000000..7dafe9a4da
--- /dev/null
+++ b/packages/lambda/src/cli/commands/functions/rmall.ts
@@ -0,0 +1,47 @@
+import {CliInternals} from '@remotion/cli';
+import {getFunctions} from '../../..';
+import {deleteFunction} from '../../../api/delete-function';
+import {getFunctionInfo} from '../../../api/get-function-info';
+import {getAwsRegion} from '../../get-aws-region';
+import {confirmCli} from '../../helpers/confirm';
+import {Log} from '../../log';
+
+export const FUNCTIONS_RMALL_SUBCOMMAND = 'rmall';
+const LEFT_COL = 16;
+
+export const functionsRmallCommand = async () => {
+ const region = getAwsRegion();
+ const functions = await getFunctions({
+ region,
+ compatibleOnly: false,
+ });
+
+ for (const fun of functions) {
+ const infoOutput = CliInternals.createOverwriteableCliOutput(
+ CliInternals.quietFlagProvided()
+ );
+ infoOutput.update('Getting function info...');
+ const info = await getFunctionInfo({
+ region,
+ functionName: fun.functionName,
+ });
+
+ infoOutput.update(
+ [
+ 'Function name: '.padEnd(LEFT_COL, ' ') + ' ' + info.functionName,
+ 'Memory: '.padEnd(LEFT_COL, ' ') + ' ' + info.memorySizeInMb + 'MB',
+ 'Timeout: '.padEnd(LEFT_COL, ' ') + ' ' + info.timeoutInSeconds + 'sec',
+ 'Version: '.padEnd(LEFT_COL, ' ') + ' ' + info.version,
+ ].join('\n')
+ );
+ Log.info();
+
+ await confirmCli({delMessage: 'Delete? (Y/n)', allowForceFlag: true});
+ const output = CliInternals.createOverwriteableCliOutput(
+ CliInternals.quietFlagProvided()
+ );
+ output.update('Deleting...');
+ await deleteFunction({region, functionName: fun.functionName});
+ output.update('Deleted!\n');
+ }
+};