Skip to content

Commit 70e07bb

Browse files
Use new AWS SDK client constructors. (#5232)
[SC-51986](https://app.shortcut.com/tiledb-inc/story/51986/stop-using-deprecated-s3client-constructors) AWS SDK client constructors that accept a generic `ClientConfig` are [deprecated](https://github.com/aws/aws-sdk-cpp/blob/8f42b8167fbb31fb3c0392b58c4b6327e71afbb8/generated/src/aws-cpp-sdk-s3/include/aws/s3/S3Client.h#L105-L135). The suggested alternatives accept subclasses of `ClientConfig`, which may include service-specific options (like payload signing policy and using virtual addressing for S3). This PR moves to the new constructors when creating both S3 and STS clients. --- TYPE: NO_HISTORY
1 parent c0c3bb4 commit 70e07bb

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

tiledb/sm/filesystem/s3.cc

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ Status S3::init_client() const {
13481348
// check for client configuration on create, which can be slow if aws is not
13491349
// configured on a users systems due to ec2 metadata check
13501350

1351-
client_config_ = make_shared<Aws::Client::ClientConfiguration>(HERE());
1351+
client_config_ = make_shared<Aws::S3::S3ClientConfiguration>(HERE());
13521352

13531353
s3_tp_executor_ = make_shared<S3ThreadPoolExecutor>(HERE(), vfs_thread_pool_);
13541354

@@ -1388,6 +1388,10 @@ Status S3::init_client() const {
13881388
s3_params_.connect_max_tries_,
13891389
s3_params_.connect_scale_factor_);
13901390

1391+
client_config.useVirtualAddressing = s3_params_.use_virtual_addressing_;
1392+
client_config.payloadSigningPolicy =
1393+
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never;
1394+
13911395
// If the user says not to sign a request, use the
13921396
// AnonymousAWSCredentialsProvider This is equivalent to --no-sign-request on
13931397
// the aws cli
@@ -1443,7 +1447,12 @@ Status S3::init_client() const {
14431447
session_name,
14441448
external_id,
14451449
load_frequency,
1446-
make_shared<Aws::STS::STSClient>(HERE(), client_config));
1450+
make_shared<Aws::STS::STSClient>(
1451+
HERE(),
1452+
// client_config is an S3ClientConfiguration&, but gets
1453+
// casted to ClientConfiguration and copied to the STS
1454+
// client configuration.
1455+
Aws::STS::STSClientConfiguration(client_config)));
14471456
break;
14481457
}
14491458
case 7: {
@@ -1465,9 +1474,16 @@ Status S3::init_client() const {
14651474
HERE(),
14661475
Aws::Auth::GetConfigProfileName(),
14671476
std::chrono::minutes(60),
1468-
[client_config](const auto& credentials) {
1477+
[config = this->client_config_](const auto& credentials) {
14691478
return make_shared<Aws::STS::STSClient>(
1470-
HERE(), credentials, client_config);
1479+
HERE(),
1480+
credentials,
1481+
// Create default endpoint provider.
1482+
make_shared<Aws::STS::STSEndpointProvider>(HERE()),
1483+
// *config is an S3ClientConfiguration&, but gets
1484+
// casted to ClientConfiguration and copied to the STS
1485+
// client configuration.
1486+
Aws::STS::STSClientConfiguration(*config));
14711487
});
14721488
break;
14731489
}
@@ -1492,20 +1508,11 @@ Status S3::init_client() const {
14921508
{
14931509
std::lock_guard<std::mutex> static_lck(static_client_init_mtx);
14941510
if (credentials_provider_ == nullptr) {
1495-
client_ = make_shared<TileDBS3Client>(
1496-
HERE(),
1497-
s3_params_,
1498-
*client_config_,
1499-
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
1500-
s3_params_.use_virtual_addressing_);
1511+
client_ =
1512+
make_shared<TileDBS3Client>(HERE(), s3_params_, *client_config_);
15011513
} else {
15021514
client_ = make_shared<TileDBS3Client>(
1503-
HERE(),
1504-
s3_params_,
1505-
credentials_provider_,
1506-
*client_config_,
1507-
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
1508-
s3_params_.use_virtual_addressing_);
1515+
HERE(), s3_params_, credentials_provider_, *client_config_);
15091516
}
15101517
}
15111518

tiledb/sm/filesystem/s3.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include <aws/core/utils/threading/Executor.h>
7070
#include <aws/identity-management/auth/STSAssumeRoleCredentialsProvider.h>
7171
#include <aws/s3/S3Client.h>
72+
#include <aws/s3/S3ClientConfiguration.h>
7273
#include <aws/s3/model/CompleteMultipartUploadRequest.h>
7374
#include <aws/s3/model/CopyObjectRequest.h>
7475
#include <aws/s3/model/CreateBucketRequest.h>
@@ -354,21 +355,20 @@ class TileDBS3Client : public Aws::S3::S3Client {
354355
public:
355356
TileDBS3Client(
356357
const S3Parameters& s3_params,
357-
const Aws::Client::ClientConfiguration& client_config,
358-
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy sign_payloads,
359-
bool use_virtual_addressing)
360-
: Aws::S3::S3Client(client_config, sign_payloads, use_virtual_addressing)
358+
const Aws::S3::S3ClientConfiguration& client_config)
359+
: Aws::S3::S3Client(client_config)
361360
, params_(s3_params) {
362361
}
363362

364363
TileDBS3Client(
365364
const S3Parameters& s3_params,
366365
const std::shared_ptr<Aws::Auth::AWSCredentialsProvider>& creds,
367-
const Aws::Client::ClientConfiguration& client_config,
368-
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy sign_payloads,
369-
bool use_virtual_addressing)
366+
const Aws::S3::S3ClientConfiguration& client_config)
370367
: Aws::S3::S3Client(
371-
creds, client_config, sign_payloads, use_virtual_addressing)
368+
creds,
369+
// Create default endpoint provider.
370+
make_shared<Aws::S3::S3EndpointProvider>(HERE()),
371+
client_config)
372372
, params_(s3_params) {
373373
}
374374

@@ -1352,7 +1352,7 @@ class S3 : FilesystemBase {
13521352
mutable std::mutex client_init_mtx_;
13531353

13541354
/** Configuration object used to initialize the client. */
1355-
mutable shared_ptr<Aws::Client::ClientConfiguration> client_config_;
1355+
mutable shared_ptr<Aws::S3::S3ClientConfiguration> client_config_;
13561356

13571357
/** The executor used by 'client_'. */
13581358
mutable shared_ptr<S3ThreadPoolExecutor> s3_tp_executor_;

0 commit comments

Comments
 (0)