Skip to content

add support for per-service options to aws.Config #3141

@rittneje

Description

@rittneje

Describe the feature

Allow for aws.Config to hold "options" to be applied only when constructing the client for a particular service.

Use Case

In a monorepo, it is useful to have a single framework for configuring the SDK. Today, while we can configure the "base" aws.Config itself, it is not feasible to for example apply a consistent configuration to all DynamoDB service clients.

While we can somewhat achieve this today by writing our own wrapper functions around every service client constructor, this requires all developers to remember to do this.

Proposed Solution

Add a field to aws.Config that maps from a service ID (e.g., dynamodb.ServiceID) to a list of callback functions ([]func(any)).

When calling for example dynamodb.NewFromConfig, it will check if the aws.Config contains an entry for the service ID in question. If it does, it will pass the service-specific options struct (e.g., dynamodb.Options) to each callback.

Alternatively, add a field like func(string) []func(any) to aws.Config, which is a function that will accept the service ID and return the list of options callback, if any. The advantage of this approach is that the set of options can be determined more dynamically (e.g., mapping the service ID to an environment variable).

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Go SDK V2 Module Versions Used

n/a

Go version used

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p2This is a standard priority issuequeuedThis issues is on the AWS team's backlog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions