Skip to content

Commit ad8df6a

Browse files
committed
Use the region specified in the client config.
1 parent 37c8c1d commit ad8df6a

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

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

+1-17
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,14 @@ STSAssumeRoleWebIdentityCredentialsProvider::STSAssumeRoleWebIdentityCredentials
3636
m_initialized(false)
3737
{
3838
// check environment variables
39-
Aws::String tmpRegion = Aws::Environment::GetEnv("AWS_DEFAULT_REGION");
4039
m_roleArn = Aws::Environment::GetEnv("AWS_ROLE_ARN");
4140
m_tokenFile = Aws::Environment::GetEnv("AWS_WEB_IDENTITY_TOKEN_FILE");
4241
m_sessionName = Aws::Environment::GetEnv("AWS_ROLE_SESSION_NAME");
4342

4443
// check profile_config if either m_roleArn or m_tokenFile is not loaded from environment variable
45-
// region source is not enforced, but we need it to construct sts endpoint, if we can't find from environment, we should check if it's set in config file.
46-
if (m_roleArn.empty() || m_tokenFile.empty() || tmpRegion.empty())
44+
if (m_roleArn.empty() || m_tokenFile.empty())
4745
{
4846
auto profile = Aws::Config::GetCachedConfigProfile(Aws::Auth::GetConfigProfileName());
49-
if (tmpRegion.empty())
50-
{
51-
tmpRegion = profile.GetRegion();
52-
}
5347
// If either of these two were not found from environment, use whatever found for all three in config file
5448
if (m_roleArn.empty() || m_tokenFile.empty())
5549
{
@@ -79,15 +73,6 @@ STSAssumeRoleWebIdentityCredentialsProvider::STSAssumeRoleWebIdentityCredentials
7973
AWS_LOGSTREAM_DEBUG(STS_ASSUME_ROLE_WEB_IDENTITY_LOG_TAG, "Resolved role_arn from profile_config or environment variable to be " << m_roleArn);
8074
}
8175

82-
if (tmpRegion.empty())
83-
{
84-
tmpRegion = Aws::Region::US_EAST_1;
85-
}
86-
else
87-
{
88-
AWS_LOGSTREAM_DEBUG(STS_ASSUME_ROLE_WEB_IDENTITY_LOG_TAG, "Resolved region from profile_config or environment variable to be " << tmpRegion);
89-
}
90-
9176
if (m_sessionName.empty())
9277
{
9378
m_sessionName = Aws::Utils::UUID::PseudoRandomUUID();
@@ -98,7 +83,6 @@ STSAssumeRoleWebIdentityCredentialsProvider::STSAssumeRoleWebIdentityCredentials
9883
}
9984

10085
config.scheme = Aws::Http::Scheme::HTTPS;
101-
config.region = tmpRegion;
10286

10387
if (config.retryStrategy == nullptr) {
10488
Aws::Vector<Aws::String> retryableErrors;

0 commit comments

Comments
 (0)