10
10
#include " istringstream_nocopy.hh"
11
11
12
12
#include < aws/core/Aws.h>
13
+ #include < aws/core/auth/AWSCredentialsProvider.h>
14
+ #include < aws/core/auth/AWSCredentialsProviderChain.h>
13
15
#include < aws/core/client/ClientConfiguration.h>
14
16
#include < aws/core/client/DefaultRetryStrategy.h>
15
17
#include < aws/core/utils/logging/FormattedLogSystem.h>
@@ -77,9 +79,15 @@ static void initAWS()
77
79
});
78
80
}
79
81
80
- S3Helper::S3Helper (const string & region)
82
+ S3Helper::S3Helper (const std::string & profile, const std:: string & region)
81
83
: config(makeConfig(region))
82
- , client(make_ref<Aws::S3::S3Client>(*config, true , false ))
84
+ , client(make_ref<Aws::S3::S3Client>(
85
+ profile == " "
86
+ ? std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>(
87
+ std::make_shared<Aws::Auth::DefaultAWSCredentialsProviderChain>())
88
+ : std::dynamic_pointer_cast<Aws::Auth::AWSCredentialsProvider>(
89
+ std::make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>(profile.c_str())),
90
+ *config, true , false ))
83
91
{
84
92
}
85
93
@@ -148,6 +156,7 @@ S3Helper::DownloadResult S3Helper::getObject(
148
156
149
157
struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
150
158
{
159
+ const Setting<std::string> profile{this , " " , " profile" , " The name of the AWS configuration profile to use." };
151
160
const Setting<std::string> region{this , Aws::Region::US_EAST_1, " region" , {" aws-region" }};
152
161
const Setting<std::string> narinfoCompression{this , " " , " narinfo-compression" , " compression method for .narinfo files" };
153
162
const Setting<std::string> lsCompression{this , " " , " ls-compression" , " compression method for .ls files" };
@@ -163,7 +172,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
163
172
const Params & params, const std::string & bucketName)
164
173
: S3BinaryCacheStore(params)
165
174
, bucketName(bucketName)
166
- , s3Helper(region)
175
+ , s3Helper(profile, region)
167
176
{
168
177
diskCache = getNarInfoDiskCache ();
169
178
}
0 commit comments