aws-sdk-go-v2 icon indicating copy to clipboard operation
aws-sdk-go-v2 copied to clipboard

LoadOptions for wrapWithCredentialsCache

Open fpozzobon opened this issue 2 years ago • 0 comments

Describe the feature

When resolving credentials, it would be nice to be able to define wrapWithCredentialsCache used here.

Consumer of AWS library could define their own credential cache mechanism (eg asynchronous) while beneficiate from resolveCredentialChain to get the right credential provider.

Use Case

Credential Cache does not support asynchronous retrieval of credentials. To be able to achieve this, it requires changes inside credential cache (PR aborted) or redefine provider after config.LoadDefaultConfig has been called (if consume wants to beneficiates from default configuration).

Proposed Solution

Adding LoadOptions:

// WrapWithCredentialsCache will wrap provider with custom credentialCache with the provided options
// default: aws.CredentialsCache if the provider is not already a aws.CredentialsCache
WrapWithCredentialsCache func(provider aws.CredentialsProvider, optFns ...func(options *aws.CredentialsCacheOptions)) aws.CredentialsProvider
func WithWrapWithCredentialsCache(v func(provider aws.CredentialsProvider, optFns ...func(options *aws.CredentialsCacheOptions)) aws.CredentialsProvider) aws.CredentialsProvider) LoadOptionsFunc {
	return func(o *LoadOptions) error {
		o.WrapWithCredentialsCache = v
		return nil
	}
}

Other Information

No response

Acknowledgements

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

AWS Go SDK V2 Module Versions Used

github.com/aws/[email protected] github.com/aws/aws-sdk-go-v2/[email protected] github.com/aws/aws-sdk-go-v2/[email protected]

Go version used

1.19

fpozzobon avatar Jan 30 '23 07:01 fpozzobon