From 9c043c6c14cfbd8ea3ccda162fd0127e8d39e476 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 28 Mar 2025 12:17:27 -0400 Subject: [PATCH] tusd: Attempt to derive S3 region. We already do this in computed_settings.py, but only if the S3 (secret) key is set. Those aren't required to be set, and tusd _requires_ a region, so we try again to suss it out here. --- zerver/management/commands/runtusd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zerver/management/commands/runtusd.py b/zerver/management/commands/runtusd.py index 9a660a7e2b..6d4630ba7a 100644 --- a/zerver/management/commands/runtusd.py +++ b/zerver/management/commands/runtusd.py @@ -63,6 +63,10 @@ class Command(BaseCommand): env_vars["AWS_ACCESS_KEY_ID"] = settings.S3_KEY if settings.S3_SECRET_KEY is not None: env_vars["AWS_SECRET_ACCESS_KEY"] = settings.S3_SECRET_KEY - assert settings.S3_REGION is not None - env_vars["AWS_REGION"] = settings.S3_REGION + if settings.S3_REGION is None: + import boto3 + + env_vars["AWS_REGION"] = boto3.client("s3").meta.region_name + else: + env_vars["AWS_REGION"] = settings.S3_REGION os.execvpe("tusd", tusd_args, env_vars)