remotion-dev/remotion · error · Exception
Failed to create bucket: {$exception->getMessage()}
Error message
Failed to create bucket: {$exception->getMessage()} What it means
Thrown by PHPClient when the AwsException caught during createBucket is re-raised as a generic Exception. The PHP client replicates the JS SDK bucket-creation logic, including the us-east-1 special case (no LocationConstraint). The most common root causes are missing s3:CreateBucket permission, an invalid region string, or hitting the account bucket quota.
Source
Thrown at packages/lambda-php/src/PHPClient.php:186
}
$bucket = $this->makeBucketName();
$s3Client = $this->createS3Client();
try {
$params = ['Bucket' => $bucket];
if ($this->region !== self::REGION_US_EAST) {
$params['CreateBucketConfiguration'] = [
'LocationConstraint' => $this->region
];
}
$s3Client->createBucket($params);
return $bucket;
} catch (AwsException $exception) {
throw new Exception("Failed to create bucket: " . $exception->getMessage());
}
}
/**
* Upload payload to S3
*/
private function uploadToS3(string $bucket, string $key, string $payload): void
{
$s3Client = $this->createS3Client();
try {
$s3Client->putObject([
'Bucket' => $bucket,
'Key' => $key,
'Body' => $payload,
'ContentType' => 'application/json',
]);
} catch (AwsException $exception) {View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Read $exception->getMessage() / $exception->getAwsErrorCode(): AccessDenied → add s3:CreateBucket; IllegalLocationConstraintException → fix region; BucketAlreadyExists → retry.
- Pre-create the `remotionlambda-` bucket and let the client discover it instead of creating.
- Validate the region string against the AWS region list before calling render.
- Request a quota increase if the account hit its bucket limit.
Example fix
// before
try {
$s3Client->createBucket($params);
} catch (AwsException $exception) {
throw new Exception("Failed to create bucket: " . $exception->getMessage());
}
// after - surface the AWS error code so the cause is diagnosable
} catch (AwsException $exception) {
throw new Exception(sprintf(
"Failed to create bucket in %s: [%s] %s",
$this->region,
$exception->getAwsErrorCode() ?? 'Unknown',
$exception->getMessage()
), 0, $exception);
} Defensive patterns
Strategy: try-catch
Try / catch
try {
$bucket = $this->getOrCreateBucket();
} catch (Exception $e) {
if (strpos($e->getMessage(), 'AccessDenied') !== false) {
// grant s3:CreateBucket to the caller role
}
throw $e;
} Prevention
- Validate the region string against the AWS region list before rendering.
- Pre-create the bucket if creation permission is intentionally withheld.
- Surface getAwsErrorCode() in the exception so the cause is diagnosable.
When it happens
Trigger: $s3Client->createBucket($params) throws AwsException — AccessDenied (no s3:CreateBucket), BucketAlreadyExists (random-name collision, essentially impossible), InvalidLocationConstraint (region string invalid), or AccountCountExceedsLimit (bucket quota).
Common situations: Production IAM roles that forbid bucket creation. Typo in the region like `us-east1`. Account already at the 100-bucket soft limit. Running the client with credentials from a role assumption that lacks the create permission.
Related errors
- failed to create bucket: %w
- You have multiple buckets (%s) in your S3 region (%s) starti
- Failed to upload to S3: {$exception->getMessage()}
- could not get location of S3 bucket %q: %w
- could not list S3 buckets: %w
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/41215534a113a4c0.
Report an issue: GitHub.