{"record":{"id":"41215534a113a4c0","repo":"remotion-dev/remotion","slug":"failed-to-create-bucket-exception-getmessage","errorCode":null,"errorMessage":"Failed to create bucket: {$exception->getMessage()}","messagePattern":"Failed to create bucket: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"packages/lambda-php/src/PHPClient.php","lineNumber":186,"sourceCode":"        }\n\n        $bucket = $this->makeBucketName();\n        $s3Client = $this->createS3Client();\n\n        try {\n            $params = ['Bucket' => $bucket];\n\n            if ($this->region !== self::REGION_US_EAST) {\n                $params['CreateBucketConfiguration'] = [\n                    'LocationConstraint' => $this->region\n                ];\n            }\n\n            $s3Client->createBucket($params);\n\n            return $bucket;\n        } catch (AwsException $exception) {\n            throw new Exception(\"Failed to create bucket: \" . $exception->getMessage());\n        }\n    }\n\n    /**\n     * Upload payload to S3\n     */\n    private function uploadToS3(string $bucket, string $key, string $payload): void\n    {\n        $s3Client = $this->createS3Client();\n\n        try {\n            $s3Client->putObject([\n                'Bucket' => $bucket,\n                'Key' => $key,\n                'Body' => $payload,\n                'ContentType' => 'application/json',\n            ]);\n        } catch (AwsException $exception) {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-php/src/PHPClient.php#L168-L204","documentation":"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.","triggerScenarios":"$s3Client->createBucket($params) throws AwsException — AccessDenied (no s3:CreateBucket), BucketAlreadyExists (random-name collision, essentially impossible), InvalidLocationConstraint (region string invalid), or AccountCountExceedsLimit (bucket quota).","commonSituations":"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.","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."],"exampleFix":"// before\ntry {\n    $s3Client->createBucket($params);\n} catch (AwsException $exception) {\n    throw new Exception(\"Failed to create bucket: \" . $exception->getMessage());\n}\n\n// after - surface the AWS error code so the cause is diagnosable\n} catch (AwsException $exception) {\n    throw new Exception(sprintf(\n        \"Failed to create bucket in %s: [%s] %s\",\n        $this->region,\n        $exception->getAwsErrorCode() ?? 'Unknown',\n        $exception->getMessage()\n    ), 0, $exception);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $bucket = $this->getOrCreateBucket();\n} catch (Exception $e) {\n    if (strpos($e->getMessage(), 'AccessDenied') !== false) {\n        // grant s3:CreateBucket to the caller role\n    }\n    throw $e;\n}","preventionTips":["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."],"tags":["aws","s3","bucket","iam","region","php","lambda-php"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}