Skip to content

Commit

Permalink
change BaseEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtwinkle committed Jan 19, 2024
1 parent 367d7f4 commit 4f04567
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions aws/awss3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import (
"context"
"encoding/gob"
"fmt"
"net/url"

"github.com/88labs/go-utils/aws/awsconfig"

"github.com/88labs/go-utils/aws/ctxawslocal"
"github.com/aws/aws-sdk-go-v2/aws"
awsConfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
smithyendpoints "github.com/aws/smithy-go/endpoints"
)

// GetClient
Expand All @@ -34,18 +33,6 @@ func GetClient(ctx context.Context, region awsconfig.Region) (*s3.Client, error)
return s3.NewFromConfig(awsCfg), nil
}

type staticResolver struct {
endpoint url.URL
}

func (r *staticResolver) ResolveEndpoint(_ context.Context, _ s3.EndpointParameters) (
smithyendpoints.Endpoint, error,
) {
return smithyendpoints.Endpoint{
URI: r.endpoint,
}, nil
}

func getClientLocal(ctx context.Context, localProfile LocalProfile) (*s3.Client, error) {
awsCfg, err := awsConfig.LoadDefaultConfig(ctx,
awsConfig.WithCredentialsProvider(credentials.StaticCredentialsProvider{
Expand All @@ -59,23 +46,9 @@ func getClientLocal(ctx context.Context, localProfile LocalProfile) (*s3.Client,
if err != nil {
return nil, fmt.Errorf("unable to load SDK config, %w", err)
}
//u, err := url.Parse(localProfile.Endpoint)
//if err != nil {
// return nil, fmt.Errorf("custom endpoint parse error, %w", err)
//}
return s3.NewFromConfig(awsCfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(localProfile.Endpoint)
//o.EndpointResolverV2 = &staticResolver{
// endpoint: *u,
//}
o.UsePathStyle = true
//o.Credentials = credentials.StaticCredentialsProvider{
// Value: aws.Credentials{
// AccessKeyID: localProfile.AccessKey,
// SecretAccessKey: localProfile.SecretAccessKey,
// SessionToken: localProfile.SessionToken,
// },
//}
}), nil
}

Expand Down

0 comments on commit 4f04567

Please sign in to comment.