add auto_create_bucket defaulting to false, enabled for tests

This commit is contained in:
Matthew Farrellee 2025-08-21 19:53:26 -04:00
parent d67d679baf
commit 72036891e8
5 changed files with 47 additions and 0 deletions

View file

@ -59,6 +59,11 @@ async def _create_bucket_if_not_exists(client: boto3.client, config: S3FilesImpl
except ClientError as e:
error_code = e.response["Error"]["Code"]
if error_code == "404":
if not config.auto_create_bucket:
raise RuntimeError(
f"S3 bucket '{config.bucket_name}' does not exist. "
f"Either create the bucket manually or set 'auto_create_bucket: true' in your configuration."
) from e
try:
# For us-east-1, we can't specify LocationConstraint
if config.region == "us-east-1":