Skip to content

Commit 0bb3ee7

Browse files
aajtoddaws-sdk-rust-ci
authored andcommitted
[smithy-rs] fix default credential chain not respecting endpoint URL overrides (#3873)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> #1193 ## Description This PR fixes a customer reported bug where the default chain doesn't respect `AWS_ENDPOINT_URL`/`AWS_ENDPOINT_URL_<SERVICE>` environment variables or the equivalents in AWS shared config (`~/.aws/config`). This fix is a little nuanced and frankly gross but there isn't a better option that I can see right now that isn't way more invasive. The crux of the issue is that when we implemented support for this feature ([1](smithy-lang/smithy-rs#3568), [2](smithy-lang/smithy-rs#3493), [3](smithy-lang/smithy-rs#3488)) we really only made it work for clients created via [`ConfigLoader::load()`](https://github.com/smithy-lang/smithy-rs/blob/release-2024-10-09/aws/rust-runtime/aws-config/src/lib.rs#L871). Internally the default chain credential provider constructs `STS` and `SSO` clients but it does so using [`ProviderConfig`](https://github.com/smithy-lang/smithy-rs/blob/release-2024-10-09/aws/rust-runtime/aws-config/src/provider_config.rs#L36) by mapping this to `SdkConfig` via [`ProviderConfig::client_config()`](https://github.com/smithy-lang/smithy-rs/blob/release-2024-10-09/aws/rust-runtime/aws-config/src/provider_config.rs#L199). This conversion is used in several places and it doesn't take any of the required logic into account to setup [`EnvServiceConfig`](https://github.com/smithy-lang/smithy-rs/blob/release-2024-10-09/aws/rust-runtime/aws-config/src/lib.rs#L859-L862) which is what generated SDK's ultimately use to figure out the endpoint URL from either environment/profile ([example client](https://github.com/awslabs/aws-sdk-rust/blob/release-2024-10-09/sdk/sts/src/config.rs#L1214-L1221) which ultimately ends up in `EnvServiceConfig` [here](https://github.com/smithy-lang/smithy-rs/blob/release-2024-10-09/aws/rust-runtime/aws-config/src/env_service_config.rs#L18)). The fix applied here is nuanced in that we update the conversion to provide a `EnvServiceConfig` but it relies on the profile to have been parsed already or else you'll get an empty/default profile. This generally works for the profile provider since the first thing we do is load the profile but in isolation it may not work as expected. I've added tests for STS to cover all cases but SSO credentials and token providers do NOT currently respect shared config endpoint URL keys. Fixing this is possible but involved since we require an `async` context to ensure a profile is loaded already and in many places where we construct `SdkConfig` from `ProviderConfig` we are in non async function. ## Testing Tested repro + additional integration tests ## Future This does _not_ fix #1194 which was discovered as a bug/gap. Fixing it would be outside the scope of this PR. SSO/token provider is instantiated sometimes before we have parsed a profile. This PR definitely fixes the STS provider for all configuration scenarios but the SSO related client usage may still have some edge cases when configured via profiles since we often instantiate them before parsing a profile. When we surveyed other SDKs there were several that failed to respect these variables and haven't received issues around this which leads me to believe this isn't likely a problem in practice (most likely due to SSO being used in local development most often where redirecting that endpoint doesn't make much sense anyway). ## Checklist - [X] For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the `.changelog` directory, specifying "aws-sdk-rust" in the `applies_to` key. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent af8fb9e commit 0bb3ee7

File tree

484 files changed

+1532
-846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

484 files changed

+1532
-846
lines changed

README.md

Lines changed: 1 addition & 1 deletion

examples/cross_service/detect_faces/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
publish = false
77

88
[dependencies]
9-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config" }
9+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config" }
1010
aws-sdk-rekognition= { version = "1.50.0", path = "../../../sdk/rekognition" }
1111
aws-sdk-s3= { version = "1.58.0", path = "../../../sdk/s3" }
1212
aws-smithy-types= { version = "1.2.8", path = "../../../sdk/aws-smithy-types", features = ["rt-tokio"] }

examples/cross_service/detect_labels/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77

88
[dependencies]
99
kamadak-exif = "0.5.4"
10-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config" }
10+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config" }
1111
aws-sdk-dynamodb= { version = "1.51.0", path = "../../../sdk/dynamodb" }
1212
aws-sdk-rekognition= { version = "1.50.0", path = "../../../sdk/rekognition" }
1313
aws-sdk-s3= { version = "1.58.0", path = "../../../sdk/s3" }

examples/cross_service/photo_asset_management/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ streaming-zip = "0.5.0"
3030
tempfile = "3.5.0"
3131
tokio-stream = "0.1.12"
3232
tracing = "0.1.37"
33-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config" }
33+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config" }
3434
aws-sdk-dynamodb= { version = "1.51.0", path = "../../../sdk/dynamodb" }
3535
aws-sdk-rekognition= { version = "1.50.0", path = "../../../sdk/rekognition" }
3636
aws-sdk-s3= { version = "1.58.0", path = "../../../sdk/s3" }

examples/cross_service/photo_asset_management/integration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ publish = false
99

1010
[dependencies]
1111
tracing = "0.1.37"
12-
aws-config= { version = "1.5.8", path = "../../../../sdk/aws-config" }
12+
aws-config= { version = "1.5.9", path = "../../../../sdk/aws-config" }
1313
aws-sdk-dynamodb= { version = "1.51.0", path = "../../../../sdk/dynamodb" }
1414
aws-sdk-rekognition= { version = "1.50.0", path = "../../../../sdk/rekognition" }
1515

examples/cross_service/rest_ses/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tracing-actix-web = "0.7.3"
2929
tracing-bunyan-formatter = "0.3.4"
3030
tracing-log = "0.1.3"
3131
xlsxwriter = "0.6.0"
32-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config" }
32+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config" }
3333
aws-sdk-cloudwatchlogs= { version = "1.53.0", path = "../../../sdk/cloudwatchlogs" }
3434
aws-sdk-rdsdata= { version = "1.47.0", path = "../../../sdk/rdsdata" }
3535
aws-sdk-ses= { version = "1.49.0", path = "../../../sdk/ses" }

examples/cross_service/telephone/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ anyhow = "1"
1111
bytes = "1"
1212
reqwest = "0.11.4"
1313
serde_json = "1.0"
14-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config" }
14+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config" }
1515
aws-sdk-polly= { version = "1.49.0", path = "../../../sdk/polly" }
1616
aws-sdk-s3= { version = "1.58.0", path = "../../../sdk/s3" }
1717
aws-sdk-transcribe= { version = "1.48.0", path = "../../../sdk/transcribe" }

examples/examples/apigateway/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ publish = false
77

88
[dependencies]
99
thiserror = "1.0"
10-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
10+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
1111
aws-sdk-apigateway= { version = "1.48.0", path = "../../../sdk/apigateway" }
1212
aws-smithy-types-convert= { version = "0.60.8", path = "../../../sdk/aws-smithy-types-convert", features = ["convert-chrono"] }
1313

examples/examples/apigatewaymanagement/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88

99
[dependencies]
1010
http = "0.2.5"
11-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
11+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
1212
aws-sdk-apigatewaymanagement= { version = "1.47.0", path = "../../../sdk/apigatewaymanagement" }
1313

1414
[dependencies.tokio]

examples/examples/applicationautoscaling/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
publish = false
88

99
[dependencies]
10-
aws-config= { version = "1.5.8", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
10+
aws-config= { version = "1.5.9", path = "../../../sdk/aws-config", features = ["behavior-version-latest"] }
1111
aws-sdk-applicationautoscaling= { version = "1.51.0", path = "../../../sdk/applicationautoscaling" }
1212

1313
[dependencies.tokio]

0 commit comments

Comments
 (0)