From f5fd8545b6d97b49357fb054ace389a02c466553 Mon Sep 17 00:00:00 2001 From: Chen Chen Date: Wed, 7 Aug 2024 16:38:01 -0500 Subject: [PATCH] feat(services/s3): add role_session_name in assume roles --- core/src/services/s3/backend.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 1bcd4a4bfd08..64b56e63cf77 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -124,6 +124,8 @@ pub struct S3Config { pub role_arn: Option, /// external_id for this backend. pub external_id: Option, + /// role_session_name for this backend. + pub role_session_name: Option, /// Disable config load so that opendal will not load config from /// environment. /// @@ -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: @@ -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() };