Skip to content

Commit

Permalink
fix(services/s3): Return error if region not set for AWS S3 (#2234)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored May 8, 2023
1 parent 7d5f096 commit c1d0c6c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/src/services/s3/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,18 @@ impl Builder for S3Builder {
}

if cfg.region.is_none() {
// region is required to make signer work.
//
// If we don't know region after loading from builder and env.
// We will use `us-east-1` as default.
// AWS S3 requires region to be set.
if self.endpoint.is_none()
|| self.endpoint.as_deref() == Some("https://s3.amazonaws.com")
{
return Err(Error::new(ErrorKind::ConfigInvalid, "region is missing")
.with_operation("Builder::build")
.with_context("service", Scheme::S3));
}

// For other compatible services, if we don't know region
// after loading from builder and env, we can use `us-east-1`
// as default.
cfg.region = Some("us-east-1".to_string());
}

Expand Down

0 comments on commit c1d0c6c

Please sign in to comment.