Skip to content

feat: add AWS_S3_FORCE_PATH_STYLE environment variable support #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/aws_s3/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,24 @@ async fn s3_client() -> Result<Client, anyhow::Error> {
static S3_CLIENT: tokio::sync::OnceCell<Client> = tokio::sync::OnceCell::const_new();
let client = S3_CLIENT
.get_or_try_init(|| async {
let config = must_s3_config_from_env()
let aws_config = must_s3_config_from_env()
.context("AWS env variables are required when using S3 storage")?
.retry_config(RetryConfig::standard())
.load()
.await;
anyhow::Ok(Client::new(&config))

// Build S3 config with optional force path style
let mut s3_config_builder = aws_sdk_s3::Config::builder().from(&aws_config);

// Check for AWS_S3_FORCE_PATH_STYLE environment variable
if let Ok(force_path_style) = env::var("AWS_S3_FORCE_PATH_STYLE") {
if force_path_style.to_lowercase() == "true" {
s3_config_builder = s3_config_builder.force_path_style(true);
}
}

let s3_config = s3_config_builder.build();
anyhow::Ok(Client::from_conf(s3_config))
})
.await?
.clone();
Expand Down