-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholder types for S3 Express and enable control flow to be re…
…directed for S3 Express use case (#3386) ## Motivation and Context This PR is the first in the series to support the S3 Express feature in the Rust SDK. The work will be done in the feature branch, and once it is code complete, the branch will be merged to main. ## Description This PR adds placeholder types for S3 Express and enables control flow to be redirected for S3 Express use case. For instance, if we run the following example code against a generated SDK from this PR: ```rust let shared_config = aws_config::from_env().region(aws_sdk_s3::config::Region::new("us-east-1")).load().await; let client = aws_sdk_s3::Client::new(&shared_config); client.list_objects_v2().bucket("testbucket--use1-az4--x-s3";).send().await.unwrap(); ``` it will end up ``` thread 's3_express' panicked at 'not yet implemented', /Users/awsaito/src/smithy-rs/aws/sdk/build/aws-sdk/sdk/s3/src/s3_express.rs:104:13 ``` which points to ``` impl ProvideCredentials for DefaultS3ExpressIdentityProvider { fn provide_credentials<'a>(&'a self) -> aws_credential_types::provider::future::ProvideCredentials<'a> where Self: 'a, { todo!() <--- } } ``` ### Implementation decisions - `DefaultS3ExpressIdentityProvider` has an accompanying identity cache. That identity cache cannot be configured by customers so it makes sense for the provider itself to internally own it. In that case, we do NOT want to use the identity cache stored in `RuntimeComponents`, since it interferes with the S3 Express's caching policy. To that end, I added an enum `CacheLocation` to `SharedIdentityResolver` (it already had the `cache_partition` field so it was kind of aware of caching). - Two reasons why `CacheLocation` is added to `SharedIdentityResolver`, but not to individual, concrete `IdentityResolver`s. One is `SharedIdentityResolver` was already cache aware, as mentioned above. The other is that it is more flexible that way; The cache location is not tied to a type of identity resolver, but we can select it when creating a `SharedIdentityResolver`. - I considered but did not add a field `cacheable` to `Identity` since I wanted to keep `Identity` as plain data, keeping the concept of "caching" somewhere outside. - I've added a separate `Config` method, `set_express_credentials_provider`, to override credentials provider for S3 Express. There are other SDKs (e.g. [Ruby](https://www.rubydoc.info/gems/aws-sdk-s3/Aws/S3/Client)) that follow this style and it makes it clear to the customers that this is the method to use when overriding the express credentials provider. The existing `set_credentials_provider`, given its input type, cannot tell whether a passed-in credentials provider is for a regular `sigv4` or for S3 Express. ## Testing Only verified that control flow could be altered for an S3 Express use case, as shown above. Further testing will be added in subsequent PRs. ## Checklist I am planning to include in `CHANGELOG.next.toml` a user guide for S3 Express once the feature branch `ysaito/s3express` is ready to be merged to main. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: John DiSanti <[email protected]> Co-authored-by: AWS SDK Rust Bot <[email protected]> Co-authored-by: AWS SDK Rust Bot <[email protected]> Co-authored-by: Zelda Hessler <[email protected]>
- Loading branch information
1 parent
ae52b69
commit 39be6ce
Showing
28 changed files
with
988 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/// Supporting code for S3 Express auth | ||
pub(crate) mod auth { | ||
use aws_smithy_runtime_api::box_error::BoxError; | ||
use aws_smithy_runtime_api::client::auth::{ | ||
AuthScheme, AuthSchemeEndpointConfig, AuthSchemeId, Sign, | ||
}; | ||
use aws_smithy_runtime_api::client::identity::{Identity, SharedIdentityResolver}; | ||
use aws_smithy_runtime_api::client::orchestrator::HttpRequest; | ||
use aws_smithy_runtime_api::client::runtime_components::{ | ||
GetIdentityResolver, RuntimeComponents, | ||
}; | ||
use aws_smithy_types::config_bag::ConfigBag; | ||
|
||
/// Auth scheme ID for S3 Express. | ||
pub(crate) const SCHEME_ID: AuthSchemeId = AuthSchemeId::new("sigv4-s3express"); | ||
|
||
/// S3 Express auth scheme. | ||
#[derive(Debug, Default)] | ||
pub(crate) struct S3ExpressAuthScheme { | ||
signer: S3ExpressSigner, | ||
} | ||
|
||
impl S3ExpressAuthScheme { | ||
/// Creates a new `S3ExpressAuthScheme`. | ||
pub(crate) fn new() -> Self { | ||
Default::default() | ||
} | ||
} | ||
|
||
impl AuthScheme for S3ExpressAuthScheme { | ||
fn scheme_id(&self) -> AuthSchemeId { | ||
SCHEME_ID | ||
} | ||
|
||
fn identity_resolver( | ||
&self, | ||
identity_resolvers: &dyn GetIdentityResolver, | ||
) -> Option<SharedIdentityResolver> { | ||
identity_resolvers.identity_resolver(self.scheme_id()) | ||
} | ||
|
||
fn signer(&self) -> &dyn Sign { | ||
&self.signer | ||
} | ||
} | ||
|
||
/// S3 Express signer. | ||
#[derive(Debug, Default)] | ||
pub(crate) struct S3ExpressSigner; | ||
|
||
impl Sign for S3ExpressSigner { | ||
fn sign_http_request( | ||
&self, | ||
_request: &mut HttpRequest, | ||
_identity: &Identity, | ||
_auth_scheme_endpoint_config: AuthSchemeEndpointConfig<'_>, | ||
_runtime_components: &RuntimeComponents, | ||
_config_bag: &ConfigBag, | ||
) -> Result<(), BoxError> { | ||
todo!() | ||
} | ||
} | ||
} | ||
|
||
/// Supporting code for S3 Express identity cache | ||
pub(crate) mod identity_cache { | ||
/// The caching implementation for S3 Express identity. | ||
/// | ||
/// While customers can either disable S3 Express itself or provide a custom S3 Express identity | ||
/// provider, configuring S3 Express identity cache is not supported. Thus, this is _the_ | ||
/// implementation of S3 Express identity cache. | ||
#[derive(Debug)] | ||
pub(crate) struct S3ExpressIdentityCache; | ||
} | ||
|
||
/// Supporting code for S3 Express identity provider | ||
pub(crate) mod identity_provider { | ||
use crate::s3_express::identity_cache::S3ExpressIdentityCache; | ||
use aws_smithy_runtime_api::client::identity::{ | ||
IdentityCacheLocation, IdentityFuture, ResolveIdentity, | ||
}; | ||
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents; | ||
use aws_smithy_types::config_bag::ConfigBag; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct DefaultS3ExpressIdentityProvider { | ||
_cache: S3ExpressIdentityCache, | ||
} | ||
|
||
#[derive(Default)] | ||
pub(crate) struct Builder; | ||
|
||
impl DefaultS3ExpressIdentityProvider { | ||
pub(crate) fn builder() -> Builder { | ||
Builder | ||
} | ||
} | ||
|
||
impl Builder { | ||
pub(crate) fn build(self) -> DefaultS3ExpressIdentityProvider { | ||
DefaultS3ExpressIdentityProvider { | ||
_cache: S3ExpressIdentityCache, | ||
} | ||
} | ||
} | ||
|
||
impl ResolveIdentity for DefaultS3ExpressIdentityProvider { | ||
fn resolve_identity<'a>( | ||
&'a self, | ||
_runtime_components: &'a RuntimeComponents, | ||
_config_bag: &'a ConfigBag, | ||
) -> IdentityFuture<'a> { | ||
todo!() | ||
} | ||
|
||
fn cache_location(&self) -> IdentityCacheLocation { | ||
IdentityCacheLocation::IdentityResolver | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.