Skip to content

Commit b2c4cee

Browse files
authored
Fetch from task iam when env var is found (#480)
1 parent faddaf6 commit b2c4cee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/storage/s3.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use datafusion::datasource::object_store::{
2525
use datafusion::execution::runtime_env::RuntimeConfig;
2626
use futures::stream::FuturesUnordered;
2727
use futures::{StreamExt, TryStreamExt};
28-
use object_store::aws::{AmazonS3, AmazonS3Builder, Checksum};
28+
use object_store::aws::{AmazonS3, AmazonS3Builder, AmazonS3ConfigKey, Checksum};
2929
use object_store::limit::LimitStore;
3030
use object_store::path::Path as StorePath;
3131
use object_store::{ClientOptions, ObjectStore};
@@ -46,6 +46,7 @@ use super::{object_storage, ObjectStorageProvider};
4646
// in bytes
4747
const MULTIPART_UPLOAD_SIZE: usize = 1024 * 1024 * 100;
4848
const CONNECT_TIMEOUT_SECS: u64 = 5;
49+
const AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: &str = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
4950

5051
#[derive(Debug, Clone, clap::Args)]
5152
#[command(
@@ -152,6 +153,13 @@ impl S3Config {
152153
.with_secret_access_key(secret_key);
153154
}
154155

156+
if let Ok(relative_uri) = std::env::var(AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
157+
builder = builder.with_config(
158+
AmazonS3ConfigKey::ContainerCredentialsRelativeUri,
159+
relative_uri,
160+
);
161+
}
162+
155163
if self.imdsv1_fallback {
156164
builder = builder.with_imdsv1_fallback()
157165
}

0 commit comments

Comments
 (0)