Skip to content

Commit 3820f0d

Browse files
Backport #82422 to 25.4: Read AWS ECS token from file, attempt #3
1 parent 41cc571 commit 3820f0d

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/IO/S3/Credentials.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,12 @@ S3CredentialsProviderChain::S3CredentialsProviderChain(
759759
auto token = Aws::Environment::GetEnv(AWS_ECS_CONTAINER_AUTHORIZATION_TOKEN);
760760
const auto token_path = Aws::Environment::GetEnv(AWS_ECS_CONTAINER_AUTHORIZATION_TOKEN_FILE);
761761

762-
if (!token_path.empty())
763-
{
764-
LOG_INFO(logger, "The environment variable value {} is {}", AWS_ECS_CONTAINER_AUTHORIZATION_TOKEN_FILE, token_path);
765-
766-
String token_from_file;
767-
768-
ReadBufferFromFile in(token_path);
769-
readStringUntilEOF(token_from_file, in);
770-
Poco::trimInPlace(token_from_file);
771-
772-
token = token_from_file;
773-
}
774-
775-
AddProvider(std::make_shared<Aws::Auth::TaskRoleCredentialsProvider>(absolute_uri.c_str(), token.c_str()));
762+
AddProvider(std::make_shared<Aws::Auth::GeneralHTTPCredentialsProvider>(
763+
relative_uri,
764+
absolute_uri,
765+
token,
766+
token_path
767+
));
776768

777769
/// DO NOT log the value of the authorization token for security purposes.
778770
LOG_INFO(logger, "Added ECS credentials provider with URI: [{}] to the provider chain with a{} authorization token.",

0 commit comments

Comments
 (0)