Skip to content

Commit

Permalink
Add support for session tags
Browse files Browse the repository at this point in the history
  • Loading branch information
rahull-p committed Aug 10, 2024
1 parent 928bf96 commit 61a9500
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/aws/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub struct Config {
/// - this field if it's `is_some`.
/// - profile config: `external_id`
pub external_id: Option<String>,
/// `tags` value will be loaded from:
///
/// - this field if it's `is_some`
pub tags: Option<Vec<String>>,
/// `web_identity_token_file` value will be loaded from:
///
/// - this field if it's `is_some`
Expand Down Expand Up @@ -118,6 +122,7 @@ impl Default for Config {
role_session_name: "reqsign".to_string(),
duration_seconds: Some(3600),
external_id: None,
tags: None,
web_identity_token_file: None,
ec2_metadata_disabled: false,
}
Expand Down
11 changes: 11 additions & 0 deletions src/aws/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,17 @@ impl AssumeRoleLoader {
if let Some(duration_seconds) = &self.config.duration_seconds {
write!(url, "&DurationSeconds={duration_seconds}")?;
}
if let Some(tags) = &self.config.tags {
for (idx, tag) in tags.iter().enumerate() {
let parts = tag.split("=").collect::<Vec<&str>>();
let key = parts[0];
let value = parts[1];
write!(
url,
"&Tags.member.{idx}.Key={key}&Tags.member.{idx}.Value={value}"
)?;
}
}

let req = http::request::Request::builder()
.method("GET")
Expand Down

0 comments on commit 61a9500

Please sign in to comment.