Skip to content

Commit

Permalink
feat(services/s3): add role_session_name in assume roles
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdroychan committed Aug 7, 2024
1 parent d184c69 commit f5fd854
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ pub struct S3Config {
pub role_arn: Option<String>,
/// external_id for this backend.
pub external_id: Option<String>,
/// role_session_name for this backend.
pub role_session_name: Option<String>,
/// Disable config load so that opendal will not load config from
/// environment.
///
Expand Down Expand Up @@ -358,6 +360,15 @@ impl S3Builder {
self
}

/// Set role_session_name for this backend.
pub fn role_session_name(mut self, v: &str) -> Self {
if !v.is_empty() {
self.config.role_session_name = Some(v.to_string())
}

self
}

/// Set default storage_class for this backend.
///
/// Available values:
Expand Down Expand Up @@ -952,6 +963,7 @@ impl Builder for S3Builder {
region: Some(region.clone()),
role_arn: Some(role_arn),
external_id: self.config.external_id.clone(),
role_session_name: self.config.role_session_name.clone(),
sts_regional_endpoints: "regional".to_string(),
..Default::default()
};
Expand Down

0 comments on commit f5fd854

Please sign in to comment.