diff --git a/service/s3/api_client.go b/service/s3/api_client.go index e59172545a7..5e1c36672d1 100644 --- a/service/s3/api_client.go +++ b/service/s3/api_client.go @@ -97,10 +97,8 @@ func New(config aws.Config) *Client { ), } - if config.AdditionalConfig != nil { - if err := config.AdditionalConfig.ResolveConfig(resolveClientConfig(svc)); err != nil { - panic(fmt.Errorf("failed to resolve service configuration: %v", err)) - } + if err := resolveClientConfig(svc, config.ConfigSources); err != nil { + panic(fmt.Errorf("failed to resolve service configuration: %v", err)) } // Handlers diff --git a/service/s3/api_client_config.go b/service/s3/api_client_config.go index 2289f8da64e..b59012fb7f2 100644 --- a/service/s3/api_client_config.go +++ b/service/s3/api_client_config.go @@ -6,14 +6,16 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3/internal/external" ) -func resolveClientConfig(svc *Client) func(configs []interface{}) error { - return func(configs []interface{}) error { - if value, ok, err := external.ResolveUseARNRegion(configs); err != nil { - return err - } else if ok { - svc.UseARNRegion = value - } - +func resolveClientConfig(svc *Client, configs []interface{}) error { + if len(configs) == 0 { return nil } + + if value, ok, err := external.ResolveUseARNRegion(configs); err != nil { + return err + } else if ok { + svc.UseARNRegion = value + } + + return nil } diff --git a/service/s3/api_client_config_test.go b/service/s3/api_client_config_test.go index bd263602db3..9a5b7c709b2 100644 --- a/service/s3/api_client_config_test.go +++ b/service/s3/api_client_config_test.go @@ -18,7 +18,7 @@ func TestExternalConfigResolver(t *testing.T) { t.Run("UseARNRegion", func(t *testing.T) { t.Run("value not found", func(t *testing.T) { svc := &Client{} - err := resolveClientConfig(svc)([]interface{}{ + err := resolveClientConfig(svc, []interface{}{ mockUseARNRegion(func() (value bool, ok bool, err error) { return value, ok, err }), @@ -32,7 +32,7 @@ func TestExternalConfigResolver(t *testing.T) { }) t.Run("resolve error", func(t *testing.T) { svc := &Client{} - err := resolveClientConfig(svc)([]interface{}{ + err := resolveClientConfig(svc, []interface{}{ mockUseARNRegion(func() (value bool, ok bool, err error) { err = fmt.Errorf("resolve error") return value, ok, err @@ -47,7 +47,7 @@ func TestExternalConfigResolver(t *testing.T) { }) t.Run("value found", func(t *testing.T) { svc := &Client{} - err := resolveClientConfig(svc)([]interface{}{ + err := resolveClientConfig(svc, []interface{}{ mockUseARNRegion(func() (value bool, ok bool, err error) { value = true return value, true, err