Skip to content

Commit a1482df

Browse files
author
cai lin
committed
new configuration support for IMDSConfig
Add ClientConfiguration support for IMDS settings and update related classes Fix: Shared pointer bug in AWSCredentialsProvider allocator mismatch bug fix, change type using c_str() Fix shared pointer bug and update IMDS config structure - Fix std::stol compilation error with Aws::String by using .c_str() - Update IMDS configuration to use credentialProviderConfig.imdsConfig structure - Add proper environment variable support for AWS_METADATA_SERVICE_TIMEOUT and AWS_METADATA_SERVICE_NUM_ATTEMPTS
1 parent 77cb41c commit a1482df

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ namespace Aws
440440
*/
441441
ResponseChecksumValidation responseChecksumValidation = ResponseChecksumValidation::WHEN_SUPPORTED;
442442
} checksumConfig;
443-
443+
444444
/**
445445
* IMDS configuration settings
446446
*/
@@ -473,7 +473,7 @@ namespace Aws
473473
* Configuration that is specifically used for the windows http client
474474
*/
475475
struct WinHTTPOptions {
476-
/**
476+
/**`
477477
* Sets the windows http client to use WINHTTP_NO_CLIENT_CERT_CONTEXT when connecting
478478
* to a service, specifically only useful when disabling ssl verification and using
479479
* a different type of authentication.
@@ -507,6 +507,21 @@ namespace Aws
507507
* AWS profile name to use for credentials.
508508
*/
509509
Aws::String profile;
510+
511+
/**
512+
* IMDS configuration settings
513+
*/
514+
struct {
515+
/**
516+
* Number of total attempts to make when retrieving data from IMDS. Default 1.
517+
*/
518+
long metadataServiceNumAttempts = 1;
519+
520+
/**
521+
* Timeout in seconds when retrieving data from IMDS. Default 1.
522+
*/
523+
long metadataServiceTimeout = 1;
524+
} imdsConfig;
510525
}credentialProviderConfig;
511526
};
512527

src/aws-cpp-sdk-core/source/auth/AWSCredentialsProvider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ InstanceProfileCredentialsProvider::InstanceProfileCredentialsProvider(const Aws
247247
m_ec2MetadataConfigLoader(Aws::MakeShared<Aws::Config::EC2InstanceProfileConfigLoader>(INSTANCE_LOG_TAG, clientConfig)),
248248
m_loadFrequencyMs(refreshRateMs)
249249
{
250+
<<<<<<< HEAD
250251
AWS_LOGSTREAM_INFO(INSTANCE_LOG_TAG, "Creating Instance with IMDS timeout: " << clientConfig.imdsConfig.metadata_service_timeout << "s, attempts: " << clientConfig.imdsConfig.metadata_service_num_attempts);
252+
=======
253+
AWS_LOGSTREAM_INFO(INSTANCE_LOG_TAG, "Creating Instance with IMDS timeout: " << clientConfig.credentialProviderConfig.imdsConfig.metadataServiceTimeout << "s, attempts: " << clientConfig.credentialProviderConfig.imdsConfig.metadataServiceNumAttempts);
254+
>>>>>>> c3e555dc5ae (new configuration support for IMDSConfig)
251255
}
252256

253257
AWSCredentials InstanceProfileCredentialsProvider::GetAWSCredentials()

src/aws-cpp-sdk-core/source/client/ClientConfiguration.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,20 @@ void setConfigFromEnvOrProfile(ClientConfiguration &config)
310310
// Parse and set IMDS num attempts
311311
long attempts = std::stol(numAttemptsStr.c_str());
312312
if (attempts >= 1) {
313+
<<<<<<< HEAD
313314
config.imdsConfig.metadata_service_num_attempts = attempts;
315+
=======
316+
config.credentialProviderConfig.imdsConfig.metadataServiceNumAttempts = attempts;
317+
>>>>>>> c3e555dc5ae (new configuration support for IMDSConfig)
314318
}
315319
// Parse and set IMDS timeout
316320
long timeout = std::stol(timeoutStr.c_str());
317321
if (timeout >= 1) {
322+
<<<<<<< HEAD
318323
config.imdsConfig.metadata_service_timeout = timeout;
324+
=======
325+
config.credentialProviderConfig.imdsConfig.metadataServiceTimeout = timeout;
326+
>>>>>>> c3e555dc5ae (new configuration support for IMDSConfig)
319327
}
320328
}
321329

0 commit comments

Comments
 (0)