Skip to content

GH-46214: [C++] Improve S3 client initialization #46723

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
7 changes: 6 additions & 1 deletion cpp/src/arrow/filesystem/s3fs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,12 @@ class EndpointProviderCache {

class ClientBuilder {
public:
explicit ClientBuilder(S3Options options) : options_(std::move(options)) {}
explicit ClientBuilder(S3Options options)
: options_(std::move(options)),
// The ClientConfiguration constructor always does a current region lookup
// via EC2 metadata, unless IMDS is disabled (GH-46214).
client_config_(/*useSmartDefaults=*/true, options_.smart_defaults,
/*shouldDisableIMDS=*/true) {}

const Aws::Client::ClientConfiguration& config() const { return client_config_; }

Expand Down
6 changes: 6 additions & 0 deletions cpp/src/arrow/filesystem/s3fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ class ARROW_EXPORT S3RetryStrategy {

/// Options for the S3FileSystem implementation.
struct ARROW_EXPORT S3Options {
/// \brief Smart defaults for option values
///
/// The possible values for this setting are explained in the AWS docs:
/// https://docs.aws.amazon.com/sdkref/latest/guide/feature-smart-config-defaults.html
const char* smart_defaults = "standard";

/// \brief AWS region to connect to.
///
/// If unset, the AWS SDK will choose a default value. The exact algorithm
Expand Down
Loading