Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,8 @@
org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider,
org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider,
software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider,
org.apache.hadoop.fs.s3a.auth.IAMInstanceCredentialsProvider
org.apache.hadoop.fs.s3a.auth.IAMInstanceCredentialsProvider,
org.apache.hadoop.fs.s3a.ProfileAWSCredentialsProvider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this optional but document it

</value>
<description>
Comma-separated class names of credential provider classes which implement
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.apache.hadoop.fs.s3a;

Check failure on line 1 in hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/ProfileAWSCredentialsProvider.java

View check run for this annotation

ASF Cloudbees Jenkins ci-hadoop / Apache Yetus

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/ProfileAWSCredentialsProvider.java#L1

asflicense: Missing Apache License

import org.apache.commons.lang3.SystemUtils;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use same import ordering as other classes

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.profiles.ProfileFile;

import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;

@InterfaceAudience.Public
@InterfaceStability.Stable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evolving

public class ProfileAWSCredentialsProvider implements AwsCredentialsProvider {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extends AbstractAWSCredentialProvider

and move into package auth

public static final String NAME
= "org.apache.hadoop.fs.s3a.ProfileAWSCredentialsProvider";

private ProfileCredentialsProvider pcp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make final


private static Path getCredentialsPath() {
String credentialsFile = SystemUtils.getEnvironmentVariable("AWS_SHARED_CREDENTIALS_FILE", null);
Path path = (credentialsFile == null) ?
FileSystems.getDefault().getPath(SystemUtils.getUserHome().getPath(),".aws","credentials")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this path should be configurable

: FileSystems.getDefault().getPath(credentialsFile);
return path;
}

public ProfileAWSCredentialsProvider(URI uri, Configuration conf) {
ProfileCredentialsProvider.Builder builder = ProfileCredentialsProvider.builder();
builder.profileName("default").profileFile(ProfileFile.builder().content(getCredentialsPath()).type(ProfileFile.Type.CREDENTIALS).build());
pcp = builder.build();
}

public ProfileAWSCredentialsProvider(Configuration conf) {
ProfileCredentialsProvider.Builder builder = ProfileCredentialsProvider.builder();
builder.profileName("default").profileFile(ProfileFile.builder().content(getCredentialsPath()).build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile name should be configurable

pcp = builder.build();
}
public AwsCredentials resolveCredentials() {
return pcp.resolveCredentials();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.hadoop.fs.s3a.Constants;
import org.apache.hadoop.fs.s3a.S3AUtils;
import org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider;
import org.apache.hadoop.fs.s3a.ProfileAWSCredentialsProvider;
import org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider;
import org.apache.hadoop.fs.s3a.adapter.AwsV1BindingSupport;
import org.apache.hadoop.fs.s3a.impl.InstantiationIOException;
Expand Down Expand Up @@ -84,7 +85,8 @@ public final class CredentialProviderListFactory {
EnvironmentVariableCredentialsProvider.class,
IAMInstanceCredentialsProvider.class,
SimpleAWSCredentialsProvider.class,
TemporaryAWSCredentialsProvider.class));
TemporaryAWSCredentialsProvider.class,
ProfileAWSCredentialsProvider.class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a standard one...will need to be explicitly configured


/** V1 credential provider: {@value}. */
public static final String ANONYMOUS_CREDENTIALS_V1 =
Expand Down
Loading