Skip to content

Commit b6c30d8

Browse files
feat: possibility to use a service account
1 parent b7e5e33 commit b6c30d8

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ All metrics have the label `name` equals to the config `name` key.
105105

106106
### AWS
107107

108-
- `AWS_ACCESS_KEY_ID`: AWS secret key ID
109-
- `AWS_SECRET_ACCESS_KEY`: AWS secret access key
108+
- `AWS_ACCESS_KEY_ID`: AWS access key ID (optional)
109+
- `AWS_SECRET_ACCESS_KEY`: AWS secret access key (optional)
110+
111+
When running in Kubernetes with a service account that has the appropriate
112+
bucket permissions (for example IAM Roles for Service Accounts), the
113+
application automatically uses the service account credentials and these
114+
variables are not required.
110115

111116
### Minio
112117

pkg/bucket/s3.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ type S3File struct {
2727
}
2828

2929
func NewS3Bucket(s3 *config.S3) *S3Bucket {
30-
s3Session := session.Must(session.NewSession(&aws.Config{
31-
Region: aws.String(s3.Region),
32-
}))
33-
34-
return &S3Bucket{
35-
Session: s3Session,
36-
S3: s3,
37-
}
30+
s3Session := session.Must(session.NewSessionWithOptions(session.Options{
31+
Config: aws.Config{
32+
Region: aws.String(s3.Region),
33+
},
34+
SharedConfigState: session.SharedConfigEnable,
35+
}))
36+
37+
return &S3Bucket{
38+
Session: s3Session,
39+
S3: s3,
40+
}
3841
}
3942

4043
func (bucket *S3Bucket) Upload(filename string, destFolder string) error {

0 commit comments

Comments
 (0)