remotion-dev/remotion · error · error

failed to create bucket: %w

Error message

failed to create bucket: %w

What it means

Returned by getOrCreateBucket when svc.CreateBucket fails while trying to provision a new Remotion bucket. The wrap carries the underlying S3 error. The create path includes the special-case for us-east-1 (no LocationConstraint), so a region mismatch between the client and the bucket constraint is a frequent culprit, as is a missing s3:CreateBucket permission.

Source

Thrown at packages/lambda-go/s3.go:145

			strings.Join(buckets, ", "), region, bucketNamePrefix,
		)
	}
	if len(buckets) == 1 {
		return buckets[0], nil
	}

	bucket, err := makeBucketName(region)
	if err != nil {
		return "", err
	}
	input := &s3.CreateBucketInput{Bucket: new(bucket)}
	if region != regionUsEast1 {
		input.CreateBucketConfiguration = &types.CreateBucketConfiguration{
			LocationConstraint: types.BucketLocationConstraint(region),
		}
	}
	if _, err := svc.CreateBucket(context.TODO(), input); err != nil {
		return "", fmt.Errorf("failed to create bucket: %w", err)
	}
	return bucket, nil
}

// uploadInputPropsToS3 writes the serialized props to S3 as private JSON.
func uploadInputPropsToS3(svc objectUploader, bucket string, key string, payload string) error {
	_, err := svc.PutObject(context.TODO(), &s3.PutObjectInput{
		Bucket:      new(bucket),
		Key:         new(key),
		Body:        strings.NewReader(payload),
		ContentType: new("application/json"),
	})
	if err != nil {
		return fmt.Errorf("failed to upload inputProps to S3: %w", err)
	}
	return nil
}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Inspect the wrapped smithy.APIError code: AccessDenied → grant s3:CreateBucket; IllegalLocationConstraintException → check region string; BucketAlreadyExists → retry (random hash collision is astronomically unlikely but a re-run regenerates the name).
  2. Pre-create the `remotionlambda-` bucket manually and let the client discover it instead of creating.
  3. Confirm region is a valid AWS region identifier (e.g. `us-east-1`, not `us-east1`).
  4. Ensure the caller's account is not over its bucket limit (soft limit 100).
Defensive patterns

Strategy: try-catch

Try / catch

bucket, err := getOrCreateBucket(svc, region)
if err != nil {
    var awsErr smithy.APIError
    if errors.As(err, &awsErr) {
        switch awsErr.ErrorCode() {
        case "AccessDenied":
            // grant s3:CreateBucket
        case "BucketAlreadyExists":
            // random-name collision: retry once
        case "IllegalLocationConstraintException":
            // region string invalid or equals us-east-1 in the constraint
        }
    }
    return "", err
}

Prevention

When it happens

Trigger: svc.CreateBucket returns BucketAlreadyExists (random-hash collision, extremely rare), AccessDenied (no s3:CreateBucket), IllegalLocationConstraintException (region passed to LocationConstraint is invalid or equals us-east-1), or a transport error.

Common situations: Production IAM roles that intentionally forbid bucket creation. Deploying into a brand-new region string the SDK does not accept. A stale AWS_REGION pointing at a different region than the LocationConstraint the code derived from it.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/d72128f0da41b357. Report an issue: GitHub.