Skip to content

Commit 1e9aac3

Browse files
Copilotzhijian-pro
andauthored
object/s3: use default credential chain in autoS3Region when accessKey is empty (#6754)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: zhijian-pro <31313340+zhijian-pro@users.noreply.github.com>
1 parent f13b3df commit 1e9aac3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/object/s3.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,13 @@ func (s *s3client) SetStorageClass(sc string) error {
384384
}
385385

386386
func autoS3Region(bucketName, accessKey, secretKey string) (string, error) {
387-
cfg, err := config.LoadDefaultConfig(ctx, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")))
387+
var cfg aws.Config
388+
var err error
389+
if accessKey != "" {
390+
cfg, err = config.LoadDefaultConfig(ctx, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, "")))
391+
} else {
392+
cfg, err = config.LoadDefaultConfig(ctx)
393+
}
388394
if err != nil {
389395
return "", err
390396
}

0 commit comments

Comments
 (0)