Skip to content

Commit 5f87bfc

Browse files
authored
docs: document how to configure a custom endpoint resolver (#392)
1 parent 2734b59 commit 5f87bfc

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

docs/howto/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# AWS SDK for Kotlin Guide
2+
3+
This documentation supplements the official [AWS SDK for Kotlin Developer Guide](https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/home.html).
4+
5+
6+
## Configuration
7+
8+
* [Endpoints](./configuring/endpoints.md) - How to configure a custom endpoint resolver
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Configuring Client Endpoints
2+
3+
The AWS SDK for Kotlin provides the ability to provide a custom endpoint to be used for a service. In most cases
4+
you can just use the default `EndpointResolver` provided with each service client. There are some reasons to provide
5+
a custom endpoint though such as working with a pre-release version of a service or access to specific service
6+
features not yet modeled in the SDK (e.g. S3 has dual-stack and FIPS endpoints).
7+
8+
9+
An [Endpoint Resolver](https://github.com/awslabs/aws-sdk-kotlin/blob/main/aws-runtime/aws-endpoint/common/src/aws/sdk/kotlin/runtime/endpoint/AwsEndpointResolver.kt#L11)
10+
can be configured to provide custom endpoint resolution logic for service clients. Every
11+
service client config is generated with an endpoint resolver that can be overridden. The endpoint resolver is given the
12+
service and region as a string, allowing for the resolver to dynamically drive its behavior. Each service client
13+
package has an exported `ServiceId` constant that can be used to determine which service is invoking your endpoint
14+
resolver.
15+
16+
## Examples
17+
18+
The following code snippet shows how a service endpoint resolver can be overridden for S3:
19+
20+
```kotlin
21+
val sharedConfig = AwsClientConfig.fromEnvironment()
22+
val client = S3Client(sharedConfig) {
23+
endpointResolver = AwsEndpointResolver { service, region ->
24+
AwsEndpoint("https://mybucket.s3.us-west-2.amazonaws.com", CredentialScope(region = "us-west-2"))
25+
}
26+
}
27+
```

0 commit comments

Comments
 (0)