Skip to content

Instantly share code, notes, and snippets.

@anboo
Created January 2, 2024 08:52
Show Gist options
  • Save anboo/036b8579811afb75b14cc9999602edf8 to your computer and use it in GitHub Desktop.
Save anboo/036b8579811afb75b14cc9999602edf8 to your computer and use it in GitHub Desktop.
Yandex cloud S3 storage example connect from golang aws S3
customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
if service == s3.ServiceID {
return aws.Endpoint{
PartitionID: "yc",
URL: "https://storage.yandexcloud.net",
}, nil
}
return aws.Endpoint{}, fmt.Errorf("unknown endpoint requested")
})
cfg, err := config.LoadDefaultConfig(
context.Background(),
config.WithEndpointResolverWithOptions(customResolver),
config.WithCredentialsProvider(
&credentials.StaticCredentialsProvider{
Value: aws.Credentials{
AccessKeyID: conf.YandexKeyID,
SecretAccessKey: conf.YandexKeySecret,
},
},
),
config.WithRegion("auto"),
)
client := s3.NewFromConfig(cfg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment