CommandLineRunner.makeProfile
fbridger opened this issue · 5 comments
Hi, I am getting the following error when trying to run the docker container.
I am running it using the parameters that are specified in the README section.
I think the problem is in the first if statement using || instead of &&
private AWSCredentialsProvider getAwsCredentialsProvider() {
if (awsProfile != null || awsConfigLocation != null) {
final String profile = makeProfile(awsProfile);
return new ProfileCredentialsProvider(awsConfigLocation, profile);
} else if (awsAccessKey != null && awsSecretKey != null) {
return new AWSStaticCredentialsProvider(
new BasicAWSCredentials(awsAccessKey, awsSecretKey));
} else {
return new DefaultAWSCredentialsProviderChain();
}
}
Picked up JAVA_TOOL_OPTIONS:
Exception in thread "main" java.lang.NullPointerException
at com.disneystreaming.pg2k4j.CommandLineRunner.makeProfile(CommandLineRunner.java:217)
at com.disneystreaming.pg2k4j.CommandLineRunner.getAwsCredentialsProvider(CommandLineRunner.java:205)
at com.disneystreaming.pg2k4j.CommandLineRunner.getKinesisProducerConfiguration(CommandLineRunner.java:229)
at com.disneystreaming.pg2k4j.SlotReaderKinesisWriter.(SlotReaderKinesisWriter.java:77)
at com.disneystreaming.pg2k4j.CommandLineRunner.run(CommandLineRunner.java:25)
at java.base/java.util.Optional.ifPresent(Optional.java:183)
at com.disneystreaming.pg2k4j.CommandLineRunner.main(CommandLineRunner.java:45)
Thanks for submitting the issue -- it makes sense. We'll work on a few fixes for the readme and validation, but from a usability perspective, if you add a --awsprofile=<yourprofile>
to your docker run command, that should get you up and running
Thanks @rkass for answering so soon!
Yes, we had to use that approach to make it work. However, we had to manually add a profile named "profile XXXX" in our credentials file to get it work as the code is appending that prefix. Which seems to be another issue.
Fix:
.aws\config
[profile default]
region = ZZZZ
.aws\credentials
[profile default]
aws_access_key_id = XXXXX
aws_secret_access_key = YYYYY
The profile prefix is unfortunately required at this point. It seems like according to the issue here aws/aws-sdk-java#1707 this will be fixed as part of the aws-sdk-java 2.0 release.
See #23 for ensuring that both profile and config file are present before using ProfileCredentialsProvider
Fixed in https://github.com/disneystreaming/pg2k4j/releases/tag/1.0.4 . Thanks for opening this issue @fbridger! Feel free to reopen if you continue to have this issue with the above release.