Skip to content

Commit ea3ebeb

Browse files
Backport ClickHouse#82422 to 25.5: Read AWS ECS token from file, attempt #3
1 parent 444a7f2 commit ea3ebeb

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

src/IO/S3/Credentials.cpp

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

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

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

0 commit comments

Comments
 (0)