Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/c307c127-15ec-4c36-b559-5bbf17465197.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "c307c127-15ec-4c36-b559-5bbf17465197",
"type": "bugfix",
"description": "Pass client configuration's httpClientEngine to the CredentialsProvider and region to ProfileCredentialsProvider",
"issues": ["#711"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ import aws.smithy.kotlin.runtime.util.PlatformProvider
* @param platformProvider The platform API provider
* @param httpClientEngine the [HttpClientEngine] instance to use to make requests. NOTE: This engine's resources and lifetime
* are NOT managed by the provider. Caller is responsible for closing.
* @param region the region to make credentials requests to.
* @return the newly-constructed credentials provider
*/
public class DefaultChainCredentialsProvider constructor(
private val profileName: String? = null,
private val platformProvider: PlatformProvider = Platform,
httpClientEngine: HttpClientEngine? = null,
region: String? = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: Needs documentation

) : CredentialsProvider, Closeable {

private val manageEngine = httpClientEngine == null
private val httpClientEngine = httpClientEngine ?: DefaultHttpEngine()

private val chain = CredentialsProviderChain(
EnvironmentCredentialsProvider(platformProvider::getenv),
ProfileCredentialsProvider(profileName = profileName, platformProvider = platformProvider, httpClientEngine = httpClientEngine),
ProfileCredentialsProvider(profileName = profileName, platformProvider = platformProvider, httpClientEngine = httpClientEngine, region = region),
// STS web identity provider can be constructed from either the profile OR 100% from the environment
StsWebIdentityProvider(platformProvider = platformProvider, httpClientEngine = httpClientEngine),
EcsCredentialsProvider(platformProvider, httpClientEngine),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AwsServiceConfigIntegration : KotlinIntegration {
AWS region to make requests to
""".trimIndent()
propertyType = ClientConfigPropertyType.Required()
order = -100
}

val CredentialsProviderProp: ClientConfigProperty = ClientConfigProperty {
Expand All @@ -38,7 +39,7 @@ class AwsServiceConfigIntegration : KotlinIntegration {

propertyType = ClientConfigPropertyType.Custom(render = { prop, writer ->
writer.write(
"public val #1L: #2T = builder.#1L?.borrow() ?: #3T()",
"public val #1L: #2T = builder.#1L?.borrow() ?: #3T(httpClientEngine = httpClientEngine, region = region)",
prop.propertyName,
prop.symbol,
AwsRuntimeTypes.Config.Credentials.DefaultChainCredentialsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ class AwsServiceConfigIntegrationTest {
val contents = writer.toString()

val expectedProps = """
public val credentialsProvider: CredentialsProvider = builder.credentialsProvider?.borrow() ?: DefaultChainCredentialsProvider()
public val endpointResolver: AwsEndpointResolver = builder.endpointResolver ?: DefaultEndpointResolver()
public val region: String = requireNotNull(builder.region) { "region is a required configuration property" }
public val credentialsProvider: CredentialsProvider = builder.credentialsProvider?.borrow() ?: DefaultChainCredentialsProvider(httpClientEngine = httpClientEngine, region = region)
public val endpointResolver: AwsEndpointResolver = builder.endpointResolver ?: DefaultEndpointResolver()
"""
contents.shouldContainOnlyOnceWithDiff(expectedProps)

val expectedImpl = """
/**
* AWS region to make requests to
*/
public var region: String? = null
/**
* The AWS credentials provider to use for authenticating requests. If not provided a
* [aws.sdk.kotlin.runtime.auth.credentials.DefaultChainCredentialsProvider] instance will be used.
Expand All @@ -62,10 +66,6 @@ class AwsServiceConfigIntegrationTest {
* resolver is configured automatically. This is an advanced client option.
*/
public var endpointResolver: AwsEndpointResolver? = null
/**
* AWS region to make requests to
*/
public var region: String? = null
"""
contents.shouldContainOnlyOnceWithDiff(expectedImpl)
}
Expand Down