Skip to content

🎥 Make videos programmatically with React

progress

Jonny Burgerb6a25e847d4d
diff --git a/packages/docs/docs/deletefunction.md b/packages/docs/docs/deletefunction.md
index 23840ce950..208ce92ec1 100644
--- a/packages/docs/docs/deletefunction.md
+++ b/packages/docs/docs/deletefunction.md
@@ -3,3 +3,48 @@ id: deletefunction
title: deleteFunction()
slug: /lambda/deletefunction
---
+
+Deletes a deployed Lambda function based on it's name.
+
+To retrieve a list of functions, call [`getFunctions()`](/docs/lambda/getfunctions) first.
+
+## Example
+
+```ts twoslash
+// @module: esnext
+// @target: es2017
+
+import {deleteFunction, getFunctions} from '@remotion/lambda';
+
+const functions = await getFunctions({
+ region: 'us-east-1',
+ compatibleOnly: false
+});
+for (const fn of functions) {
+ await deleteFunction({
+ region: 'us-east-1',
+ functionName: fn.name
+ });
+}
+```
+
+## Arguments
+
+An object with the following properties:
+
+### `region`
+
+The [AWS region](/docs/lambda/region-selection) to which the function was deployed to.
+
+### `functionName`
+
+The name of the function to be deleted.
+
+## Return value
+
+Nothing. If the deletion failed, the function rejects with an error.
+
+## See also
+
+- [deployFunction()](/docs/lambda/deployfunction)
+- [getFunctions()](/docs/lambda/getfunctions)
diff --git a/packages/docs/docs/deployfunction.md b/packages/docs/docs/deployfunction.md
index a73d82db11..46a81f8a21 100644
--- a/packages/docs/docs/deployfunction.md
+++ b/packages/docs/docs/deployfunction.md
@@ -36,7 +36,7 @@ The [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.
### `region`
-The AWS region which you want to deploy the Lambda function too. It must be the same region that your Lambda Layer resides in.
+The [AWS region](/docs/lambda/region-selection) which you want to deploy the Lambda function too. It must be the same region that your Lambda Layer resides in.
### `timeoutInSeconds`
@@ -52,3 +52,8 @@ How many megabytes of RAM the Lambda function should have. By default we recomme
An object with the following values:
- `functionName` (_string_): The name of the function just created.
+
+## See also
+
+- [deleteFunction()](/docs/lambda/deletefunction)
+- [getFunctions()](/docs/lambda/getfunctions)
diff --git a/packages/lambda/src/api/delete-function.ts b/packages/lambda/src/api/delete-function.ts
index 46211f19c1..cef17822e8 100644
--- a/packages/lambda/src/api/delete-function.ts
+++ b/packages/lambda/src/api/delete-function.ts
@@ -2,6 +2,13 @@ import {DeleteFunctionCommand} from '@aws-sdk/client-lambda';
import {AwsRegion} from '../pricing/aws-regions';
import {getLambdaClient} from '../shared/aws-clients';
+/**
+ * @description Deletes a function from AWS Lambda.
+ * @param options.region The region the function was deployed to.
+ * @param options.functionName The name of the function.
+ * @returns Nothing. Throws if the function failed to delete.
+ * @link https://remotion.dev/docs/lambda/deletefunction
+ */
export const deleteFunction = async ({
region,
functionName,
diff --git a/packages/lambda/src/api/get-functions.ts b/packages/lambda/src/api/get-functions.ts
index d2d333c168..5e066a2219 100644
--- a/packages/lambda/src/api/get-functions.ts
+++ b/packages/lambda/src/api/get-functions.ts
@@ -1,14 +1,33 @@
import {ListFunctionsCommand} from '@aws-sdk/client-lambda';
import {AwsRegion} from '../pricing/aws-regions';
import {getLambdaClient} from '../shared/aws-clients';
-import {CURRENT_VERSION, RENDER_FN_PREFIX} from '../shared/constants';
+import {
+ CURRENT_VERSION,
+ LambdaVersions,
+ RENDER_FN_PREFIX,
+} from '../shared/constants';
import {getFunctionVersion} from '../shared/get-function-version';
-// TODO: Compatible only
+type FunctionInfo = {
+ name: string;
+ version: LambdaVersions;
+ memoryInMb: number;
+ timeoutInSeconds: number;
+};
+
+/**
+ *
+ *
+ * @description Lists Remotion Lambda render functions deployed to AWS Lambda.
+ * @param options.region The region of which the functions should be listed.
+ * @param options.compatibleOnly Whether only functions compatible with the installed version of Remotion Lambda should be returned.
+ * @returns An array with the objects containing information about the deployed functions.
+ * @link https://remotion.dev/docs/lambda/getfunctions
+ */
export const getFunctions = async (options: {
region: AwsRegion;
compatibleOnly: boolean;
-}) => {
+}): Promise<FunctionInfo[]> => {
const lambdas = await getLambdaClient(options.region).send(
new ListFunctionsCommand({})
);
@@ -26,12 +45,12 @@ export const getFunctions = async (options: {
})
);
- const list = remotionLambdas.map((lambda, i) => {
+ const list = remotionLambdas.map((lambda, i): FunctionInfo => {
return {
name: lambda.FunctionName as string,
version: configs[i],
- memory: lambda.MemorySize as number,
- timeout: lambda.Timeout as number,
+ memoryInMb: lambda.MemorySize as number,
+ timeoutInSeconds: lambda.Timeout as number,
};
});
if (!options.compatibleOnly) {
diff --git a/packages/lambda/src/cli/commands/functions/ls.ts b/packages/lambda/src/cli/commands/functions/ls.ts
index e0b0a3015b..8f09fdee60 100644
--- a/packages/lambda/src/cli/commands/functions/ls.ts
+++ b/packages/lambda/src/cli/commands/functions/ls.ts
@@ -52,8 +52,8 @@ export const functionsLsCommand = async () => {
[
datapoint.name.padEnd(NAME_COLS, ' '),
datapoint.version.padEnd(VERSION_COLS, ' '),
- String(datapoint.memory).padEnd(MEMORY_COLS, ' '),
- String(datapoint.timeout).padEnd(TIMEOUT_COLS, ' '),
+ String(datapoint.memoryInMb).padEnd(MEMORY_COLS, ' '),
+ String(datapoint.timeoutInSeconds).padEnd(TIMEOUT_COLS, ' '),
].join('')
);
}