Skip to content

Commit

Permalink
Support custom S3 endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
EAliakbar authored Dec 14, 2022
1 parent 941c5a8 commit 61f329d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ another-service/2020/12/01/01.log.gz
another-service/2020/12/01/23.log.gz
another-service/2020/12/02/00.log.gz
```

You can Also set `S3_ENDPOINT` env for using an S3-Compatible Object Storage like Minio
11 changes: 9 additions & 2 deletions exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ module.exports = function createExporter (opts) {
assert(awsSecretAccessKey, `The parameter 'opts.awsSecretAccessKey' is required.`)
assert(lokiHost, `The parameter 'opts.lokiHost' is required.`)

const s3 = new S3({
s3_config = {
region: awsRegion,
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretAccessKey
})
}

if (process.env.S3_ENDPOINT) {
s3_config.endpoint = process.env.S3_ENDPOINT
s3_config.s3ForcePathStyle = true
}

const s3 = new S3(s3_config)

const createS3WriteStream = (key) => new s3WriteStream(s3, {Bucket: awsBucket, Key: key})

Expand Down

0 comments on commit 61f329d

Please sign in to comment.