From cf0bd1a17df4c59800aeaec583fe879addc56d17 Mon Sep 17 00:00:00 2001 From: Taukon <83957880+Taukon@users.noreply.github.com> Date: Sat, 7 Jun 2025 04:34:45 +0900 Subject: [PATCH] feat: add endpoint config for S3 and DynamoDB --- config/custom-environment-variables.yaml | 2 ++ config/default.yaml | 1 + src/store/S3Manager.js | 11 +++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config/custom-environment-variables.yaml b/config/custom-environment-variables.yaml index 627c0698..51324027 100644 --- a/config/custom-environment-variables.yaml +++ b/config/custom-environment-variables.yaml @@ -17,9 +17,11 @@ firehose: s3: region: RTCSTATS_S3_AWS_REGION bucket: RTCSTATS_S3_BUCKET + endpoint: RTCSTATS_S3_ENDPOINT dynamo: tableName: RTCSTATS_METADATA_TABLE + endpoint: RTCSTATS_DYNAMODB_ENDPOINT webhooks: apiEndpoint: RTCSTATS_WEBHOOK_ENDPOINT diff --git a/config/default.yaml b/config/default.yaml index b175c15e..71d4d5c4 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -27,6 +27,7 @@ s3: useIAMAuth: # Default value is 2 days signedLinkExpirationSec: 172800 + endpoint: firehose: accessKeyId: diff --git a/src/store/S3Manager.js b/src/store/S3Manager.js index 7e79c73a..d23da97e 100644 --- a/src/store/S3Manager.js +++ b/src/store/S3Manager.js @@ -16,7 +16,7 @@ class S3Manager { * @param {*} config - Configuration object that contains S3 settings such as region, bucket, etc. */ constructor(config) { - const { region, useIAMAuth, bucket, signedLinkExpirationSec } = config; + const { region, useIAMAuth, bucket, signedLinkExpirationSec, endpoint } = config; assert(region); assert(bucket); @@ -27,11 +27,9 @@ class S3Manager { AWS.config = config; } - this.s3bucket = new AWS.S3({ - params: { - Bucket: bucket - } - }); + // Use endpoint for local S3 (e.g., MinIO or LocalStack). + // Falls back to default AWS S3 if no endpoint is specified. + this.s3bucket = new AWS.S3(endpoint ? { endpoint } : {}); this.bucket = bucket; this.signedLinkExpirationSec = signedLinkExpirationSec; @@ -50,6 +48,7 @@ class S3Manager { const compressedStream = readStream.pipe(gzipStream); return this.s3bucket.upload({ + Bucket: this.bucket, Key: key, Body: compressedStream }).promise();