From 79ed44c5f0409056b6f365a383a0991c00048033 Mon Sep 17 00:00:00 2001 From: huanghaoyuan Date: Wed, 11 Oct 2023 14:21:01 +0800 Subject: [PATCH] storage: use anonymous credentials when ak sk is empty Signed-off-by: huanghaoyuan --- storage/s3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/s3.go b/storage/s3.go index 934b9c1..1ef01b8 100644 --- a/storage/s3.go +++ b/storage/s3.go @@ -67,7 +67,11 @@ func NewS3Client(cfg Cfg) (*S3Client, error) { } if !cfg.UseIAM { - awsCfg.Credentials = credentials.NewStaticCredentialsProvider(cfg.AK, cfg.SK, "") + if 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 }