Skip to content

🎥 Make videos programmatically with React

better error message if an old version failed to set up the bucket correctly

Jonny Burger45d7dc8b915f
diff --git a/packages/lambda/src/api/create-bucket.ts b/packages/lambda/src/api/create-bucket.ts
index d94726a959..c93bbae9cc 100644
--- a/packages/lambda/src/api/create-bucket.ts
+++ b/packages/lambda/src/api/create-bucket.ts
@@ -52,10 +52,20 @@ export const createBucket = async ({
throw err;
}
- await getS3Client(region, null).send(
- new PutBucketAclCommand({
- Bucket: bucketName,
- ACL: 'public-read',
- })
- );
+ try {
+ await getS3Client(region, null).send(
+ new PutBucketAclCommand({
+ Bucket: bucketName,
+ ACL: 'public-read',
+ })
+ );
+ } catch (err) {
+ if ((err as Error).message.includes('The bucket does not allow ACLs')) {
+ throw new Error(
+ `Could not add an ACL to the bucket. This might have happened because the bucket was already successfully created before but then failed to configure correctly. We recommend to delete the bucket (${bucketName}) if it is empty and start over to fix the problem.`
+ );
+ }
+
+ throw err;
+ }
};