gaborgsomogyi commented on code in PR #27026:
URL: https://github.com/apache/flink/pull/27026#discussion_r4164690910
##########
flink-filesystems/flink-s3-fs-presto/src/main/java/org/apache/flink/fs/s3presto/token/S3PrestoDelegationTokenProvider.java:
##########
@@ -20,12 +20,42 @@
import org.apache.flink.annotation.Internal;
import org.apache.flink.fs.s3.common.token.AbstractS3DelegationTokenProvider;
+import org.apache.flink.fs.s3.common.token.S3SessionCredentials;
-/** Delegation token provider for S3 Presto filesystems. */
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.securitytoken.AWSSecurityTokenService;
+import
com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder;
+import com.amazonaws.services.securitytoken.model.Credentials;
+
+/** Delegation token provider for S3 Presto filesystems, based on AWS SDK v1.
*/
@Internal
public class S3PrestoDelegationTokenProvider extends
AbstractS3DelegationTokenProvider {
+
@Override
public String serviceName() {
return "s3-presto";
}
+
+ @Override
+ protected S3SessionCredentials getSessionCredentials(
+ String region, String accessKey, String secretKey) {
+ AWSSecurityTokenService stsClient =
+ AWSSecurityTokenServiceClientBuilder.standard()
+ .withRegion(region)
+ .withCredentials(
+ new AWSStaticCredentialsProvider(
+ new BasicAWSCredentials(accessKey,
secretKey)))
+ .build();
+ try {
+ Credentials credentials =
stsClient.getSessionToken().getCredentials();
+ return new S3SessionCredentials(
+ credentials.getAccessKeyId(),
+ credentials.getSecretAccessKey(),
+ credentials.getSessionToken(),
+ credentials.getExpiration().getTime());
+ } finally {
+ stsClient.shutdown();
Review Comment:
I think it would be good to make this best effort with try/catch/log. Please
see the discussion here:
https://github.com/apache/flink/pull/29344#discussion_r4153360811
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]