Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from jankronquist/master
Browse files Browse the repository at this point in the history
Added support to set AWSCredentialsProvider
  • Loading branch information
kenoir committed Sep 17, 2015
2 parents dad7787 + 37803aa commit 8a8a228
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main/java/com/gu/logback/appender/kinesis/KinesisAppender.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class KinesisAppender extends AppenderBase<ILoggingEvent> {
private AmazonKinesisAsyncClient kinesisClient;
private AsyncPutCallStatsReporter asyncCallHander;
private LayoutBase layout;
private AWSCredentialsProvider credentials;
private AWSCredentialsProvider credentials = new CustomCredentialsProviderChain();

public LayoutBase getLayout() {
return layout;
Expand Down Expand Up @@ -107,18 +107,6 @@ public void start() {
return;
}

CustomCredentialsProviderChain localAccountCredentials = new CustomCredentialsProviderChain();

if (Validator.isBlank(roleToAssumeArn)) {
credentials = localAccountCredentials;
} else {
String sessionId = "session" + Math.random();
STSAssumeRoleSessionCredentialsProvider remoteAccountCredentials = new
STSAssumeRoleSessionCredentialsProvider(localAccountCredentials, roleToAssumeArn, sessionId);

credentials = remoteAccountCredentials;
}

ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setMaxErrorRetry(maxRetries);
clientConfiguration.setRetryPolicy(new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION,
Expand Down Expand Up @@ -378,6 +366,17 @@ public String getRoleToAssumeArn() {

public void setRoleToAssumeArn(String roleToAssumeArn) {
this.roleToAssumeArn = roleToAssumeArn;
if (!Validator.isBlank(roleToAssumeArn)) {
String sessionId = "session" + Math.random();
STSAssumeRoleSessionCredentialsProvider remoteAccountCredentials = new
STSAssumeRoleSessionCredentialsProvider(credentials, roleToAssumeArn, sessionId);

credentials = remoteAccountCredentials;
}
}

public void setCredentialsProvider(AWSCredentialsProvider credentialsProvider) {
this.credentials = credentialsProvider;
}

/**
Expand Down

0 comments on commit 8a8a228

Please sign in to comment.