@@ -39,6 +39,8 @@ static const char* REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_VAR = "request_min_
39
39
static const char * AWS_EXECUTION_ENV = " AWS_EXECUTION_ENV" ;
40
40
static const char * DISABLE_IMDSV1_CONFIG_VAR = " AWS_EC2_METADATA_V1_DISABLED" ;
41
41
static const char * DISABLE_IMDSV1_ENV_VAR = " ec2_metadata_v1_disabled" ;
42
+ static const char * AWS_ACCOUNT_ID_ENDPOINT_MODE_ENVIRONMENT_VARIABLE = " AWS_ACCOUNT_ID_ENDPOINT_MODE" ;
43
+ static const char * AWS_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_FILE_OPTION = " account_id_endpoint_mode" ;
42
44
43
45
using RequestChecksumConfigurationEnumMapping = std::pair<const char *, RequestChecksumCalculation>;
44
46
static const std::array<RequestChecksumConfigurationEnumMapping, 2 > REQUEST_CHECKSUM_CONFIG_MAPPING = {{
@@ -278,12 +280,21 @@ void setConfigFromEnvOrProfile(ClientConfiguration &config)
278
280
if (disableIMDSv1 == " true" ) {
279
281
config.disableImdsV1 = true ;
280
282
}
283
+
284
+ // accountId is intentionally not set here: AWS_ACCOUNT_ID env variable may not match the provided credentials.
285
+ // it must be set by an auth provider / identity resolver or by an SDK user.
286
+ config.accountIdEndpointMode = ClientConfiguration::LoadConfigFromEnvOrProfile (AWS_ACCOUNT_ID_ENDPOINT_MODE_ENVIRONMENT_VARIABLE,
287
+ config.profileName ,
288
+ AWS_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_FILE_OPTION,
289
+ {" required" , " disabled" , " preferred" }, /* allowed values */
290
+ " preferred" /* default value */ );
281
291
}
282
292
283
293
ClientConfiguration::ClientConfiguration ()
284
294
{
285
295
this ->disableIMDS = false ;
286
296
setLegacyClientConfigurationParameters (*this );
297
+ setConfigFromEnvOrProfile (*this );;
287
298
288
299
if (!this ->disableIMDS &&
289
300
region.empty () &&
@@ -300,13 +311,13 @@ ClientConfiguration::ClientConfiguration()
300
311
return ;
301
312
}
302
313
region = Aws::String (Aws::Region::US_EAST_1);
303
- setConfigFromEnvOrProfile (*this );
304
314
}
305
315
306
316
ClientConfiguration::ClientConfiguration (const ClientConfigurationInitValues &configuration)
307
317
{
308
318
this ->disableIMDS = configuration.shouldDisableIMDS ;
309
319
setLegacyClientConfigurationParameters (*this );
320
+ setConfigFromEnvOrProfile (*this );
310
321
311
322
if (!this ->disableIMDS &&
312
323
region.empty () &&
@@ -323,7 +334,6 @@ ClientConfiguration::ClientConfiguration(const ClientConfigurationInitValues &co
323
334
return ;
324
335
}
325
336
region = Aws::String (Aws::Region::US_EAST_1);
326
- setConfigFromEnvOrProfile (*this );
327
337
}
328
338
329
339
ClientConfiguration::ClientConfiguration (const char * profile, bool shouldDisableIMDS)
@@ -333,6 +343,7 @@ ClientConfiguration::ClientConfiguration(const char* profile, bool shouldDisable
333
343
this ->profileName = Aws::String (profile);
334
344
}
335
345
setLegacyClientConfigurationParameters (*this );
346
+ setConfigFromEnvOrProfile (*this );
336
347
// Call EC2 Instance Metadata service only once
337
348
Aws::String ec2MetadataRegion;
338
349
bool hasEc2MetadataRegion = false ;
@@ -368,13 +379,13 @@ ClientConfiguration::ClientConfiguration(const char* profile, bool shouldDisable
368
379
}
369
380
370
381
AWS_LOGSTREAM_WARN (CLIENT_CONFIG_TAG, " User specified profile: [" << profile << " ] is not found, will use the SDK resolved one." );
371
- setConfigFromEnvOrProfile (*this );
372
382
}
373
383
374
384
ClientConfiguration::ClientConfiguration (bool /* useSmartDefaults*/ , const char * defaultMode, bool shouldDisableIMDS)
375
385
{
376
386
this ->disableIMDS = shouldDisableIMDS;
377
387
setLegacyClientConfigurationParameters (*this );
388
+ setConfigFromEnvOrProfile (*this );
378
389
379
390
// Call EC2 Instance Metadata service only once
380
391
Aws::String ec2MetadataRegion;
@@ -397,7 +408,6 @@ ClientConfiguration::ClientConfiguration(bool /*useSmartDefaults*/, const char*
397
408
}
398
409
399
410
Aws::Config::Defaults::SetSmartDefaultsConfigurationParameters (*this , defaultMode, hasEc2MetadataRegion, ec2MetadataRegion);
400
- setConfigFromEnvOrProfile (*this );
401
411
}
402
412
403
413
std::shared_ptr<RetryStrategy> InitRetryStrategy (Aws::String retryMode)
0 commit comments