Skip to content

Commit efdbb3b

Browse files
authored
feat: expose opendal S3 options for anonymous access (#757)
1 parent 4fba3f4 commit efdbb3b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

crates/iceberg/src/io/storage_s3.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ pub const S3_ASSUME_ROLE_ARN: &str = "client.assume-role.arn";
5858
pub const S3_ASSUME_ROLE_EXTERNAL_ID: &str = "client.assume-role.external-id";
5959
/// Optional session name used to assume an IAM role.
6060
pub const S3_ASSUME_ROLE_SESSION_NAME: &str = "client.assume-role.session-name";
61+
/// Option to skip signing request (e.g. for public buckets/folders)
62+
pub const S3_ALLOW_ANONYMOUS: &str = "s3.allow-anonymous";
63+
/// Option to skip loading the credential from EC2 metadata (typically used in conjunction with
64+
/// `S3_ALLOW_ANONYMOUS`)
65+
pub const S3_DISABLE_EC2_METADATA: &str = "s3.disable-ec2-metadata";
6166

6267
/// Parse iceberg props to s3 config.
6368
pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config> {
@@ -81,7 +86,7 @@ pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config
8186
cfg.region = Some(region);
8287
};
8388
if let Some(path_style_access) = m.remove(S3_PATH_STYLE_ACCESS) {
84-
if ["true", "True", "1"].contains(&path_style_access.as_str()) {
89+
if ["true", "t", "1"].contains(&path_style_access.to_lowercase().as_str()) {
8590
cfg.enable_virtual_host_style = true;
8691
}
8792
};
@@ -126,6 +131,17 @@ pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config
126131
}
127132
};
128133

134+
if let Some(allow_anonymous) = m.remove(S3_ALLOW_ANONYMOUS) {
135+
if ["true", "t", "1", "on"].contains(&allow_anonymous.to_lowercase().as_str()) {
136+
cfg.allow_anonymous = true;
137+
}
138+
}
139+
if let Some(disable_ec2_metadata) = m.remove(S3_DISABLE_EC2_METADATA) {
140+
if ["true", "t", "1", "on"].contains(&disable_ec2_metadata.to_lowercase().as_str()) {
141+
cfg.disable_ec2_metadata = true;
142+
}
143+
};
144+
129145
Ok(cfg)
130146
}
131147

0 commit comments

Comments
 (0)