Skip to content

Commit

Permalink
made key & secret settings not mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
pecollet committed Jan 31, 2024
1 parent 1591bad commit 996d3c3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.neo4j</groupId>
<artifactId>aws-ec2-asg-discovery</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/cs/neo4j/AsgResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,29 @@ public String name() {

@Override
protected void internalInit(Config config, LogService logService, DependencyResolver externalDependencies) {
log = logService.getUserLog(AsgResolver.class);
log.info("Init of discovery plugin "+this.configDescription());

discoveryPort = checkConfig(config, DiscoverySettings.discovery_listen_address).getPort();

selector = checkConfig(config, Ec2Settings.asg_name);
awsKey = checkConfig(config, Ec2Settings.aws_key);
awsSecret = checkConfig(config, Ec2Settings.aws_secret);
awsRegion = checkConfig(config, Ec2Settings.aws_region);

discoveryPort = checkConfig(config, DiscoverySettings.discovery_listen_address).getPort();
awsKey = config.get(Ec2Settings.aws_key);
awsSecret = config.get(Ec2Settings.aws_secret);

log = logService.getUserLog(AsgResolver.class);
log.info("Init of discovery plugin "+this.configDescription());
awsClient = externalDependencies.containsDependency(AwsClient.class)
? externalDependencies.resolveDependency(AwsClient.class)
: new AwsClient(awsKey, awsSecret, awsRegion);
: instantiateAwsClient(awsKey, awsSecret, awsRegion);

}

private AwsClient instantiateAwsClient(String accessKey, String secretKey, String region) {
if (accessKey != null && secretKey != null) {
return new AwsClient(accessKey, secretKey, region);
} else {
return new AwsClient(region);
}
}

@Override
Expand Down

0 comments on commit 996d3c3

Please sign in to comment.