Skip to content

Commit

Permalink
io: add support to set assume role session name (#555)
Browse files Browse the repository at this point in the history
Partial fix for #527
  • Loading branch information
mattheusv authored Aug 16, 2024
1 parent 1b32a33 commit 19af3d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/iceberg/src/io/storage_s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub const S3_SSE_MD5: &str = "s3.sse.md5";
pub const S3_ASSUME_ROLE_ARN: &str = "client.assume-role.arn";
/// Optional external ID used to assume an IAM role.
pub const S3_ASSUME_ROLE_EXTERNAL_ID: &str = "client.assume-role.external-id";
/// Optional session name used to assume an IAM role.
pub const S3_ASSUME_ROLE_SESSION_NAME: &str = "client.assume-role.session-name";

/// Parse iceberg props to s3 config.
pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config> {
Expand All @@ -76,13 +78,15 @@ pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config
cfg.enable_virtual_host_style = true;
}
};

if let Some(arn) = m.remove(S3_ASSUME_ROLE_ARN) {
cfg.role_arn = Some(arn);
}
if let Some(external_id) = m.remove(S3_ASSUME_ROLE_EXTERNAL_ID) {
cfg.external_id = Some(external_id);
};
if let Some(session_name) = m.remove(S3_ASSUME_ROLE_SESSION_NAME) {
cfg.role_session_name = Some(session_name);
};
let s3_sse_key = m.remove(S3_SSE_KEY);
if let Some(sse_type) = m.remove(S3_SSE_TYPE) {
match sse_type.to_lowercase().as_str() {
Expand Down

0 comments on commit 19af3d3

Please sign in to comment.