Skip to content

Commit 8b0e850

Browse files
committed
address pr reviews
1 parent 7ce5703 commit 8b0e850

File tree

5 files changed

+49
-17
lines changed

5 files changed

+49
-17
lines changed

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,26 @@ import aws.smithy.kotlin.runtime.client.region.RegionProvider
1414
public interface AwsSdkClientConfig : SdkClientConfig {
1515

1616
/**
17-
* The AWS region (e.g. `us-west-2`) to make requests to. See about AWS
18-
* [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more
19-
* information
17+
* The AWS region to sign with and make requests to. When specified, this static region configuration
18+
* takes precedence over other region resolution methods.
19+
*
20+
* The region resolution order is:
21+
* 1. Static region (if specified)
22+
* 2. Custom region provider (if configured)
23+
* 3. Default region provider chain
2024
*/
2125
public val region: String?
2226

2327
/**
2428
* An optional region provider that determines the AWS region for client operations. When specified, this provider
2529
* takes precedence over the default region provider chain, unless a static region is explicitly configured.
2630
*
27-
* Region Resolution Priority:
31+
* The region resolution order is:
2832
* 1. Static region (if specified)
2933
* 2. Custom region provider (if configured)
3034
* 3. Default region provider chain
3135
*/
32-
public val regionProvider: RegionProvider?
36+
public val regionProvider: RegionProvider
3337

3438
/**
3539
* Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests.
@@ -60,9 +64,13 @@ public interface AwsSdkClientConfig : SdkClientConfig {
6064

6165
public interface Builder {
6266
/**
63-
* The AWS region (e.g. `us-west-2`) to make requests to. See about AWS
64-
* [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more
65-
* information
67+
* The AWS region to sign with and make requests to. When specified, this static region configuration
68+
* takes precedence over other region resolution methods.
69+
*
70+
* Region Resolution Priority:
71+
* 1. Static region (if specified)
72+
* 2. Custom region provider (if configured)
73+
* 3. Default region provider chain
6674
*/
6775
public var region: String?
6876

aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactoryTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package aws.sdk.kotlin.runtime.config
88
import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig
99
import aws.sdk.kotlin.runtime.config.useragent.resolveUserAgentAppId
1010
import aws.sdk.kotlin.runtime.config.utils.mockPlatform
11+
import aws.sdk.kotlin.runtime.region.DefaultRegionProviderChain
1112
import aws.smithy.kotlin.runtime.client.*
1213
import aws.smithy.kotlin.runtime.client.region.RegionProvider
1314
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy
@@ -129,7 +130,7 @@ private interface TestClient : SdkClient {
129130
override val clientName: String = builder.clientName
130131
override val logMode: LogMode = builder.logMode ?: LogMode.Default
131132
override val region: String? = builder.region
132-
override var regionProvider: RegionProvider? = builder.regionProvider
133+
override var regionProvider: RegionProvider = builder.regionProvider ?: DefaultRegionProviderChain()
133134
override var useFips: Boolean = builder.useFips ?: false
134135
override var useDualStack: Boolean = builder.useDualStack ?: false
135136
override val applicationId: String? = builder.applicationId

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsRuntimeTypes.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ object AwsRuntimeTypes {
5454
}
5555

5656
object Region : RuntimeTypePackage(AwsKotlinDependency.AWS_CONFIG, "region") {
57+
val DefaultRegionProviderChain = symbol("DefaultRegionProviderChain")
5758
val resolveRegion = symbol("resolveRegion")
5859
}
5960
}

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ class AwsServiceConfigIntegration : KotlinIntegration {
2727
baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig
2828
useNestedBuilderBaseClass()
2929
documentation = """
30-
The AWS region (e.g. `us-west-2`) to make requests to. See about AWS
31-
[global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more
32-
information
30+
The region to sign with and make requests to.
31+
The AWS region to sign with and make requests to. When specified, this static region configuration
32+
takes precedence over other region resolution methods.
33+
34+
The region resolution order is:
35+
1. Static region (if specified)
36+
2. Custom region provider (if configured)
37+
3. Default region provider chain
3338
""".trimIndent()
3439

3540
propertyType = ConfigPropertyType.Custom(
@@ -49,18 +54,29 @@ class AwsServiceConfigIntegration : KotlinIntegration {
4954

5055
val RegionProviderProp: ConfigProperty = ConfigProperty {
5156
name = "regionProvider"
52-
symbol = RuntimeTypes.SmithyClient.Region.RegionProvider.asNullable()
57+
symbol = RuntimeTypes.SmithyClient.Region.RegionProvider
5358
baseClass = AwsRuntimeTypes.Config.AwsSdkClientConfig
5459
useNestedBuilderBaseClass()
5560
documentation = """
5661
An optional region provider that determines the AWS region for client operations. When specified, this provider
5762
takes precedence over the default region provider chain, unless a static region is explicitly configured.
63+
5864
The region resolution order is:
5965
1. Static region (if specified)
6066
2. Custom region provider (if configured)
6167
3. Default region provider chain
6268
""".trimIndent()
6369

70+
propertyType = ConfigPropertyType.Custom(
71+
render = { prop, writer ->
72+
writer.write(
73+
"override val #1L: #2T = builder.#1L ?: #3T()",
74+
prop.propertyName,
75+
prop.symbol,
76+
AwsRuntimeTypes.Config.Region.DefaultRegionProviderChain
77+
)
78+
},
79+
)
6480
order = -100
6581
}
6682

codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegrationTest.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,28 @@ class AwsServiceConfigIntegrationTest {
4646

4747
val expectedProps = """
4848
override val region: String? = builder.region ?: runBlocking { builder.regionProvider?.getRegion() ?: resolveRegion() }
49-
override val regionProvider: RegionProvider? = builder.regionProvider
49+
override val regionProvider: RegionProvider = builder.regionProvider ?: DefaultRegionProviderChain()
5050
override val credentialsProvider: CredentialsProvider = builder.credentialsProvider ?: DefaultChainCredentialsProvider(httpClient = httpClient, region = region).manage()
5151
"""
5252
contents.shouldContainOnlyOnceWithDiff(expectedProps)
5353

5454
val expectedImpl = """
5555
/**
56-
* The AWS region (e.g. `us-west-2`) to make requests to. See about AWS
57-
* [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more
58-
* information
56+
* The region to sign with and make requests to.
57+
* The AWS region to sign with and make requests to. When specified, this static region configuration
58+
* takes precedence over other region resolution methods.
59+
*
60+
* The region resolution order is:
61+
* 1. Static region (if specified)
62+
* 2. Custom region provider (if configured)
63+
* 3. Default region provider chain
5964
*/
6065
override var region: String? = null
6166
6267
/**
6368
* An optional region provider that determines the AWS region for client operations. When specified, this provider
6469
* takes precedence over the default region provider chain, unless a static region is explicitly configured.
70+
*
6571
* The region resolution order is:
6672
* 1. Static region (if specified)
6773
* 2. Custom region provider (if configured)

0 commit comments

Comments
 (0)