Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the orchestrator client for ECS and IMDS credentials in aws-config #2997

Merged
merged 13 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,15 @@ message = "The `futures_core::stream::Stream` trait has been removed from [`Byte
references = ["smithy-rs#2983"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "ysaito1001"

[[smithy-rs]]
message = "`StaticUriEndpointResolver`'s `uri` constructor now takes a `String` instead of a `Uri`."
references = ["smithy-rs#2997"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "jdisanti"

[[aws-sdk-rust]]
message = "The IMDS Client builder's `build()` method is no longer async."
references = ["smithy-rs#2997"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
author = "jdisanti"
6 changes: 5 additions & 1 deletion aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
repository = "https://github.com/awslabs/smithy-rs"

[features]
client-hyper = ["aws-smithy-client/client-hyper"]
client-hyper = ["aws-smithy-client/client-hyper", "aws-smithy-runtime/connector-hyper"]
jdisanti marked this conversation as resolved.
Show resolved Hide resolved
rustls = ["aws-smithy-client/rustls", "client-hyper"]
native-tls = []
allow-compilation = [] # our tests use `cargo test --all-features` and native-tls breaks CI
Expand All @@ -27,7 +27,10 @@ aws-smithy-client = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-client", de
aws-smithy-http = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http" }
jdisanti marked this conversation as resolved.
Show resolved Hide resolved
aws-smithy-http-tower = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-http-tower" }
aws-smithy-json = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-json" }
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client"] }
aws-smithy-runtime-api = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-types = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-types" }
aws-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-runtime" }
aws-types = { path = "../../sdk/build/aws-sdk/sdk/aws-types" }
hyper = { version = "0.14.26", default-features = false }
time = { version = "0.3.4", features = ["parsing"] }
Expand All @@ -48,6 +51,7 @@ hex = { version = "0.4.3", optional = true }
zeroize = { version = "1", optional = true }

[dev-dependencies]
aws-smithy-runtime = { path = "../../sdk/build/aws-sdk/sdk/aws-smithy-runtime", features = ["client", "test-util"] }
futures-util = { version = "0.3.16", default-features = false }
tracing-test = "0.2.1"
tracing-subscriber = { version = "0.3.16", features = ["fmt", "json"] }
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-config/examples/imds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
async fn main() -> Result<(), Box<dyn std::error::Error>> {
use aws_config::imds::Client;

let imds = Client::builder().build().await?;
let imds = Client::builder().build();
let instance_id = imds.get("/latest/meta-data/instance-id").await?;
println!("current instance id: {}", instance_id);
println!("current instance id: {}", instance_id.as_ref());
Ok(())
}
13 changes: 11 additions & 2 deletions aws/rust-runtime/aws-config/src/ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use aws_credential_types::provider::{self, error::CredentialsError, future, Prov
use aws_smithy_client::erase::boxclone::BoxCloneService;
use aws_smithy_http::endpoint::apply_endpoint;
use aws_smithy_types::error::display::DisplayErrorContext;
use http::uri::{InvalidUri, Scheme};
use http::uri::{InvalidUri, PathAndQuery, Scheme};
use http::{HeaderValue, Uri};
use tower::{Service, ServiceExt};

Expand Down Expand Up @@ -166,6 +166,15 @@ impl Provider {
Err(EcsConfigurationError::NotConfigured) => return Provider::NotConfigured,
Err(err) => return Provider::InvalidConfiguration(err),
};
let path = uri.path().to_string();
let endpoint = {
let mut parts = uri.into_parts();
parts.path_and_query = Some(PathAndQuery::from_static("/"));
Uri::from_parts(parts)
}
.expect("parts will be valid")
.to_string();

let http_provider = HttpCredentialProvider::builder()
.configure(&provider_config)
.connector_settings(
Expand All @@ -174,7 +183,7 @@ impl Provider {
.read_timeout(DEFAULT_READ_TIMEOUT)
.build(),
)
.build("EcsContainer", uri);
.build("EcsContainer", &endpoint, path);
Provider::Configured(http_provider)
}

Expand Down
Loading
Loading