Skip to content

Commit 8dfa5af

Browse files
authored
fix: Add optional configurationSource parameter to ProfileCredentialsProvider (#1140)
1 parent f09c714 commit 8dfa5af

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "d7c1e490-7fc3-48fe-8faf-914a5f09c671",
3+
"type": "misc",
4+
"description": "Add optional `configurationSource` parameter to `ProfileCredentialsProvider`"
5+
}

aws-runtime/aws-config/api/aws-config.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public final class aws/sdk/kotlin/runtime/auth/credentials/ProcessCredentialsPro
9999

100100
public final class aws/sdk/kotlin/runtime/auth/credentials/ProfileCredentialsProvider : aws/smithy/kotlin/runtime/auth/awscredentials/CloseableCredentialsProvider {
101101
public fun <init> ()V
102-
public fun <init> (Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/http/engine/HttpClientEngine;)V
103-
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/http/engine/HttpClientEngine;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
102+
public fun <init> (Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/http/engine/HttpClientEngine;Laws/sdk/kotlin/runtime/config/profile/AwsConfigurationSource;)V
103+
public synthetic fun <init> (Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/http/engine/HttpClientEngine;Laws/sdk/kotlin/runtime/config/profile/AwsConfigurationSource;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
104104
public fun close ()V
105105
public final fun getHttpClient ()Laws/smithy/kotlin/runtime/http/engine/HttpClientEngine;
106106
public final fun getPlatformProvider ()Laws/smithy/kotlin/runtime/util/PlatformProvider;

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/auth/credentials/ProfileCredentialsProvider.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import aws.sdk.kotlin.runtime.auth.credentials.profile.RoleArn
1111
import aws.sdk.kotlin.runtime.client.AwsClientOption
1212
import aws.sdk.kotlin.runtime.config.AwsSdkSetting
1313
import aws.sdk.kotlin.runtime.config.imds.ImdsClient
14+
import aws.sdk.kotlin.runtime.config.profile.AwsConfigurationSource
1415
import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig
1516
import aws.sdk.kotlin.runtime.region.resolveRegion
1617
import aws.smithy.kotlin.runtime.auth.awscredentials.CloseableCredentialsProvider
@@ -73,12 +74,15 @@ import kotlin.coroutines.coroutineContext
7374
* @param platformProvider The platform API provider
7475
* @param httpClient the [HttpClientEngine] instance to use to make requests. NOTE: This engine's resources and lifetime
7576
* are NOT managed by the provider. Caller is responsible for closing.
77+
* @param configurationSource An optional configuration source to use for loading shared config. If not provided,
78+
* it will be resolved from the environment.
7679
*/
7780
public class ProfileCredentialsProvider(
7881
public val profileName: String? = null,
7982
public val region: String? = null,
8083
public val platformProvider: PlatformProvider = PlatformProvider.System,
8184
public val httpClient: HttpClientEngine? = null,
85+
private val configurationSource: AwsConfigurationSource? = null,
8286
) : CloseableCredentialsProvider {
8387
private val namedProviders = mapOf(
8488
"Environment" to EnvironmentCredentialsProvider(platformProvider::getenv),
@@ -97,7 +101,7 @@ public class ProfileCredentialsProvider(
97101

98102
override suspend fun resolve(attributes: Attributes): Credentials {
99103
val logger = coroutineContext.logger<ProfileCredentialsProvider>()
100-
val sharedConfig = loadAwsSharedConfig(platformProvider, profileName)
104+
val sharedConfig = loadAwsSharedConfig(platformProvider, profileName, configurationSource)
101105
logger.debug { "Loading credentials from profile `${sharedConfig.activeProfile.name}`" }
102106
val chain = ProfileChain.resolve(sharedConfig)
103107

0 commit comments

Comments
 (0)