in src/authentication/authentication_provider.cc [242:267]
bool GetCredentialsFromSecretsManager(const char* secret_id, const char* region, Credentials* credentials) {
if (1 == ++sdk_ref_count) {
std::lock_guard<std::mutex> lock(sdk_mutex);
Aws::InitAPI(sdk_opts);
}
std::string region_str = region;
SecretsManagerHelper::ParseRegionFromSecretId(secret_id, region_str);
// configure the secrets manager client according to the region determined
Aws::SecretsManager::SecretsManagerClientConfiguration sm_client_cfg;
sm_client_cfg.region = region_str;
std::shared_ptr<Aws::SecretsManager::SecretsManagerClient> sm_client = std::make_shared<Aws::SecretsManager::SecretsManagerClient>(sm_client_cfg);
SecretsManagerHelper sm_helper(sm_client);
bool is_success = sm_helper.FetchCredentials(secret_id);
ShutdownAwsAPI(); // done using the AWS API
// don't copy any memory if there was a failure fetching the credentials
if (!is_success) {
return false;
}
return UpdateTokenValue(credentials->username, credentials->username_size, sm_helper.GetUsername().c_str())
&& UpdateTokenValue(credentials->password, credentials->password_size, sm_helper.GetPassword().c_str());
}