diff --git a/autotest/gcore/vsis3.py b/autotest/gcore/vsis3.py index cacec03b5b45..f799185fce48 100755 --- a/autotest/gcore/vsis3.py +++ b/autotest/gcore/vsis3.py @@ -143,7 +143,7 @@ def test_vsis3_no_sign_request(aws_test_config_as_config_options_or_credentials) bucket = "noaa-goes16" obj = "ABI-L1b-RadC/2022/001/00/OR_ABI-L1b-RadC-M6C01_G16_s20220010001173_e20220010003546_c20220010003587.nc" vsis3_path = "/vsis3/" + bucket + "/" + obj - url = "https://" + bucket + ".s3.amazonaws.com/" + obj + url = "https://" + bucket + ".s3.us-east-1.amazonaws.com/" + obj with gdaltest.config_options( options, thread_local=False diff --git a/port/cpl_aws.cpp b/port/cpl_aws.cpp index 0f4606a5c8ad..550a2b8df1c7 100644 --- a/port/cpl_aws.cpp +++ b/port/cpl_aws.cpp @@ -1730,8 +1730,12 @@ VSIS3HandleHelper *VSIS3HandleHelper::BuildFromURI(const char *pszURI, osRegion = osDefaultRegion; } - const std::string osEndpoint = VSIGetPathSpecificOption( + std::string osEndpoint = VSIGetPathSpecificOption( osPathForOption.c_str(), "AWS_S3_ENDPOINT", "s3.amazonaws.com"); + if (!osRegion.empty() && osEndpoint == "s3.amazonaws.com") + { + osEndpoint = "s3." + osRegion + ".amazonaws.com"; + } const std::string osRequestPayer = VSIGetPathSpecificOption( osPathForOption.c_str(), "AWS_REQUEST_PAYER", ""); std::string osBucket;