@Test public void createCredentialsProviderOverride() throws Exception { AwsClientFactory factory = new AwsClientFactory(config); AwsCredentialsProvider creds = factory.createCredentialsProvider("ec2-test", null); Assert.assertTrue(creds instanceof StsAssumeRoleCredentialsProvider); Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getRequest(creds).roleArn()); Assert.assertEquals("iep", getRequest(creds).roleSessionName()); }
AwsCredentialsProvider createCredentialsProvider(String name, String accountId) { final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else { if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } }
AwsClientFactory implements AutoCloseable { AwsCredentialsProvider createCredentialsProvider(String name, String accountId) { final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else { if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } } }
AwsClientFactory implements AutoCloseable { AwsCredentialsProvider createCredentialsProvider(String name, String accountId) { final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else { if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } } @Inject  AwsClientFactory(Config config); }
AwsClientFactory implements AutoCloseable { AwsCredentialsProvider createCredentialsProvider(String name, String accountId) { final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else { if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close(); }
AwsClientFactory implements AutoCloseable { AwsCredentialsProvider createCredentialsProvider(String name, String accountId) { final AwsCredentialsProvider dflt = DefaultCredentialsProvider.builder() .asyncCredentialUpdateEnabled(true) .build(); final Config cfg = getConfig(name, "credentials"); if (cfg.hasPath("role-arn")) { return createAssumeRoleProvider(cfg, accountId, dflt); } else { if (accountId != null) { LOGGER.warn("requested account, {}, ignored, no role ARN configured", accountId); } return dflt; } } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close();  }