Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
storage: use anonymous credentials when ak sk is empty
Browse files Browse the repository at this point in the history
Signed-off-by: huanghaoyuan <[email protected]>
  • Loading branch information
huanghaoyuanhhy committed Oct 11, 2023
1 parent ed33a98 commit 3d28f1a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ func NewS3Client(cfg Cfg) (*S3Client, error) {
awsCfg.EndpointResolverWithOptions = resolver
}

if !cfg.UseIAM {
if !cfg.UseIAM && len(cfg.AK) != 0 && len(cfg.SK) != 0 {
awsCfg.Credentials = credentials.NewStaticCredentialsProvider(cfg.AK, cfg.SK, "")
} else {
awsCfg.Credentials = aws.AnonymousCredentials{}
}
return &S3Client{cli: s3.NewFromConfig(awsCfg)}, nil
}
Expand Down

0 comments on commit 3d28f1a

Please sign in to comment.