Unverified Commit 29abdc9b authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Enable Endpoints 2.0 (#2074)

* wip

* Fix region decorator

* Update S3 tests to succeed

* Create 'endpoint_url' setters

* Fix SDK adhoc tests

* Fix endpoint tests

* Fix protocol test generator to have a stub endpoint resolver

* Fix some more tests

* Fix aws rust runtime tests

* Update generator to appease clippy

* CR feedback

* Fix compilation

* Fix tests

* Fix doc links

* Fix SDK integration tests

* Update changelog

* Fix s3 control by adding transformer

* Throw a specific exception if the service doesn't have ep rules

* Add codecatalyst to the list of custom services
parent 59de0220
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -11,6 +11,38 @@
# meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"}
# author = "rcoh"

[[aws-sdk-rust]]
message = """Integrate Endpoints 2.0 into the Rust SDK. Endpoints 2.0 enables features like S3 virtual addressing & S3
object lambda. As part of this change, there are several breaking changes although efforts have been made to deprecate
where possible to smooth the upgrade path.
1. `aws_smithy_http::endpoint::Endpoint` and the `endpoint_resolver` methods have been deprecated. In general, these usages
   should be replaced with usages of `endpoint_url` instead. `endpoint_url` accepts a string so an `aws_smithy_http::Endpoint`
   does not need to be constructed. This structure and methods will be removed in a future release.
2. The `endpoint_resolver` method on `<service>::config::Builder` now accepts a service specific endpoint resolver instead
   of an implementation of `ResolveAwsEndpoint`. Most users will be able to replace these usages with a usage of `endpoint_url`.
3. `ResolveAwsEndpoint` has been deprecated and will be removed in a future version of the SDK.
4. The SDK does not support "pseudo regions" anymore. Specifically, regions like `iam-fips` will no longer resolve to a FIPS endpoint.
"""
references = ["smithy-rs#1784", "smithy-rs#2074"]
meta = { "breaking" = true, "tada" = true, "bug" = false }
author = "rcoh"

[[aws-sdk-rust]]
message = """Add additional configuration parameters to `aws_sdk_s3::Config`.

The launch of endpoints 2.0 includes more configuration options for S3. The default behavior for endpoint resolution has
been changed. Before, all requests hit the path-style endpoint. Going forward, all requests that can be routed to the
virtually hosted bucket will be routed there automatically.
- `force_path_style`: Requests will now default to the virtually-hosted endpoint `<bucketname>.s3.<region>.amazonaws.com`
- `use_arn_region`: Enables this client to use an ARN’s region when constructing an endpoint instead of the client’s configured region.
- `accelerate`: Enables this client to use S3 Transfer Acceleration endpoints.

Note: the AWS SDK for Rust does not currently support Multi Region Access Points (MRAP).
"""
references = ["smithy-rs#1784", "smithy-rs#2074"]
meta = { "breaking" = true, "tada" = true, "bug" = false }
author = "rcoh"

[[smithy-rs]]
message = "In 0.52, `@length`-constrained collection shapes whose members are not constrained made the server code generator crash. This has been fixed."
references = ["smithy-rs#2103"]
+3 −5
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ use std::io;
use std::net::IpAddr;

use aws_smithy_client::erase::boxclone::BoxCloneService;
use aws_smithy_http::endpoint::Endpoint;
use aws_smithy_http::endpoint::apply_endpoint;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_types::credentials;
use aws_types::credentials::{future, CredentialsError, ProvideCredentials};
@@ -190,10 +190,8 @@ impl Provider {
                });
            }
        };
        let endpoint =
            Endpoint::immutable_uri(Uri::from_static(BASE_HOST)).expect("BASE_HOST is valid");
        endpoint
            .set_endpoint(&mut relative_uri, None)
        let endpoint = Uri::from_static(BASE_HOST);
        apply_endpoint(&mut relative_uri, &endpoint, None)
            .expect("appending relative URLs to the ECS endpoint should always succeed");
        Ok(relative_uri)
    }
+3 −7
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ use aws_smithy_client::http_connector::ConnectorSettings;
use aws_smithy_client::{erase::DynConnector, SdkSuccess};
use aws_smithy_client::{retry, SdkError};
use aws_smithy_http::body::SdkBody;
use aws_smithy_http::endpoint::Endpoint;
use aws_smithy_http::endpoint::apply_endpoint;
use aws_smithy_http::operation;
use aws_smithy_http::operation::{Metadata, Operation};
use aws_smithy_http::response::ParseStrictResponse;
@@ -128,7 +128,7 @@ pub struct Client {

#[derive(Debug)]
struct ClientInner {
    endpoint: Endpoint,
    endpoint: Uri,
    smithy_client: aws_smithy_client::Client<DynConnector, ImdsMiddleware>,
}

@@ -235,10 +235,7 @@ impl Client {
        let mut base_uri: Uri = path.parse().map_err(|_| {
            ImdsError::unexpected("IMDS path was not a valid URI. Hint: does it begin with `/`?")
        })?;
        self.inner
            .endpoint
            .set_endpoint(&mut base_uri, None)
            .map_err(ImdsError::unexpected)?;
        apply_endpoint(&mut base_uri, &self.inner.endpoint, None).map_err(ImdsError::unexpected)?;
        let request = http::Request::builder()
            .uri(base_uri)
            .body(SdkBody::empty())
@@ -434,7 +431,6 @@ impl Builder {
            .endpoint
            .unwrap_or_else(|| EndpointSource::Env(config.env(), config.fs()));
        let endpoint = endpoint_source.endpoint(self.mode_override).await?;
        let endpoint = Endpoint::immutable_uri(endpoint)?;
        let retry_config = retry::Config::default()
            .with_max_attempts(self.max_attempts.unwrap_or(DEFAULT_ATTEMPTS));
        let token_loader = token::TokenMiddleware::new(
+4 −6
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ use aws_smithy_async::rt::sleep::AsyncSleep;
use aws_smithy_client::erase::DynConnector;
use aws_smithy_client::retry;
use aws_smithy_http::body::SdkBody;
use aws_smithy_http::endpoint::Endpoint;
use aws_smithy_http::endpoint::apply_endpoint;
use aws_smithy_http::middleware::AsyncMapRequest;
use aws_smithy_http::operation;
use aws_smithy_http::operation::Operation;
@@ -66,7 +66,7 @@ pub(super) struct TokenMiddleware {
    token_parser: GetTokenResponseHandler,
    token: ExpiringCache<Token, ImdsError>,
    time_source: TimeSource,
    endpoint: Endpoint,
    endpoint: Uri,
    token_ttl: Duration,
}

@@ -80,7 +80,7 @@ impl TokenMiddleware {
    pub(super) fn new(
        connector: DynConnector,
        time_source: TimeSource,
        endpoint: Endpoint,
        endpoint: Uri,
        token_ttl: Duration,
        retry_config: retry::Config,
        timeout_config: TimeoutConfig,
@@ -128,9 +128,7 @@ impl TokenMiddleware {

    async fn get_token(&self) -> Result<(Token, SystemTime), ImdsError> {
        let mut uri = Uri::from_static("/latest/api/token");
        self.endpoint
            .set_endpoint(&mut uri, None)
            .map_err(ImdsError::unexpected)?;
        apply_endpoint(&mut uri, &self.endpoint, None).map_err(ImdsError::unexpected)?;
        let request = http::Request::builder()
            .header(
                X_AWS_EC2_METADATA_TOKEN_TTL_SECONDS,
+29 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@ mod loader {
        app_name: Option<AppName>,
        credentials_provider: Option<SharedCredentialsProvider>,
        endpoint_resolver: Option<Arc<dyn ResolveAwsEndpoint>>,
        endpoint_url: Option<String>,
        region: Option<Box<dyn ProvideRegion>>,
        retry_config: Option<RetryConfig>,
        sleep: Option<Arc<dyn AsyncSleep>>,
@@ -315,6 +316,8 @@ mod loader {

        /// 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.
@@ -332,6 +335,7 @@ mod loader {
        ///     .await;
        /// # Ok(())
        /// # }
        #[deprecated(note = "use `.endpoint_url(...)` instead")]
        pub fn endpoint_resolver(
            mut self,
            endpoint_resolver: impl ResolveAwsEndpoint + 'static,
@@ -340,6 +344,30 @@ mod loader {
            self
        }

        /// Override the endpoint URL used for **all** AWS services.
        ///
        /// This method will override the endpoint URL used for **all** AWS services. This primarily
        /// exists to set a static endpoint for tools like `LocalStack`. When sending requests to
        /// production AWS services, this method should only be used for service-specific behavior.
        ///
        /// When this method is used, the [`Region`](aws_types::region::Region) is only used for
        /// signing; it is not used to route the request.
        ///
        /// # Examples
        ///
        /// Use a static endpoint for all services
        /// ```no_run
        /// # async fn create_config() {
        /// let sdk_config = aws_config::from_env()
        ///     .endpoint_url("http://localhost:1234")
        ///     .load()
        ///     .await;
        /// # }
        pub fn endpoint_url(mut self, endpoint_url: impl Into<String>) -> Self {
            self.endpoint_url = Some(endpoint_url.into());
            self
        }

        /// Set configuration for all sub-loaders (credentials, region etc.)
        ///
        /// Update the `ProviderConfig` used for all nested loaders. This can be used to override
@@ -458,6 +486,7 @@ mod loader {
            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);
            builder.build()
        }
    }
Loading