Commit
+10 -7 +/-1 browse
1 | diff --git a/src/storage/s3.rs b/src/storage/s3.rs |
2 | index a421eb2..60d3b00 100644 |
3 | --- a/src/storage/s3.rs |
4 | +++ b/src/storage/s3.rs |
5 | @@ -105,15 +105,18 @@ impl Backend { |
6 | prefix.pop(); |
7 | } |
8 | |
9 | - // `Region::default` will get try to get the region from the environment |
10 | - // and fallback to a default if it isn't found. |
11 | - let mut region = Region::default(); |
12 | - if let Ok(endpoint) = std::env::var("AWS_S3_ENDPOINT") { |
13 | - region = Region::Custom { |
14 | - name: region.name().to_owned(), |
15 | + // If a custom endpoint is set, do not use the AWS default (us-east-1) |
16 | + // instead, check environment variables for a region name. |
17 | + let region = if let Ok(endpoint) = std::env::var("AWS_S3_ENDPOINT") { |
18 | + Region::Custom { |
19 | + name: std::env::var("AWS_DEFAULT_REGION") |
20 | + .or_else(|_| std::env::var("AWS_REGION")) |
21 | + .unwrap(), |
22 | endpoint, |
23 | } |
24 | - } |
25 | + } else { |
26 | + Region::default() |
27 | + }; |
28 | |
29 | Backend::with_client(S3Client::new(region), bucket, prefix) |
30 | } |