Skip to content

Commit 98f34dd

Browse files
authored
feat: add endpoint config for S3 and DynamoDB (#126)
1 parent 6cc63cd commit 98f34dd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

config/custom-environment-variables.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ firehose:
1717
s3:
1818
region: RTCSTATS_S3_AWS_REGION
1919
bucket: RTCSTATS_S3_BUCKET
20+
endpoint: RTCSTATS_S3_ENDPOINT
2021

2122
dynamo:
2223
tableName: RTCSTATS_METADATA_TABLE
24+
endpoint: RTCSTATS_DYNAMODB_ENDPOINT
2325

2426
webhooks:
2527
apiEndpoint: RTCSTATS_WEBHOOK_ENDPOINT

config/default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ s3:
2727
useIAMAuth:
2828
# Default value is 2 days
2929
signedLinkExpirationSec: 172800
30+
endpoint:
3031

3132
firehose:
3233
accessKeyId:

src/store/S3Manager.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class S3Manager {
1616
* @param {*} config - Configuration object that contains S3 settings such as region, bucket, etc.
1717
*/
1818
constructor(config) {
19-
const { region, useIAMAuth, bucket, signedLinkExpirationSec } = config;
19+
const { region, useIAMAuth, bucket, signedLinkExpirationSec, endpoint } = config;
2020

2121
assert(region);
2222
assert(bucket);
@@ -27,11 +27,9 @@ class S3Manager {
2727
AWS.config = config;
2828
}
2929

30-
this.s3bucket = new AWS.S3({
31-
params: {
32-
Bucket: bucket
33-
}
34-
});
30+
// Use endpoint for local S3 (e.g., MinIO or LocalStack).
31+
// Falls back to default AWS S3 if no endpoint is specified.
32+
this.s3bucket = new AWS.S3(endpoint ? { endpoint } : {});
3533

3634
this.bucket = bucket;
3735
this.signedLinkExpirationSec = signedLinkExpirationSec;
@@ -50,6 +48,7 @@ class S3Manager {
5048
const compressedStream = readStream.pipe(gzipStream);
5149

5250
return this.s3bucket.upload({
51+
Bucket: this.bucket,
5352
Key: key,
5453
Body: compressedStream
5554
}).promise();

0 commit comments

Comments
 (0)