Skip to content

Commit 0cce8e3

Browse files
authored
Merge branch 'main' into update-all-lockfiles-1758060336
2 parents a6a2ab3 + eaa6135 commit 0cce8e3

File tree

13 files changed

+161
-14
lines changed

13 files changed

+161
-14
lines changed

aws/codegen-aws-sdk/src/main/kotlin/software/amazon/smithy/rustsdk/AccountIdEndpointParamsDecorator.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import software.amazon.smithy.rust.codegen.client.smithy.customize.ConditionalDe
1414
import software.amazon.smithy.rust.codegen.client.smithy.endpoint.EndpointCustomization
1515
import software.amazon.smithy.rust.codegen.client.smithy.endpoint.EndpointTypesGenerator
1616
import software.amazon.smithy.rust.codegen.client.smithy.endpoint.rustName
17+
import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceRuntimePluginCustomization
18+
import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceRuntimePluginSection
1719
import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization
1820
import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ServiceConfig
1921
import software.amazon.smithy.rust.codegen.core.rustlang.Writable
@@ -199,6 +201,10 @@ class AccountIdEndpointModeBuiltInParamDecorator : ConditionalDecorator(
199201
"AccountIdEndpointMode" to
200202
AwsRuntimeType.awsTypes(codegenContext.runtimeConfig)
201203
.resolve("endpoint_config::AccountIdEndpointMode"),
204+
"AwsSdkFeature" to
205+
AwsRuntimeType.awsRuntime(codegenContext.runtimeConfig)
206+
.resolve("sdk_feature::AwsSdkFeature"),
207+
"tracing" to RuntimeType.Tracing,
202208
)
203209

204210
override fun loadBuiltInFromServiceConfig(
@@ -236,5 +242,31 @@ class AccountIdEndpointModeBuiltInParamDecorator : ConditionalDecorator(
236242
}
237243
},
238244
)
245+
246+
override fun serviceRuntimePluginCustomizations(
247+
codegenContext: ClientCodegenContext,
248+
baseCustomizations: List<ServiceRuntimePluginCustomization>,
249+
): List<ServiceRuntimePluginCustomization> =
250+
baseCustomizations + listOf(AccountIdEndpointFeatureTrackerInterceptor(codegenContext))
239251
},
240252
)
253+
254+
private class AccountIdEndpointFeatureTrackerInterceptor(codegenContext: ClientCodegenContext) :
255+
ServiceRuntimePluginCustomization() {
256+
override fun section(section: ServiceRuntimePluginSection) =
257+
writable {
258+
if (section is ServiceRuntimePluginSection.RegisterRuntimeComponents) {
259+
section.registerInterceptor(this) {
260+
rustTemplate(
261+
"#{Interceptor}",
262+
"Interceptor" to
263+
RuntimeType.forInlineDependency(
264+
InlineAwsDependency.forRustFile(
265+
"account_id_endpoint",
266+
),
267+
).resolve("AccountIdEndpointFeatureTrackerInterceptor"),
268+
)
269+
}
270+
}
271+
}
272+
}

aws/rust-runtime/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aws/rust-runtime/aws-credential-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-credential-types"
3-
version = "1.2.6"
3+
version = "1.2.7"
44
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
55
description = "Types for AWS SDK credentials."
66
edition = "2021"

aws/rust-runtime/aws-credential-types/src/credential_feature.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use aws_smithy_types::config_bag::{Storable, StoreAppend};
99
#[non_exhaustive]
1010
#[derive(Clone, Debug, Eq, PartialEq)]
1111
pub enum AwsCredentialFeature {
12+
/// An operation where credential resolution resolved an account ID
13+
ResolvedAccountId,
1214
/// An operation called using credentials resolved from code, cli parameters, session object, or client instance
1315
CredentialsCode,
1416
/// An operation called using credentials resolved from environment variables

aws/rust-runtime/aws-credential-types/src/credentials_impl.rs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,18 @@ impl From<Credentials> for Identity {
396396

397397
builder.set_expiration(expiry);
398398

399-
if let Some(features) = val.get_property::<Vec<AwsCredentialFeature>>().cloned() {
399+
let features = val.get_property::<Vec<AwsCredentialFeature>>().cloned();
400+
let has_account_id = val.account_id().is_some();
401+
402+
if features.is_some() || has_account_id {
400403
let mut layer = Layer::new("IdentityResolutionFeatureIdTracking");
401-
for feat in features {
402-
layer.store_append(feat);
404+
if let Some(features) = features {
405+
for feat in features {
406+
layer.store_append(feat);
407+
}
408+
}
409+
if has_account_id {
410+
layer.store_append(AwsCredentialFeature::ResolvedAccountId);
403411
}
404412
builder.set_property(layer.freeze());
405413
}
@@ -413,9 +421,6 @@ mod test {
413421
use crate::Credentials;
414422
use std::time::{Duration, UNIX_EPOCH};
415423

416-
#[cfg(feature = "test-util")]
417-
use crate::credential_feature::AwsCredentialFeature;
418-
419424
#[test]
420425
fn debug_impl() {
421426
let creds = Credentials::new(
@@ -451,7 +456,7 @@ mod test {
451456
#[derive(Clone, Debug)]
452457
struct Foo;
453458
let mut creds1 = Credentials::for_tests_with_session_token();
454-
creds1.set_property(AwsCredentialFeature::CredentialsCode);
459+
creds1.set_property(crate::credential_feature::AwsCredentialFeature::CredentialsCode);
455460

456461
let mut creds2 = Credentials::for_tests_with_session_token();
457462
creds2.set_property(Foo);
@@ -462,6 +467,7 @@ mod test {
462467
#[cfg(feature = "test-util")]
463468
#[test]
464469
fn identity_inherits_feature_properties() {
470+
use crate::credential_feature::AwsCredentialFeature;
465471
use aws_smithy_runtime_api::client::identity::Identity;
466472
use aws_smithy_types::config_bag::FrozenLayer;
467473

@@ -485,4 +491,28 @@ mod test {
485491
feature_props.reverse();
486492
assert_eq!(maybe_props, feature_props)
487493
}
494+
495+
#[cfg(feature = "test-util")]
496+
#[test]
497+
fn from_credentials_adds_resolved_account_id_feature() {
498+
use crate::credential_feature::AwsCredentialFeature;
499+
use aws_smithy_runtime_api::client::identity::Identity;
500+
use aws_smithy_types::config_bag::FrozenLayer;
501+
502+
let creds = Credentials::builder()
503+
.access_key_id("test")
504+
.secret_access_key("test")
505+
.account_id("123456789012")
506+
.provider_name("test")
507+
.build();
508+
509+
let identity = Identity::from(creds);
510+
511+
let layer = identity.property::<FrozenLayer>().unwrap();
512+
let features = layer
513+
.load::<AwsCredentialFeature>()
514+
.cloned()
515+
.collect::<Vec<_>>();
516+
assert!(features.contains(&AwsCredentialFeature::ResolvedAccountId));
517+
}
488518
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
use aws_runtime::sdk_feature::AwsSdkFeature;
7+
use aws_smithy_runtime_api::{
8+
box_error::BoxError,
9+
client::interceptors::{context::BeforeSerializationInterceptorContextRef, Intercept},
10+
};
11+
use aws_smithy_types::config_bag::ConfigBag;
12+
use aws_types::endpoint_config::AccountIdEndpointMode;
13+
14+
// Interceptor that tracks AWS SDK features for the account based endpoints.
15+
#[derive(Debug, Default)]
16+
pub(crate) struct AccountIdEndpointFeatureTrackerInterceptor;
17+
18+
impl Intercept for AccountIdEndpointFeatureTrackerInterceptor {
19+
fn name(&self) -> &'static str {
20+
"AccountIdEndpointFeatureTrackerInterceptor"
21+
}
22+
23+
fn read_before_execution(
24+
&self,
25+
_context: &BeforeSerializationInterceptorContextRef<'_>,
26+
cfg: &mut ConfigBag,
27+
) -> Result<(), BoxError> {
28+
match cfg
29+
.load::<AccountIdEndpointMode>()
30+
.cloned()
31+
.unwrap_or_default()
32+
{
33+
AccountIdEndpointMode::Preferred => {
34+
cfg.interceptor_state()
35+
.store_append(AwsSdkFeature::AccountIdModePreferred);
36+
}
37+
AccountIdEndpointMode::Required => {
38+
cfg.interceptor_state()
39+
.store_append(AwsSdkFeature::AccountIdModeRequired);
40+
}
41+
AccountIdEndpointMode::Disabled => {
42+
cfg.interceptor_state()
43+
.store_append(AwsSdkFeature::AccountIdModeDisabled);
44+
}
45+
otherwise => {
46+
::tracing::warn!(
47+
"Attempted to track an SDK feature for `{otherwise:?}`, which is not recognized in the current version of the SDK. \
48+
Consider upgrading to the latest version to ensure that it is properly tracked."
49+
);
50+
}
51+
}
52+
53+
Ok(())
54+
}
55+
}

aws/rust-runtime/aws-inlineable/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
unreachable_pub
2323
)]
2424

25+
/// Supporting code for the account based endpoints.
26+
#[allow(dead_code)]
27+
pub mod account_id_endpoint;
28+
2529
/// Supporting code to determine auth scheme options based on the `authSchemes` endpoint list property.
2630
#[allow(dead_code)]
2731
pub mod endpoint_auth;

aws/rust-runtime/aws-runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-runtime"
3-
version = "1.5.10"
3+
version = "1.5.11"
44
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
55
description = "Runtime support code for the AWS SDK. This crate isn't intended to be used directly."
66
edition = "2021"

aws/rust-runtime/aws-runtime/src/sdk_feature.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ use aws_smithy_types::config_bag::{Storable, StoreAppend};
1212
#[non_exhaustive]
1313
#[derive(Clone, Debug, Eq, PartialEq)]
1414
pub enum AwsSdkFeature {
15+
/// An operation called with account ID mode set to preferred
16+
AccountIdModePreferred,
17+
/// An operation called with account ID mode set to disabled
18+
AccountIdModeDisabled,
19+
/// An operation called with account ID mode set to required
20+
AccountIdModeRequired,
1521
/// Indicates that an operation was called by the S3 Transfer Manager
1622
S3Transfer,
1723
/// Calling an SSO-OIDC operation as part of the SSO login flow, when using the OAuth2.0 device code grant

aws/rust-runtime/aws-runtime/src/user_agent/metrics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ impl ProvideBusinessMetric for AwsSdkFeature {
216216
fn provide_business_metric(&self) -> Option<BusinessMetric> {
217217
use AwsSdkFeature::*;
218218
match self {
219+
AccountIdModePreferred => Some(BusinessMetric::AccountIdModePreferred),
220+
AccountIdModeDisabled => Some(BusinessMetric::AccountIdModeDisabled),
221+
AccountIdModeRequired => Some(BusinessMetric::AccountIdModeRequired),
219222
S3Transfer => Some(BusinessMetric::S3Transfer),
220223
SsoLoginDevice => Some(BusinessMetric::SsoLoginDevice),
221224
SsoLoginAuth => Some(BusinessMetric::SsoLoginAuth),
@@ -227,6 +230,7 @@ impl ProvideBusinessMetric for AwsCredentialFeature {
227230
fn provide_business_metric(&self) -> Option<BusinessMetric> {
228231
use AwsCredentialFeature::*;
229232
match self {
233+
ResolvedAccountId => Some(BusinessMetric::ResolvedAccountId),
230234
CredentialsCode => Some(BusinessMetric::CredentialsCode),
231235
CredentialsEnvVars => Some(BusinessMetric::CredentialsEnvVars),
232236
CredentialsEnvVarsStsWebIdToken => {

0 commit comments

Comments
 (0)