-
Hi, The following client, using a func NewAWSClient() (*AWSClient, error) {
endpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: "https://s3.us-west-2.amazonaws.com",
}, nil
})
cfg := aws.Config{
Region: "us-west-2",
Credentials: credentials.NewStaticCredentialsProvider("accessKey", "secretKey", ""),
EndpointResolverWithOptions: endpoint,
}
return &AWSClient{Client: s3.NewFromConfig(cfg)}, nil
} When hitting AWS endpoint, this client return the following error:
Of course if you load the configuration from the environment using func NewAWSClient() (*AWSClient, error) {
endpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: "https://s3.us-west-2.amazonaws.com",
}, nil
})
cfg, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
return nil, fmt.Errorf("couldn't load default configuration. Have you set up your AWS account?")
}
return &AWSClient{Client: s3.NewFromConfig(cfg)}, nil
} I also tried to create the default with a cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion("us-west-2"),
config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(opts.AccessKey, opts.SecretKey, "")),
config.WithEndpointResolverWithOptions(endpoint),
) As I said we have a requirement to provide config from our own sources, which have a different format. Is there a work around to this issue? Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Oh, I think I found where the problem was, I was missing endpoint := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: "https://s3.us-west-2.amazonaws.com",
SigningRegion: "us-west-2",
}, nil
}) Cheers. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Oh, I think I found where the problem was, I was missing
SigningRegion
in the custom endpoint resolver.Cheers.