Skip to content
10 changes: 10 additions & 0 deletions .changelog/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Add tags to AssumeRoleProviderBuilder
# ---
# applies_to: ["aws-sdk-rust"]
# authors: ["c-thiel"]
# references: ["aws-rust-sdk#1366"]
# breaking: false
# new_feature: true
# bug_fix: false
# ---
# Add tags to AssumeRoleProviderBuilder
16 changes: 14 additions & 2 deletions aws/rust-runtime/aws-config/src/sts/assume_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use aws_credential_types::provider::{
};
use aws_sdk_sts::operation::assume_role::builders::AssumeRoleFluentBuilder;
use aws_sdk_sts::operation::assume_role::AssumeRoleError;
use aws_sdk_sts::types::PolicyDescriptorType;
use aws_sdk_sts::types::{PolicyDescriptorType, Tag};
use aws_sdk_sts::Client as StsClient;
use aws_smithy_runtime::client::identity::IdentityCache;
use aws_smithy_runtime_api::client::result::SdkError;
Expand Down Expand Up @@ -103,6 +103,7 @@ pub struct AssumeRoleProviderBuilder {
policy_arns: Option<Vec<PolicyDescriptorType>>,
region_override: Option<Region>,
sdk_config: Option<SdkConfig>,
tags: Option<Vec<Tag>>,
}

impl AssumeRoleProviderBuilder {
Expand All @@ -123,6 +124,7 @@ impl AssumeRoleProviderBuilder {
policy_arns: None,
sdk_config: None,
region_override: None,
tags: None,
}
}

Expand Down Expand Up @@ -198,6 +200,15 @@ impl AssumeRoleProviderBuilder {
self
}

/// Set the session tags
///
/// A list of session tags that you want to pass. Each session tag consists of a key name and an associated value.
/// For more information, see `[Tag]`.
pub fn tags(mut self, tags: impl Into<Vec<Tag>>) -> Self {
self.tags = Some(tags.into());
self
}

/// Sets the configuration used for this provider
///
/// This enables overriding the connection used to communicate with STS in addition to other internal
Expand Down Expand Up @@ -256,7 +267,8 @@ impl AssumeRoleProviderBuilder {
.set_role_session_name(Some(session_name))
.set_policy(self.policy)
.set_policy_arns(self.policy_arns)
.set_duration_seconds(self.session_length.map(|dur| dur.as_secs() as i32));
.set_duration_seconds(self.session_length.map(|dur| dur.as_secs() as i32))
.set_tags(self.tags);

AssumeRoleProvider {
inner: Inner { fluent_builder },
Expand Down
Loading