aws-sdk-kotlin
aws-sdk-kotlin copied to clipboard
Allow loading config files only once per-client
Describe the feature
Shared config files (e.g., ~/.aws/config and ~/.aws/credentials) may be used by the SDK to determine credentials for service clients via ProfileCredentialsProvider. As written, the provider will read the config on every request for credentials—potentially on every API request. (In the default configuration for SDK clients, this will be read as part of the default credentials chain, which caches credentials for 15 minutes.)
This may be desirable under some circumstances but other use cases may require reading the config files only once and reusing those values for the duration of the client. Consider adding a mechanism (e.g., a parameter to the provider) which controls whether files are parsed on demand (current behavior) or only once.
Is your Feature Request related to a problem?
n/a
Proposed Solution
One potential solution is a parameter to the provider that allows configuring when and how often config files are read. For example:
val currentBehavior = ProfileCredentialsProvider()
val loadOnlyOnce = ProfileCredentialsProvider(loadBehavior = ProfileLoadBehavior.LoadOnInitialization)
Options to consider for loading behavior are:
- load on every request (current behavior)
- load once on provider initialization (greedy)
- load once on first request (lazy)
Describe alternative solutions or features you've considered
No response
Acknowledge
- [X] I may be able to implement this feature request
AWS Kotlin SDK version used
0.19.5-beta
Platform (JVM/JS/Native)
JVM
Operating System and version
Amazon Linux 2