j256 / cloudwatch-logback-appender

Appender that publishes logback log entries to AWS CloudWatch
ISC License
56 stars 37 forks source link

Considering using DefaultAWSCredentialsProviderChain #1

Closed efenderbosch closed 7 years ago

efenderbosch commented 7 years ago

I'm just looking at several of the Logback appenders for CloudWatch and noticed you require that the key and secret be in logback.xml and use BasicAWSCredentials. If you switched to DefaultAWSCredentialsProviderChain then users could inject their credentials several different ways (env var, sys props, .aws/credentials, ec2 container creds) w/o having to check them in their VCS.

j256 commented 7 years ago

Good point Eric. So I just need to do something like the following?

AWSCredentials awsCredentials;
if (accessKey == null) {
    awsCredentials = new DefaultAWSCredentialsProviderChain().getCredentials();
} else {
    awsCredentials = new BasicAWSCredentials(accessKey, secretKey);
}
j256 commented 7 years ago

Ok fixed. Seems to work. Thanks again for the suggestion. v1.1 released.