Skip to content

🎥 Make videos programmatically with React

how to uninstall lambda

Jonny Burger6a9a3edfa8a7
diff --git a/packages/docs/docs/lambda-uninstall.md b/packages/docs/docs/lambda-uninstall.md
new file mode 100644
index 0000000000..d8ff1974f3
--- /dev/null
+++ b/packages/docs/docs/lambda-uninstall.md
@@ -0,0 +1,35 @@
+---
+id: lambda-uninstall
+title: Uninstall Lambda
+slug: /lambda/uninstall
+---
+
+Of course we are bummed if you decided not to use Remotion Lambda anymore. We are very receptive to feedback if you'd like to share it with us.
+
+If you would like to remove **all Remotion Lambda related objects** from your infrastructure, you can follow these steps.
+
+:::warning
+This will remove all videos already rendered, and break your programs that are using Remotion Lambda to render videos.
+:::
+
+## Delete Lambda Functions
+
+You can delete all functions using the following command. The `yes` flag is already included, if you run this, it will delete all functions without confirmation.
+
+```
+npx remotion lambda functions rm $(npx remotion lambda functions ls -q) -y
+```
+
+## Delete projects
+
+```
+npx remotion lambda sites rm $(npx remotion lambda sites ls -q) -y
+```
+
+## Delete renders and artifacts
+
+Delete all S3 buckets starting with `remotionlambda-` from your S3 bucket.
+
+---
+
+Make sure you have [applied the instructions to all regions](/docs/lambda/region-selection). You have now cleared up your AWS infrastructure from all Remotion Lambda-related resources.
diff --git a/packages/docs/docs/region-selection.md b/packages/docs/docs/region-selection.md
index 061f56adc4..d159bfacf7 100644
--- a/packages/docs/docs/region-selection.md
+++ b/packages/docs/docs/region-selection.md
@@ -28,12 +28,12 @@ There are 3 ways of selection a region:
- When using the CLI, you can set the region using the `AWS_REGION` environment variable. It's best to put it in a `.env` file so you don't forget it sometimes.
+- You can also pass the `--region` flag to all CLI commands to override the region. The flag takes precedence over the environment variable.
+
:::info
-The AWS_REGION environment variable does not work when using the Node.JS APIs.
+The AWS_REGION environment variable and `--region` flag do not work when using the Node.JS APIs. You need to pass a region explicitly.
:::
-- You can also pass the `--region` flag to all CLI commands to override the region. The flag takes precedence over the environment variable.
-
If you don't set a region, Remotion will use the default region.
## Which region should I choose?
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index d190702044..346c1b18b6 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -37,6 +37,7 @@ module.exports = {
],
},
"lambda-changelog",
+ "lambda-uninstall",
],
someSidebar: [
{
diff --git a/packages/lambda/src/cli/commands/sites/rm.ts b/packages/lambda/src/cli/commands/sites/rm.ts
index 411d4e9426..b2a5251495 100644
--- a/packages/lambda/src/cli/commands/sites/rm.ts
+++ b/packages/lambda/src/cli/commands/sites/rm.ts
@@ -1,14 +1,15 @@
import {CliInternals} from '@remotion/cli';
+import {getSites} from '../../..';
import {deleteSite} from '../../../api/delete-site';
import {getRemotionS3Buckets} from '../../../api/get-buckets';
import {getAwsRegion} from '../../get-aws-region';
+import {confirmCli} from '../../helpers/confirm';
import {formatBytes} from '../../helpers/format-bytes';
import {Log} from '../../log';
export const SITES_RM_COMMAND = 'rm';
export const sitesRmSubcommand = async (args: string[]) => {
- const siteName = args[0];
- if (!siteName) {
+ if (args.length === 0) {
Log.error(
'No site name was passed. Run the command again and pass another argument <site-name>.'
);
@@ -16,30 +17,55 @@ export const sitesRmSubcommand = async (args: string[]) => {
}
const region = getAwsRegion();
- const {remotionBuckets} = await getRemotionS3Buckets(region);
+ const deployedSites = await getSites({
+ region,
+ });
- if (remotionBuckets.length > 1) {
- Log.error(
- 'You have more than one Remotion Lambda bucket. You should only have one - delete all but one before continuing.'
- );
- process.exit(1);
- }
+ for (const siteName of args) {
+ const {remotionBuckets} = await getRemotionS3Buckets(region);
- if (remotionBuckets.length === 0) {
- Log.error(
- `You don't have a Remotion Lambda bucket in the ${region} region. Therefore nothing was deleted.`
- );
- process.exit(1);
- }
+ if (remotionBuckets.length > 1) {
+ Log.error(
+ 'You have more than one Remotion Lambda bucket. You should only have one - delete all but one before continuing.'
+ );
+ process.exit(1);
+ }
- const {totalSizeInBytes: totalSize} = await deleteSite({
- bucketName: remotionBuckets[0].name,
- siteName,
- region,
- onAfterItemDeleted: ({itemName}) => {
- Log.info(CliInternals.chalk.gray(`Deleted ${itemName}`));
- },
- });
+ if (remotionBuckets.length === 0) {
+ Log.error(
+ `You don't have a Remotion Lambda bucket in the ${region} region. Therefore nothing was deleted.`
+ );
+ process.exit(1);
+ }
+
+ const site = deployedSites.sites.find((s) => s.id === siteName.trim());
+ if (!site) {
+ Log.error(
+ `No site ${siteName.trim()} was found in your bucket ${
+ remotionBuckets[0].name
+ }.`
+ );
+ process.exit(1);
+ }
- Log.info(`Deleted site ${siteName} and freed up ${formatBytes(totalSize)}.`);
+ await confirmCli({
+ delMessage: `Site ${site.id} in bucket ${site.bucketName} (${formatBytes(
+ site.sizeInBytes
+ )}): Delete? (Y/n)`,
+ allowForceFlag: true,
+ });
+
+ const {totalSizeInBytes: totalSize} = await deleteSite({
+ bucketName: remotionBuckets[0].name,
+ siteName,
+ region,
+ onAfterItemDeleted: ({itemName}) => {
+ Log.info(CliInternals.chalk.gray(`Deleted ${itemName}`));
+ },
+ });
+
+ Log.info(
+ `Deleted site ${siteName} and freed up ${formatBytes(totalSize)}.`
+ );
+ }
};