@Test public void createCredentialsProviderForAccountIgnored() throws Exception { AwsClientFactory factory = new AwsClientFactory(config); AWSCredentialsProvider creds = factory.createCredentialsProvider("ec2-test", "123"); Assert.assertTrue(creds instanceof STSAssumeRoleSessionCredentialsProvider); Assert.assertEquals("arn:aws:iam::1234567890:role/IepTest", getField(creds, "roleArn")); Assert.assertEquals("iep", getField(creds, "roleSessionName")); }
AWSCredentialsProvider createCredentialsProvider(String name, String accountId) { final AWSCredentialsProvider dflt = new DefaultAWSCredentialsProviderChain(); 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 = new DefaultAWSCredentialsProviderChain(); 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 = new DefaultAWSCredentialsProviderChain(); 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 = new DefaultAWSCredentialsProviderChain(); 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 = new DefaultAWSCredentialsProviderChain(); 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();  }