Skip to content

Provide client config property for region provider #1478

@ianbotsf

Description

@ianbotsf

Describe the feature

Currently, SDK client config has a region property which is a non-defered static string. Internally, the SDK uses RegionProvider and DefaultRegionProviderChain to lazily infer the region when one is not explicitly provided by the caller. This complicates dynamic region selection for callers who use their own configuration lookup mechanisms or want to use custom provider chains.

Is your feature request related to a problem?

The lack of a regionProvider property complicates dynamic region selection for callers who use their own configuration lookup mechanisms or want to use custom provider chains. Users must manage their own chain independently and then call getRegion() to pass to the client's region property:

val myRegionProvider = RegionProviderChain(src1, src2, src3, ...)

val s3 = S3Client.fromEnvironment {
    region = myRegionProvider.getRegion()
}

Proposed Solution

Expose a regionProvider client config property alongside region. When set, it should replace the default region provider chain used when a static region is not specified:

val myRegionProvider = RegionProviderChain(src1, src2, src3, ...)

val s3 = S3Client.fromEnvironment {
    regionProvider = myRegionProvider 
}

If a static region is specified, the value of regionProvider will not be used:

val myRegionProvider = ...

val s3 = S3Client.fromEnvironment {
    regionProvider = myRegionProvider // Ignored since `region` is also set
    region = "moon-east-1"
}

Describe alternative solutions or features you've considered

The existing region property presently allows using providers indirectly but it's not very ergonomic and differs from how credentials are resolved.

Acknowledge

  • I may be able to implement this feature request

AWS SDK for Kotlin version

1.3.93

Platform (JVM/JS/Native)

(any)

Operating system and version

(any)

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions