Skip to content

Commit e294319

Browse files
authored
Merge branch 'v1.5-main' into v1.5-merge
2 parents 42de9e1 + 78cd84a commit e294319

32 files changed

+400
-172
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "05ac561b-963f-4953-bb4f-1fc19fc1207c",
3+
"type": "feature",
4+
"description": "Add `regionProvider` property to client config",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1478"
7+
]
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "49af01b8-6fed-4add-ace0-9f027e83425a",
3+
"type": "feature",
4+
"description": "⚠️ **IMPORTANT**: Refactor endpoint discoverer classes into interfaces so custom implementations may be provided",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1413"
7+
],
8+
"requiresMinorVersionBump": true
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "929f0e2a-3af9-4f73-9f1b-b4e97f91f0db",
3+
"type": "feature",
4+
"description": "⚠️ **IMPORTANT**: Add support for enabling/disabling endpoint discovery via [standard cross-SDK config mechanisms](https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoint-discovery.html)",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1413"
7+
],
8+
"requiresMinorVersionBump": true
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "e6515649-dab5-4be9-b4b4-b289369960d5",
3+
"type": "bugfix",
4+
"description": "Favor `endpointUrl` instead of endpoint discovery if both are provided",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1413"
7+
]
8+
}

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,27 @@ public abstract class aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory
244244
public static synthetic fun fromEnvironment$default (Laws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
245245
}
246246

247+
public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig : aws/smithy/kotlin/runtime/client/SdkClientConfig {
248+
public abstract fun getApplicationId ()Ljava/lang/String;
249+
public abstract fun getRegion ()Ljava/lang/String;
250+
public abstract fun getRegionProvider ()Laws/smithy/kotlin/runtime/client/region/RegionProvider;
251+
public abstract fun getUseDualStack ()Z
252+
public abstract fun getUseFips ()Z
253+
}
254+
255+
public abstract interface class aws/sdk/kotlin/runtime/config/AwsSdkClientConfig$Builder {
256+
public abstract fun getApplicationId ()Ljava/lang/String;
257+
public abstract fun getRegion ()Ljava/lang/String;
258+
public abstract fun getRegionProvider ()Laws/smithy/kotlin/runtime/client/region/RegionProvider;
259+
public abstract fun getUseDualStack ()Ljava/lang/Boolean;
260+
public abstract fun getUseFips ()Ljava/lang/Boolean;
261+
public abstract fun setApplicationId (Ljava/lang/String;)V
262+
public abstract fun setRegion (Ljava/lang/String;)V
263+
public abstract fun setRegionProvider (Laws/smithy/kotlin/runtime/client/region/RegionProvider;)V
264+
public abstract fun setUseDualStack (Ljava/lang/Boolean;)V
265+
public abstract fun setUseFips (Ljava/lang/Boolean;)V
266+
}
267+
247268
public final class aws/sdk/kotlin/runtime/config/AwsSdkSetting {
248269
public static final field INSTANCE Laws/sdk/kotlin/runtime/config/AwsSdkSetting;
249270
public final fun getAwsAccessKeyId ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
@@ -259,6 +280,7 @@ public final class aws/sdk/kotlin/runtime/config/AwsSdkSetting {
259280
public final fun getAwsEc2MetadataDisabled ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
260281
public final fun getAwsEc2MetadataServiceEndpoint ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
261282
public final fun getAwsEc2MetadataServiceEndpointMode ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
283+
public final fun getAwsEndpointDiscoveryEnabled ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
262284
public final fun getAwsEndpointUrl ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
263285
public final fun getAwsExecutionEnv ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
264286
public final fun getAwsIgnoreEndpointUrls ()Laws/smithy/kotlin/runtime/config/EnvironmentSetting;
@@ -315,6 +337,8 @@ public final class aws/sdk/kotlin/runtime/config/endpoints/ResolversKt {
315337
public static final fun resolveAccountId (Laws/sdk/kotlin/runtime/config/endpoints/AccountIdEndpointMode;Laws/smithy/kotlin/runtime/collections/Attributes;)Ljava/lang/String;
316338
public static final fun resolveAccountIdEndpointMode (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
317339
public static synthetic fun resolveAccountIdEndpointMode$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
340+
public static final fun resolveEndpointDiscoveryEnabled (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
341+
public static synthetic fun resolveEndpointDiscoveryEnabled$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
318342
public static final fun resolveEndpointUrl (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
319343
public static synthetic fun resolveEndpointUrl$default (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
320344
public static final fun resolveUseDualStack (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -494,6 +518,7 @@ public final class aws/sdk/kotlin/runtime/config/profile/AwsProfileKt {
494518
public static synthetic fun getBooleanOrNull$default (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/Boolean;
495519
public static final fun getCredentialProcess (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;)Ljava/lang/String;
496520
public static final fun getDisableRequestCompression (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;)Ljava/lang/Boolean;
521+
public static final fun getEndpointDiscoveryEnabled (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;)Ljava/lang/Boolean;
497522
public static final fun getEndpointUrl (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;)Laws/smithy/kotlin/runtime/net/url/Url;
498523
public static final fun getIgnoreEndpointUrls (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;)Ljava/lang/Boolean;
499524
public static final fun getIntOrNull (Laws/sdk/kotlin/runtime/config/profile/ConfigSection;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Integer;
@@ -549,55 +574,43 @@ public final class aws/sdk/kotlin/runtime/config/useragent/ResolveUserAgentKt {
549574
public static synthetic fun resolveUserAgentAppId$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
550575
}
551576

552-
public final class aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProviderChain, aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable {
577+
public final class aws/sdk/kotlin/runtime/region/DefaultRegionProviderChain : aws/smithy/kotlin/runtime/client/region/RegionProviderChain, aws/smithy/kotlin/runtime/client/region/RegionProvider, java/io/Closeable {
553578
public fun <init> ()V
554579
public fun <init> (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V
555580
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/PlatformProvider;Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
556581
public fun close ()V
557582
}
558583

559-
public final class aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
584+
public final class aws/sdk/kotlin/runtime/region/EnvironmentRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider {
560585
public fun <init> ()V
561586
public fun <init> (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;)V
562587
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/EnvironmentProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
563588
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
564589
}
565590

566-
public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider, java/io/Closeable {
591+
public final class aws/sdk/kotlin/runtime/region/ImdsRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider, java/io/Closeable {
567592
public fun <init> ()V
568593
public fun <init> (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;)V
569594
public synthetic fun <init> (Lkotlin/Lazy;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
570595
public fun close ()V
571596
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
572597
}
573598

574-
public final class aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
599+
public final class aws/sdk/kotlin/runtime/region/JvmSystemPropRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider {
575600
public fun <init> ()V
576601
public fun <init> (Laws/smithy/kotlin/runtime/util/PropertyProvider;)V
577602
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/PropertyProvider;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
578603
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
579604
}
580605

581-
public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/sdk/kotlin/runtime/region/RegionProvider {
606+
public final class aws/sdk/kotlin/runtime/region/ProfileRegionProvider : aws/smithy/kotlin/runtime/client/region/RegionProvider {
582607
public fun <init> ()V
583608
public fun <init> (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;)V
584609
public synthetic fun <init> (Laws/smithy/kotlin/runtime/util/LazyAsyncValue;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
585610
public fun <init> (Ljava/lang/String;)V
586611
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
587612
}
588613

589-
public abstract interface class aws/sdk/kotlin/runtime/region/RegionProvider {
590-
public abstract fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
591-
}
592-
593-
public class aws/sdk/kotlin/runtime/region/RegionProviderChain : aws/sdk/kotlin/runtime/region/RegionProvider {
594-
public fun <init> (Ljava/util/List;)V
595-
public fun <init> ([Laws/sdk/kotlin/runtime/region/RegionProvider;)V
596-
protected final fun getProviders ()[Laws/sdk/kotlin/runtime/region/RegionProvider;
597-
public fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
598-
public fun toString ()Ljava/lang/String;
599-
}
600-
601614
public final class aws/sdk/kotlin/runtime/region/ResolveRegionKt {
602615
public static final fun resolveRegion (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
603616
public static synthetic fun resolveRegion$default (Laws/smithy/kotlin/runtime/util/PlatformProvider;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
package aws.sdk.kotlin.runtime.config
77

8-
import aws.sdk.kotlin.runtime.client.AwsSdkClientConfig
98
import aws.sdk.kotlin.runtime.config.checksums.resolveRequestChecksumCalculation
109
import aws.sdk.kotlin.runtime.config.checksums.resolveResponseChecksumValidation
1110
import aws.sdk.kotlin.runtime.config.compression.resolveDisableRequestCompression
@@ -77,7 +76,7 @@ public abstract class AbstractAwsSdkClientFactory<
7776
block?.let(config::apply)
7877

7978
config.logMode = config.logMode ?: ClientSettings.LogMode.resolve(platform = platform)
80-
config.region = config.region ?: resolveRegion(profile = profile)
79+
config.region = config.region ?: config.regionProvider?.getRegion() ?: resolveRegion(profile = profile)
8180
config.useFips = config.useFips ?: resolveUseFips(profile = profile)
8281
config.useDualStack = config.useDualStack ?: resolveUseDualStack(profile = profile)
8382
config.applicationId = config.applicationId ?: resolveUserAgentAppId(platform, profile)

aws-runtime/aws-core/common/src/aws/sdk/kotlin/runtime/client/AwsSdkClientConfig.kt renamed to aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AwsSdkClientConfig.kt

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package aws.sdk.kotlin.runtime.client
6+
package aws.sdk.kotlin.runtime.config
77

88
import aws.smithy.kotlin.runtime.client.SdkClientConfig
9+
import aws.smithy.kotlin.runtime.client.region.RegionProvider
910

1011
/**
1112
* Base interface all generated AWS SDK Kotlin clients implement
@@ -14,11 +15,27 @@ public interface AwsSdkClientConfig : SdkClientConfig {
1415

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

28+
/**
29+
* An optional region provider that determines the AWS region for client operations. When specified, this provider
30+
* takes precedence over the default region provider chain, unless a static region is explicitly configured.
31+
*
32+
* The region resolution order is:
33+
* 1. Static region (if specified)
34+
* 2. Custom region provider (if configured)
35+
* 3. Default region provider chain
36+
*/
37+
public val regionProvider: RegionProvider
38+
2239
/**
2340
* Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests.
2441
* Disabled by default.
@@ -49,11 +66,27 @@ public interface AwsSdkClientConfig : SdkClientConfig {
4966
public interface Builder {
5067
/**
5168
* The AWS region (e.g. `us-west-2`) to make requests to. See about AWS
52-
* [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more
53-
* information
69+
* [global infrastructure](https://aws.amazon.com/about-aws/global-infrastructure/regions_az/) for more information.
70+
* When specified, this static region configuration takes precedence over other region resolution methods.
71+
*
72+
* The region resolution order is:
73+
* 1. Static region (if specified)
74+
* 2. Custom region provider (if configured)
75+
* 3. Default region provider chain
5476
*/
5577
public var region: String?
5678

79+
/**
80+
* An optional region provider that determines the AWS region for client operations. When specified, this provider
81+
* takes precedence over the default region provider chain, unless a static region is explicitly configured.
82+
*
83+
* The region resolution order is:
84+
* 1. Static region (if specified)
85+
* 2. Custom region provider (if configured)
86+
* 3. Default region provider chain
87+
*/
88+
public var regionProvider: RegionProvider?
89+
5790
/**
5891
* Flag to toggle whether to use [FIPS](https://aws.amazon.com/compliance/fips/) endpoints when making requests.
5992
* Disabled by default.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ public object AwsSdkSetting {
211211
public val AwsSigV4aSigningRegionSet: EnvironmentSetting<String> =
212212
strEnvSetting("aws.sigV4aSigningRegionSet", "AWS_SIGV4A_SIGNING_REGION_SET")
213213

214+
/**
215+
* A flag indicating whether endpoint discovery is enabled for AWS services that support it. The implicit default
216+
* value for this setting is:
217+
* * `true` for services which _require_ EP discovery (e.g., Timestream)
218+
* * `false` for services which _allow but do not require_ EP discovery (e.g., DynamoDB)
219+
*/
220+
public val AwsEndpointDiscoveryEnabled: EnvironmentSetting<Boolean> =
221+
boolEnvSetting("aws.endpointDiscoveryEnabled", "AWS_ENABLE_ENDPOINT_DISCOVERY")
222+
214223
/**
215224
* Configures request checksum calculation
216225
*/

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/endpoints/Resolvers.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,16 @@ public fun resolveAccountId(endpointMode: AccountIdEndpointMode, attributes: Att
101101
AccountIdEndpointMode.DISABLED -> null
102102
AccountIdEndpointMode.REQUIRED -> attributes.getOrNull(AwsClientOption.AccountId) ?: throw ConfigurationException("AccountIdEndpointMode is set to required but no AWS account ID found")
103103
}
104+
105+
/**
106+
* Resolve the endpoint discovery mode
107+
*/
108+
@InternalSdkApi
109+
public suspend fun resolveEndpointDiscoveryEnabled(
110+
provider: PlatformProvider = PlatformProvider.System,
111+
profile: LazyAsyncValue<AwsProfile> = asyncLazy { loadAwsSharedConfig(provider).activeProfile },
112+
serviceRequiresEpDiscovery: Boolean,
113+
): Boolean =
114+
AwsSdkSetting.AwsEndpointDiscoveryEnabled.resolve(provider)
115+
?: profile.get().endpointDiscoveryEnabled
116+
?: serviceRequiresEpDiscovery

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ public val AwsProfile.requestMinCompressionSizeBytes: Long?
155155
public val AwsProfile.sigV4aSigningRegionSet: String?
156156
get() = getOrNull("sigv4a_signing_region_set")
157157

158+
/**
159+
* A flag indicating whether endpoint discovery should be enabled for a service that supports it. This setting has no
160+
* effect for services which _do not_ support endpoint discovery.
161+
*/
162+
@InternalSdkApi
163+
public val AwsProfile.endpointDiscoveryEnabled: Boolean?
164+
get() = getBooleanOrNull("endpoint_discovery_enabled")
165+
158166
/**
159167
* Configures request checksum calculation
160168
*/

0 commit comments

Comments
 (0)