Skip to content

🎥 Make videos programmatically with React

same pattern - forceBucketName

Jonny Burger88027a16ee33
diff --git a/packages/docs/docs/lambda/getsites.md b/packages/docs/docs/lambda/getsites.md
index 2af3337c48..89ab3e2025 100644
--- a/packages/docs/docs/lambda/getsites.md
+++ b/packages/docs/docs/lambda/getsites.md
@@ -50,9 +50,11 @@ An object with the following properties:
The [AWS region](/docs/lambda/region-selection) which you want to query.
-### `forced?`
+### `forceBucketName?`<AvailableFrom v="3.3.102"/>
-Whether the bucket name is forced or not. Forcing overrides the default prefix (`REMOTION_BUCKET_PREFIX`, which is currently `'remotionlambda-'`).
+_optional_
+
+Specify a specific bucket name to be used. [This is not recommended](/docs/lambda/multiple-buckets), instead let Remotion discover the right bucket automatically.
## Return value
diff --git a/packages/lambda/src/api/get-buckets.ts b/packages/lambda/src/api/get-buckets.ts
index 0970628bde..6795a1342f 100644
--- a/packages/lambda/src/api/get-buckets.ts
+++ b/packages/lambda/src/api/get-buckets.ts
@@ -1,7 +1,7 @@
import {GetBucketLocationCommand, ListBucketsCommand} from '@aws-sdk/client-s3';
+import {REMOTION_BUCKET_PREFIX} from '../defaults';
import type {AwsRegion} from '../pricing/aws-regions';
import {getS3Client} from '../shared/aws-clients';
-import {REMOTION_BUCKET_PREFIX} from '../shared/constants';
import {parseBucketName} from '../shared/validate-bucketname';
export type BucketWithLocation = {
@@ -11,7 +11,8 @@ export type BucketWithLocation = {
};
export const getRemotionS3Buckets = async (
- region: AwsRegion, bucketPrefix: string = REMOTION_BUCKET_PREFIX
+ region: AwsRegion,
+ forceBucketName?: string
): Promise<{
remotionBuckets: BucketWithLocation[];
}> => {
@@ -22,9 +23,13 @@ export const getRemotionS3Buckets = async (
return {remotionBuckets: []};
}
- const remotionBuckets = Buckets.filter((b) =>
- b.Name?.startsWith(bucketPrefix)
- );
+ const remotionBuckets = Buckets.filter((b) => {
+ if (forceBucketName) {
+ return b.Name === forceBucketName;
+ }
+
+ return b.Name?.startsWith(REMOTION_BUCKET_PREFIX);
+ });
const locations = await Promise.all(
remotionBuckets.map(async (bucket) => {
diff --git a/packages/lambda/src/api/get-sites.ts b/packages/lambda/src/api/get-sites.ts
index c9636755ce..f6a626a4fb 100644
--- a/packages/lambda/src/api/get-sites.ts
+++ b/packages/lambda/src/api/get-sites.ts
@@ -16,6 +16,7 @@ type Site = {
export type GetSitesInput = {
region: AwsRegion;
+ forceBucketName?: string;
};
export type GetSitesOutput = {
@@ -31,8 +32,11 @@ export type GetSitesOutput = {
*/
export const getSites = async ({
region,
-}: GetSitesInput, forced?: boolean): Promise<GetSitesOutput> => {
- const {remotionBuckets} = forced ? await getRemotionS3Buckets(region) : await getRemotionS3Buckets(region, "");
+ forceBucketName,
+}: GetSitesInput): Promise<GetSitesOutput> => {
+ const {remotionBuckets} = forceBucketName
+ ? await getRemotionS3Buckets(region, forceBucketName)
+ : await getRemotionS3Buckets(region);
const accountId = await getAccountId({region});
const sites: {[key: string]: Site} = {};
diff --git a/packages/lambda/src/cli/commands/sites/rm.ts b/packages/lambda/src/cli/commands/sites/rm.ts
index 37211723cf..360edfef95 100644
--- a/packages/lambda/src/cli/commands/sites/rm.ts
+++ b/packages/lambda/src/cli/commands/sites/rm.ts
@@ -25,13 +25,14 @@ export const sitesRmSubcommand = async (args: string[]) => {
const region = getAwsRegion();
const deployedSites = await getSites({
region,
- }, Boolean(parsedLambdaCli['force-bucket-name']));
+ forceBucketName: parsedLambdaCli['force-bucket-name'],
+ });
- for (const siteName of args) {
- const bucketName =
- parsedLambdaCli['force-bucket-name'] ??
- (await getOrCreateBucket({region})).bucketName;
+ const bucketName =
+ parsedLambdaCli['force-bucket-name'] ??
+ (await getOrCreateBucket({region})).bucketName;
+ for (const siteName of args) {
const site = deployedSites.sites.find((s) => s.id === siteName.trim());
if (!site) {
Log.error(