🎥 Make videos programmatically with React
support as many APIs as possible
Jonny Burgeredc98372f015
diff --git a/packages/docs/docs/lambda/multiple-buckets.md b/packages/docs/docs/lambda/multiple-buckets.mdindex c36d91e122..3ea52071b6 100644--- a/packages/docs/docs/lambda/multiple-buckets.md+++ b/packages/docs/docs/lambda/multiple-buckets.md@@ -21,6 +21,8 @@ It is not necessary to create multiple buckets because:You might intuitively create multiple buckets because you have multiple environments, but it is usually not needed.+In addition to that, Remotion was not designed for multiple buckets. While you can explicitly specify a bucket name, it is optional and therefore easy to forget.+## Using multiple bucketsIf you want to use multiple buckets nonetheless (applying different policies to them or fulfilling business or compliance requirements), you can create more buckets in the AWS console. Don't use [`getOrCreateBucket()`](/docs/lambda/getorcreatebucket) to create them.@@ -42,7 +44,9 @@ Also you must pass a `--bucket-name=your-bucket-name` option to the following CLAlso you are unable to use the following APIs:-- [`npx remotion lambda sites rm`]+- [`npx remotion lambda sites ls`](/docs/lambda/cli/sites#ls)+- [`getSites()`](/docs/lambda/getsites)+- [`getOrCreateBucket()`](/docs/lambda/getorcreatebucket)## Deleting extraneous bucketsdiff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex 3895998205..e7fb852ddf 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -85,13 +85,15 @@ export const sitesCreateSubcommand = async (const bucketName =cliBucketName ??- ((await getOrCreateBucket({- region: getAwsRegion(),- onBucketEnsured: () => {- multiProgress.bucketProgress.bucketCreated = true;- updateProgress();- },- }).then((b) => b.bucketName)) as string);+ (+ await getOrCreateBucket({+ region: getAwsRegion(),+ onBucketEnsured: () => {+ multiProgress.bucketProgress.bucketCreated = true;+ updateProgress();+ },+ })+ ).bucketName;multiProgress.bucketProgress.doneIn = Date.now() - bucketStart;updateProgress();diff --git a/packages/lambda/src/cli/commands/sites/rm.ts b/packages/lambda/src/cli/commands/sites/rm.tsindex 172c2ee14e..b335d163ee 100644--- a/packages/lambda/src/cli/commands/sites/rm.ts+++ b/packages/lambda/src/cli/commands/sites/rm.ts@@ -1,7 +1,8 @@import {CliInternals} from '@remotion/cli';import {deleteSite} from '../../../api/delete-site';-import {getRemotionS3Buckets} from '../../../api/get-buckets';+import {getOrCreateBucket} from '../../../api/get-or-create-bucket';import {getSites} from '../../../api/get-sites';+import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';import {quit} from '../../helpers/quit';@@ -27,33 +28,14 @@ export const sitesRmSubcommand = async (args: string[]) => {});for (const siteName of args) {- const {remotionBuckets} = await getRemotionS3Buckets(region);-- if (remotionBuckets.length > 1) {- Log.error('You have more than one Remotion Lambda bucket:');- for (const bucket of remotionBuckets) {- Log.error(`- ${bucket.name}`);- }-- Log.error(- 'You should only have one - delete all but one before continuing.'- );- quit(1);- }-- if (remotionBuckets.length === 0) {- Log.error(- `You don't have a Remotion Lambda bucket in the ${region} region. Therefore nothing was deleted.`- );- quit(1);- }+ const bucketName =+ parsedLambdaCli['bucket-name'] ??+ (await getOrCreateBucket({region})).bucketName;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- }.`+ `No site ${siteName.trim()} was found in your bucket ${bucketName}.`);return quit(1);}@@ -66,7 +48,7 @@ export const sitesRmSubcommand = async (args: string[]) => {});const {totalSizeInBytes: totalSize} = await deleteSite({- bucketName: remotionBuckets[0].name,+ bucketName,siteName,region,onAfterItemDeleted: ({itemName}) => {diff --git a/packages/lambda/src/cli/commands/sites/rmall.ts b/packages/lambda/src/cli/commands/sites/rmall.tsindex c7c37bdacc..90536b0b59 100644--- a/packages/lambda/src/cli/commands/sites/rmall.ts+++ b/packages/lambda/src/cli/commands/sites/rmall.ts@@ -1,10 +1,10 @@import {CliInternals} from '@remotion/cli';import {deleteSite} from '../../../api/delete-site';-import {getRemotionS3Buckets} from '../../../api/get-buckets';+import {getOrCreateBucket} from '../../../api/get-or-create-bucket';import {getSites} from '../../../api/get-sites';+import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';-import {quit} from '../../helpers/quit';import {Log} from '../../log';export const SITES_RMALL_COMMAND = 'rmall';@@ -15,26 +15,9 @@ export const sitesRmallSubcommand = async () => {region,});- const {remotionBuckets} = await getRemotionS3Buckets(region);-- if (remotionBuckets.length > 1) {- Log.error('You have more than one Remotion Lambda bucket:');- for (const bucket of remotionBuckets) {- Log.error(`- ${bucket.name}`);- }-- Log.error(- 'You should only have one - delete all but one before continuing.'- );- quit(1);- }-- if (remotionBuckets.length === 0) {- Log.error(- `You don't have a Remotion Lambda bucket in the ${region} region. Therefore nothing was deleted.`- );- quit(1);- }+ const bucketName =+ parsedLambdaCli['bucket-name'] ??+ (await getOrCreateBucket({region})).bucketName;for (const site of deployedSites.sites) {await confirmCli({@@ -45,7 +28,7 @@ export const sitesRmallSubcommand = async () => {});const {totalSizeInBytes: totalSize} = await deleteSite({- bucketName: remotionBuckets[0].name,+ bucketName,siteName: site.id,region,onAfterItemDeleted: ({itemName}) => {