Skip to content

Commit 65af682

Browse files
committed
S3 explicitly credentials shall have more priority than environment variables
1 parent 1acc53c commit 65af682

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/storage/s3.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,6 @@ func (s *S3) Connect(ctx context.Context) error {
115115
if s.Config.Region != "" {
116116
awsConfig.Region = s.Config.Region
117117
}
118-
if s.Config.AccessKey != "" && s.Config.SecretKey != "" {
119-
awsConfig.Credentials = credentials.StaticCredentialsProvider{
120-
Value: aws.Credentials{
121-
AccessKeyID: s.Config.AccessKey,
122-
SecretAccessKey: s.Config.SecretKey,
123-
},
124-
}
125-
}
126-
127118
awsRoleARN := os.Getenv("AWS_ROLE_ARN")
128119
if s.Config.AssumeRoleARN != "" || awsRoleARN != "" {
129120
stsClient := sts.NewFromConfig(awsConfig)
@@ -142,6 +133,15 @@ func (s *S3) Connect(ctx context.Context) error {
142133
)
143134
}
144135

136+
if s.Config.AccessKey != "" && s.Config.SecretKey != "" {
137+
awsConfig.Credentials = credentials.StaticCredentialsProvider{
138+
Value: aws.Credentials{
139+
AccessKeyID: s.Config.AccessKey,
140+
SecretAccessKey: s.Config.SecretKey,
141+
},
142+
}
143+
}
144+
145145
if s.Config.Debug {
146146
awsConfig.Logger = newS3Logger(s.Log)
147147
awsConfig.ClientLogMode = aws.LogRetries | aws.LogRequest | aws.LogResponse

0 commit comments

Comments
 (0)