Skip to content
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

GH-36770: [C++] Use custom endpoint for s3 using environment variable AWS_ENDPOINT_URL #36791

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ using internal::ToAwsString;
using internal::ToURLEncodedAwsString;

static const char kSep = '/';
constexpr char kAwsEndpointUrlEnvVar[] = "AWS_ENDPOINT_URL";

// -----------------------------------------------------------------------
// S3ProxyOptions implementation
Expand Down Expand Up @@ -337,6 +338,10 @@ Result<S3Options> S3Options::FromUri(const Uri& uri, std::string* out_path) {
} else {
options.ConfigureDefaultCredentials();
}
auto endpoint_env = arrow::internal::GetEnvVar(kAwsEndpointUrlEnvVar);
if (endpoint_env.ok()) {
options.endpoint_override = *endpoint_env;
}

bool region_set = false;
for (const auto& kv : options_map) {
Expand Down
7 changes: 7 additions & 0 deletions cpp/src/arrow/filesystem/s3fs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ 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_EQ(options.endpoint_override, "http://127.0.0.1:9000");
}
}

TEST_F(S3OptionsTest, FromAccessKey) {
Expand Down
Loading