Skip to content

Commit 643b7d4

Browse files
ygndotggparmesant
authored andcommitted
fix: load IRSA web identity config for S3
1 parent 829abd5 commit 643b7d4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/storage/s3.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ use super::{
6969
// in bytes
7070
// const MULTIPART_UPLOAD_SIZE: usize = 1024 * 1024 * 100;
7171
const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: &str = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
72+
const AWS_WEB_IDENTITY_TOKEN_FILE: &str = "AWS_WEB_IDENTITY_TOKEN_FILE";
73+
const AWS_ROLE_ARN: &str = "AWS_ROLE_ARN";
74+
const AWS_ROLE_SESSION_NAME: &str = "AWS_ROLE_SESSION_NAME";
7275

7376
#[derive(Debug, Clone, clap::Args)]
7477
#[command(
@@ -269,6 +272,20 @@ impl S3Config {
269272
.with_secret_access_key(secret_key);
270273
}
271274

275+
if self.access_key_id.is_none() && self.secret_key.is_none() {
276+
if let Ok(token_file) = std::env::var(AWS_WEB_IDENTITY_TOKEN_FILE) {
277+
builder = builder.with_config(AmazonS3ConfigKey::WebIdentityTokenFile, token_file);
278+
}
279+
280+
if let Ok(role_arn) = std::env::var(AWS_ROLE_ARN) {
281+
builder = builder.with_config(AmazonS3ConfigKey::RoleArn, role_arn);
282+
}
283+
284+
if let Ok(session_name) = std::env::var(AWS_ROLE_SESSION_NAME) {
285+
builder = builder.with_config(AmazonS3ConfigKey::RoleSessionName, session_name);
286+
}
287+
}
288+
272289
if let Some(ssec_encryption_key) = &self.ssec_encryption_key {
273290
match ssec_encryption_key {
274291
SSECEncryptionKey::SseC {

0 commit comments

Comments
 (0)