use of software.amazon.awssdk.core.auth.AwsCredentialsProvider in project uploader by smoketurner.
the class AwsConfiguration method getCredentials.
@JsonIgnore
public AwsCredentialsProvider getCredentials() {
final AwsCredentialsProvider credentials;
if (!Strings.isNullOrEmpty(accessKey) && !Strings.isNullOrEmpty(secretKey)) {
credentials = StaticCredentialsProvider.create(AwsCredentials.create(accessKey, secretKey));
} else {
credentials = DefaultCredentialsProvider.create();
}
if (Strings.isNullOrEmpty(stsRoleArn)) {
return credentials;
}
final STSClient stsClient = STSClient.builder().credentialsProvider(credentials).region(region).build();
final AssumeRoleRequest assumeRoleRequest = AssumeRoleRequest.builder().roleArn(stsRoleArn).build();
return StsAssumeRoleCredentialsProvider.builder().stsClient(stsClient).refreshRequest(assumeRoleRequest).build();
}
use of software.amazon.awssdk.core.auth.AwsCredentialsProvider in project iep by Netflix.
the class AwsClientFactoryTest method createCredentialsProviderOverride.
@Test
public void createCredentialsProviderOverride() throws Exception {
AwsClientFactory factory = new AwsClientFactory(config);
AwsCredentialsProvider creds = factory.createCredentialsProvider("ec2-test");
Assert.assertTrue(creds instanceof StsAssumeRoleCredentialsProvider);
Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getRequest(creds).roleArn());
Assert.assertEquals("iep", getRequest(creds).roleSessionName());
}
use of software.amazon.awssdk.core.auth.AwsCredentialsProvider in project iep by Netflix.
the class AwsClientFactory method createCredentialsProvider.
AwsCredentialsProvider createCredentialsProvider(String name) {
final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder().asyncCredentialUpdateEnabled(true).build();
final Config cfg = getConfig(name, "credentials");
if (cfg.hasPath("role-arn")) {
return createAssumeRoleProvider(cfg, dflt);
} else {
return dflt;
}
}
use of software.amazon.awssdk.core.auth.AwsCredentialsProvider in project iep by Netflix.
the class AwsClientFactoryTest method createCredentialsProvider.
@Test
public void createCredentialsProvider() {
AwsClientFactory factory = new AwsClientFactory(config);
AwsCredentialsProvider creds = factory.createCredentialsProvider(null);
Assert.assertTrue(creds instanceof DefaultCredentialsProvider);
}
Aggregations