Skip to content

Commit 93ecc1f

Browse files
authored
feat(rust): Add tags to AssumeRoleProviderBuilder (#4330)
2 parents 6164276 + fc56196 commit 93ecc1f

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

.changelog/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
applies_to: ["aws-sdk-rust"]
3+
authors: ["c-thiel"]
4+
references: ["aws-sdk-rust#1366"]
5+
breaking: false
6+
new_feature: true
7+
bug_fix: false
8+
---
9+
Add tags to `AssumeRoleProviderBuilder`

aws/rust-runtime/aws-config/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-config"
3-
version = "1.8.8"
3+
version = "1.8.9"
44
authors = [
55
"AWS Rust SDK Team <[email protected]>",
66
"Russell Cohen <[email protected]>",

aws/rust-runtime/aws-config/src/sts/assume_role.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use aws_credential_types::provider::{
1111
};
1212
use aws_sdk_sts::operation::assume_role::builders::AssumeRoleFluentBuilder;
1313
use aws_sdk_sts::operation::assume_role::AssumeRoleError;
14-
use aws_sdk_sts::types::PolicyDescriptorType;
14+
use aws_sdk_sts::types::{PolicyDescriptorType, Tag};
1515
use aws_sdk_sts::Client as StsClient;
1616
use aws_smithy_runtime::client::identity::IdentityCache;
1717
use aws_smithy_runtime_api::client::result::SdkError;
@@ -103,6 +103,7 @@ pub struct AssumeRoleProviderBuilder {
103103
policy_arns: Option<Vec<PolicyDescriptorType>>,
104104
region_override: Option<Region>,
105105
sdk_config: Option<SdkConfig>,
106+
tags: Option<Vec<Tag>>,
106107
}
107108

108109
impl AssumeRoleProviderBuilder {
@@ -123,6 +124,7 @@ impl AssumeRoleProviderBuilder {
123124
policy_arns: None,
124125
sdk_config: None,
125126
region_override: None,
127+
tags: None,
126128
}
127129
}
128130

@@ -198,6 +200,31 @@ impl AssumeRoleProviderBuilder {
198200
self
199201
}
200202

203+
/// Set the session tags
204+
///
205+
/// A list of session tags that you want to pass. Each session tag consists of a key name and an associated value.
206+
/// For more information, see `[Tag]`.
207+
pub fn tags<K, V>(mut self, tags: impl IntoIterator<Item = (K, V)>) -> Self
208+
where
209+
K: Into<String>,
210+
V: Into<String>,
211+
{
212+
self.tags = Some(
213+
tags.into_iter()
214+
// Unwrap won't fail as both key and value are specified.
215+
// Currently Tag does not have an infallible build method.
216+
.map(|(k, v)| {
217+
Tag::builder()
218+
.key(k)
219+
.value(v)
220+
.build()
221+
.expect("this is unreachable: both k and v are set")
222+
})
223+
.collect::<Vec<_>>(),
224+
);
225+
self
226+
}
227+
201228
/// Sets the configuration used for this provider
202229
///
203230
/// This enables overriding the connection used to communicate with STS in addition to other internal
@@ -256,7 +283,8 @@ impl AssumeRoleProviderBuilder {
256283
.set_role_session_name(Some(session_name))
257284
.set_policy(self.policy)
258285
.set_policy_arns(self.policy_arns)
259-
.set_duration_seconds(self.session_length.map(|dur| dur.as_secs() as i32));
286+
.set_duration_seconds(self.session_length.map(|dur| dur.as_secs() as i32))
287+
.set_tags(self.tags);
260288

261289
AssumeRoleProvider {
262290
inner: Inner { fluent_builder },

0 commit comments

Comments
 (0)