Search in sources :

Example 1 with AwsCredentialsProvider

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();
}
Also used : AssumeRoleRequest(software.amazon.awssdk.services.sts.model.AssumeRoleRequest) STSClient(software.amazon.awssdk.services.sts.STSClient) AwsCredentialsProvider(software.amazon.awssdk.core.auth.AwsCredentialsProvider) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 2 with AwsCredentialsProvider

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());
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.core.auth.AwsCredentialsProvider) StsAssumeRoleCredentialsProvider(software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider) Test(org.junit.Test)

Example 3 with AwsCredentialsProvider

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;
    }
}
Also used : Config(com.typesafe.config.Config) AwsCredentialsProvider(software.amazon.awssdk.core.auth.AwsCredentialsProvider)

Example 4 with AwsCredentialsProvider

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);
}
Also used : AwsCredentialsProvider(software.amazon.awssdk.core.auth.AwsCredentialsProvider) DefaultCredentialsProvider(software.amazon.awssdk.core.auth.DefaultCredentialsProvider) Test(org.junit.Test)

Aggregations

AwsCredentialsProvider (software.amazon.awssdk.core.auth.AwsCredentialsProvider)4 Test (org.junit.Test)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 Config (com.typesafe.config.Config)1 DefaultCredentialsProvider (software.amazon.awssdk.core.auth.DefaultCredentialsProvider)1 STSClient (software.amazon.awssdk.services.sts.STSClient)1 StsAssumeRoleCredentialsProvider (software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider)1 AssumeRoleRequest (software.amazon.awssdk.services.sts.model.AssumeRoleRequest)1