feat(backend): support s3 connection without creds

This commit is contained in:
Alexander 2024-03-28 12:30:00 +01:00
parent 19de9067e0
commit 2ac3d38078

View file

@ -34,9 +34,13 @@ func NewS3(cfg *objConfig.ObjectsConfig) (objectstorage.ObjectStorage, error) {
if cfg == nil {
return nil, fmt.Errorf("s3 config is nil")
}
creds := credentials.NewStaticCredentials(cfg.AWSAccessKeyID, cfg.AWSSecretAccessKey, "")
if cfg.AWSAccessKeyID == "" || cfg.AWSSecretAccessKey == "" {
creds = nil
}
config := &aws.Config{
Region: aws.String(cfg.AWSRegion),
Credentials: credentials.NewStaticCredentials(cfg.AWSAccessKeyID, cfg.AWSSecretAccessKey, ""),
Credentials: creds,
}
if cfg.AWSEndpoint != "" {
config.Endpoint = aws.String(cfg.AWSEndpoint)