Facilitate injection of AWSCredentials #3716
Labels
Extensions
feature-request
A feature should be added or improved.
needs-review
p2
This is a standard priority issue
Describe the feature
I'm hoping to inject into any class an instance of
AWSCredentials
. I'd like thisAWSCredentials
object to take into accountAmazon.Extensions.NETCore.Setup.AWSOptions
. The idea is that these credentials are resolved in the exact same way as the logic that creates ServiceClients.Use Case
Aside from copying
Amazon.Extensions.NETCore.Setup.CreateCredentials()
, how would I do the following?Class that makes a request against an endpoint that requires sigv4 headers:
Copy of
Amazon.Extensions.NETCore.Setup.CreateCredentials()
:Program.cs:
Test that verifies outbound call to endpoint requiring sigv4 headers:
Proposed Solution
AWSSDK.Extensions.NETCore.Setup
'sServiceCollectionExtensions
class to expose newAddCredentialsFactory()
methods that register a newIAWSCredentialsFactory
interface.ClientFactory..CreateCredentials()
to a newDefaultAWSCredentialsFactory
class.IAWSCredentialsFactory
can then be injected into any consumer's class (and by extension obtain anAWSCredentials
object).This has the added benefit that consumers can customize the behavior of credential creation to meet their needs by registering their own implementation of
IAWSCredentialsFactory
.Other Information
I've implemented these changes via PR #3715.
I believe that this would address #3461 and #3228.
Acknowledgements
AWS .NET SDK and/or Package version used
AWSSDK.Extensions.NETCore.Setup 3.7.400
Targeted .NET Platform
.NET 8
Operating System and version
macOS
The text was updated successfully, but these errors were encountered: