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

Remove deprecated ResolveAwsEndpoint and related interfaces. #2390

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 17 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,20 @@ message = "Fluent builder methods on the client are now marked as deprecated whe
references = ["aws-sdk-rust#740"]
meta = { "breaking" = false, "tada" = true, "bug" = true, "target" = "client"}
author = "Velfi"

[[aws-sdk-rust]]
message = """Remove deprecated `ResolveAwsEndpoint` interfaces.
In general, the path forward is to either:
1. Replace usages with either `endpoint_url` either on [`SdkConfig`](https://docs.rs/aws-types/0.54.1/aws_types/sdk_config/struct.Builder.html#method.endpoint_url), [`ConfigLoader`](https://docs.rs/aws-config/0.54.1/aws_config/struct.ConfigLoader.html#method.endpoint_url) or [`<service>::config::Builder::endpoint_url`](https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/config/struct.Builder.html#method.endpoint_url).
2. Replace usages with a [service-specific resolver override](https://docs.rs/aws-sdk-s3/latest/aws_sdk_s3/config/struct.Builder.html#method.endpoint_resolver).

The following APIs have been removed:
1. [`SdkConfig::endpoint_resolver()`](https://docs.rs/aws-config/0.54.1/aws_config/struct.SdkConfig.html#method.endpoint_resolver): This getter referred a field that has been removed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/referred a field/referred to a field/ ?

2. [`sdk_config::Builder::set_endpoint_resolver(resolver)`](https://docs.rs/aws-types/0.54.1/aws_types/sdk_config/struct.Builder.html#method.set_endpoint_resolver): This setter has been removed.
3. [`ConfigLoader::endpoint_resolver(resolver)](https://docs.rs/aws-config/0.54.1/aws_config/struct.ConfigLoader.html#method.endpoint_resolver): This previously deprecated setter has been removed.
4. Three types have been removed from the [`aws-endpoint`](https://docs.rs/aws-endpoint/0.54.1/aws_endpoint/) crate: `AwsEndpoint`, `CredentialScope`, and `ResolveAwsEndpoint`.
5. The re-export of `Endpoint` has been removed from generated services. Use `endpoint_url` which accepts a string directly instead.
"""
author = "rcoh"
references = ["smithy-rs#2390", "smithy-rs#1784"]
meta = { "breaking" = true, "tada" = false, "bug" = false }
35 changes: 0 additions & 35 deletions aws/rust-runtime/aws-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ mod loader {
use aws_smithy_types::timeout::TimeoutConfig;
use aws_types::app_name::AppName;
use aws_types::docs_for;
use aws_types::endpoint::ResolveAwsEndpoint;
use aws_types::SdkConfig;

use crate::connector::default_connector;
Expand All @@ -181,7 +180,6 @@ mod loader {
app_name: Option<AppName>,
credentials_cache: Option<CredentialsCache>,
credentials_provider: Option<SharedCredentialsProvider>,
endpoint_resolver: Option<Arc<dyn ResolveAwsEndpoint>>,
endpoint_url: Option<String>,
region: Option<Box<dyn ProvideRegion>>,
retry_config: Option<RetryConfig>,
Expand Down Expand Up @@ -345,36 +343,6 @@ mod loader {
self
}

/// Override the endpoint resolver used for **all** AWS Services
///
/// This method is deprecated. Use [`Self::endpoint_url`] instead.
///
/// This method will override the endpoint resolver used for **all** AWS services. This mainly
/// exists to set a static endpoint for tools like `LocalStack`. For live traffic, AWS services
/// require the service-specific endpoint resolver they load by default.
///
/// # Examples
///
/// Use a static endpoint for all services
/// ```no_run
/// # async fn create_config() -> Result<(), aws_smithy_http::endpoint::error::InvalidEndpointError> {
/// use aws_config::endpoint::Endpoint;
///
/// let sdk_config = aws_config::from_env()
/// .endpoint_resolver(Endpoint::immutable("http://localhost:1234")?)
/// .load()
/// .await;
/// # Ok(())
/// # }
#[deprecated(note = "use `.endpoint_url(...)` instead")]
pub fn endpoint_resolver(
mut self,
endpoint_resolver: impl ResolveAwsEndpoint + 'static,
) -> Self {
self.endpoint_resolver = Some(Arc::new(endpoint_resolver));
self
}

/// Provides the ability to programmatically override the profile files that get loaded by the SDK.
///
/// The [`Default`] for `ProfileFiles` includes the default SDK config and credential files located in
Expand Down Expand Up @@ -603,8 +571,6 @@ mod loader {
SharedCredentialsProvider::new(builder.build().await)
};

let endpoint_resolver = self.endpoint_resolver;

let mut builder = SdkConfig::builder()
.region(region)
.retry_config(retry_config)
Expand All @@ -613,7 +579,6 @@ mod loader {
.credentials_provider(credentials_provider)
.http_connector(http_connector);

builder.set_endpoint_resolver(endpoint_resolver);
builder.set_app_name(app_name);
builder.set_sleep_impl(sleep_impl);
builder.set_endpoint_url(self.endpoint_url);
Expand Down
69 changes: 1 addition & 68 deletions aws/rust-runtime/aws-endpoint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,84 +5,17 @@

#![allow(clippy::derive_partial_eq_without_eq)]

use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::sync::Arc;

use aws_smithy_http::endpoint::error::ResolveEndpointError;
use aws_smithy_http::endpoint::ResolveEndpoint;
use aws_smithy_http::middleware::MapRequest;
use aws_smithy_http::operation::Request;
use aws_smithy_types::endpoint::Endpoint as SmithyEndpoint;
use aws_smithy_types::Document;

pub use aws_types::endpoint::{AwsEndpoint, BoxError, CredentialScope, ResolveAwsEndpoint};
use aws_types::region::{Region, SigningRegion};
use aws_types::SigningService;

#[doc(hidden)]
pub struct Params {
region: Option<Region>,
}

impl Params {
pub fn new(region: Option<Region>) -> Self {
Self { region }
}
}

#[doc(hidden)]
pub struct EndpointShim(Arc<dyn ResolveAwsEndpoint>);
impl EndpointShim {
pub fn from_resolver(resolver: impl ResolveAwsEndpoint + 'static) -> Self {
Self(Arc::new(resolver))
}

pub fn from_arc(arc: Arc<dyn ResolveAwsEndpoint>) -> Self {
Self(arc)
}
}

impl<T> ResolveEndpoint<T> for EndpointShim
where
T: Clone + Into<Params>,
{
fn resolve_endpoint(&self, params: &T) -> Result<SmithyEndpoint, ResolveEndpointError> {
let params: Params = params.clone().into();
let aws_endpoint = self
.0
.resolve_endpoint(
params
.region
.as_ref()
.ok_or_else(|| ResolveEndpointError::message("no region in params"))?,
)
.map_err(|err| {
ResolveEndpointError::message("failure resolving endpoint").with_source(Some(err))
})?;
let uri = aws_endpoint.endpoint().uri();
let mut auth_scheme =
HashMap::from([("name".to_string(), Document::String("sigv4".into()))]);
if let Some(region) = aws_endpoint.credential_scope().region() {
auth_scheme.insert(
"signingRegion".to_string(),
region.as_ref().to_string().into(),
);
}
if let Some(service) = aws_endpoint.credential_scope().service() {
auth_scheme.insert(
"signingName".to_string(),
service.as_ref().to_string().into(),
);
}
Ok(SmithyEndpoint::builder()
.url(uri.to_string())
.property("authSchemes", vec![Document::Object(auth_scheme)])
.build())
}
}

/// Middleware Stage to add authentication information from a Smithy endpoint into the property bag
///
/// AwsAuthStage implements [`MapRequest`](MapRequest). It will:
Expand All @@ -95,7 +28,7 @@ pub struct AwsAuthStage;
#[derive(Debug)]
enum AwsAuthStageErrorKind {
NoEndpointResolver,
EndpointResolutionError(BoxError),
EndpointResolutionError(Box<dyn Error + Send + Sync>),
}

#[derive(Debug)]
Expand Down
192 changes: 0 additions & 192 deletions aws/rust-runtime/aws-types/src/endpoint.rs

This file was deleted.

3 changes: 0 additions & 3 deletions aws/rust-runtime/aws-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

pub mod app_name;
pub mod build_metadata;
#[deprecated(since = "0.9.0", note = "renamed to sdk_config")]
pub mod config;
pub mod endpoint;
#[doc(hidden)]
pub mod os_shim_internal;
pub mod region;
Expand Down
Loading