diff --git a/cpp/src/arrow/filesystem/s3fs.cc b/cpp/src/arrow/filesystem/s3fs.cc index 0446fb22209b2..29b45e1dc9abe 100644 --- a/cpp/src/arrow/filesystem/s3fs.cc +++ b/cpp/src/arrow/filesystem/s3fs.cc @@ -127,7 +127,7 @@ using internal::ToAwsString; using internal::ToURLEncodedAwsString; static const char kSep = '/'; -constexpr char kDefaultEndpointEnvVar[] = "AWS_ENDPOINT"; +constexpr char kAwsEndpointUrlEnvVar[] = "AWS_ENDPOINT_URL"; // ----------------------------------------------------------------------- // S3ProxyOptions implementation @@ -338,9 +338,9 @@ Result S3Options::FromUri(const Uri& uri, std::string* out_path) { } else { options.ConfigureDefaultCredentials(); } - auto endpoint_env = arrow::internal::GetEnvVar(kDefaultEndpointEnvVar); - if(endpoint_env.ok()) { - options.endpoint_override = endpoint_env.MoveValueUnsafe(); + auto endpoint_env = arrow::internal::GetEnvVar(kAwsEndpointUrlEnvVar); + if (endpoint_env.ok()) { + options.endpoint_override = *endpoint_env; } bool region_set = false; diff --git a/cpp/src/arrow/filesystem/s3fs_test.cc b/cpp/src/arrow/filesystem/s3fs_test.cc index 1426fe324b720..b1fdb1d07253f 100644 --- a/cpp/src/arrow/filesystem/s3fs_test.cc +++ b/cpp/src/arrow/filesystem/s3fs_test.cc @@ -297,6 +297,14 @@ TEST_F(S3OptionsTest, FromUri) { // Invalid option ASSERT_RAISES(Invalid, S3Options::FromUri("s3://mybucket/?xxx=zzz", &path)); + + // Endpoint from environment variable + { + EnvVarGuard endpoint_guard("AWS_ENDPOINT_URL", "http://127.0.0.1:9000"); + ASSERT_OK_AND_ASSIGN(options, S3Options::FromUri("s3://mybucket/", &path)); + ASSERT_NE(options.endpoint_override, "http://127.0.0.1:9000"); + } + } TEST_F(S3OptionsTest, FromAccessKey) {