@@ -11,7 +11,7 @@ use aws_credential_types::provider::{
1111} ;
1212use aws_sdk_sts:: operation:: assume_role:: builders:: AssumeRoleFluentBuilder ;
1313use aws_sdk_sts:: operation:: assume_role:: AssumeRoleError ;
14- use aws_sdk_sts:: types:: PolicyDescriptorType ;
14+ use aws_sdk_sts:: types:: { PolicyDescriptorType , Tag } ;
1515use aws_sdk_sts:: Client as StsClient ;
1616use aws_smithy_runtime:: client:: identity:: IdentityCache ;
1717use 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
108109impl 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