Skip to content

Commit cbf8592

Browse files
committed
GH-46214: [C++] Improve S3 client initialization
1 parent 0e5249b commit cbf8592

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

cpp/src/arrow/filesystem/s3fs.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,12 @@ class EndpointProviderCache {
11081108

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

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

cpp/src/arrow/filesystem/s3fs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ class ARROW_EXPORT S3RetryStrategy {
9696

9797
/// Options for the S3FileSystem implementation.
9898
struct ARROW_EXPORT S3Options {
99+
/// \brief Smart defaults for option values
100+
///
101+
/// The possible values for this setting are explained in the AWS docs:
102+
/// https://docs.aws.amazon.com/sdkref/latest/guide/feature-smart-config-defaults.html
103+
const char* smart_defaults = "standard";
104+
99105
/// \brief AWS region to connect to.
100106
///
101107
/// If unset, the AWS SDK will choose a default value. The exact algorithm

0 commit comments

Comments
 (0)