Commit 87b36e2d authored by Bill Wang's avatar Bill Wang
Browse files

update

parent 03c1d31a
......@@ -52,7 +52,7 @@
<dependency>
<groupId>org.opengroup.osdu.core.aws</groupId>
<artifactId>os-core-lib-aws</artifactId>
<version>0.3.17</version>
<version>0.11.1-local-param-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......
......@@ -14,20 +14,26 @@
package org.opengroup.osdu.search.provider.aws.persistence;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import javax.annotation.PostConstruct;
import org.opengroup.osdu.core.aws.ssm.ParameterStorePropertySource;
import org.opengroup.osdu.core.aws.ssm.SSMConfig;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.opengroup.osdu.core.aws.secrets.SecretsManager;
import java.lang.reflect.Type;
import java.util.Map;
@Component
public class ElasticRepositoryImpl implements IElasticRepository {
......@@ -62,25 +68,17 @@ public class ElasticRepositoryImpl implements IElasticRepository {
private String amazonRegion;
@Value("${aws.ssm}")
String ssmEnabledString;
private ParameterStorePropertySource ssm;
@PostConstruct
private void postConstruct() {
if( Boolean.parseBoolean(ssmEnabledString)) {
SSMConfig ssmConfig = new SSMConfig();
ssm = ssmConfig.amazonSSM();
host = ssm.getProperty(hostParameter).toString();
port = Integer.parseInt(ssm.getProperty(portParameter).toString());
}
SecretsManager sm = new SecretsManager();
username = sm.getSecret(elasticCredentialsSecret,amazonRegion,"username");
password = sm.getSecret(elasticCredentialsSecret,amazonRegion,"password");
K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
host = provider.getParameterAsString(hostParameter);
port = Integer.parseInt(provider.getParameterAsString(portParameter));
Type mapType = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String[]> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType);
username = val.get("username").toString();
password = val.get("password").toString();
//elastic expects username:password format
usernameAndPassword = String.format("%s:%s", username, password);
......
......@@ -14,9 +14,9 @@
package org.opengroup.osdu.search.provider.aws.service;
import org.opengroup.osdu.core.aws.secrets.SecretsManager;
import org.opengroup.osdu.core.aws.ssm.ParameterStorePropertySource;
import org.opengroup.osdu.core.aws.ssm.SSMConfig;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider;
import org.opengroup.osdu.core.common.model.search.ClusterSettings;
import org.opengroup.osdu.core.common.model.indexer.IElasticSettingService;
import org.springframework.beans.factory.annotation.Value;
......@@ -24,6 +24,8 @@ import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.lang.reflect.Type;
import java.util.Map;
@Primary
@Component
......@@ -61,24 +63,16 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Value("${aws.ssm}")
String ssmEnabledString;
private ParameterStorePropertySource ssm;
@PostConstruct
private void postConstruct() {
if( Boolean.parseBoolean(ssmEnabledString)) {
SSMConfig ssmConfig = new SSMConfig();
ssm = ssmConfig.amazonSSM();
host = ssm.getProperty(hostParameter).toString();
port = Integer.parseInt(ssm.getProperty(portParameter).toString());
K8sLocalParameterProvider provider = new K8sLocalParameterProvider();
host = provider.getParameterAsString(hostParameter);
port = Integer.parseInt(provider.getParameterAsString(portParameter));
Type mapType = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String[]> val = new Gson().fromJson(provider.getParameterAsString(elasticCredentialsSecret), mapType);
username = val.get("username").toString();
password = val.get("password").toString();
}
SecretsManager sm = new SecretsManager();
username = sm.getSecret(elasticCredentialsSecret,amazonRegion,"username");
password = sm.getSecret(elasticCredentialsSecret,amazonRegion,"password");
//elastic expects username:password format
usernameAndPassword = String.format("%s:%s", username, password);
}
......
......@@ -55,9 +55,9 @@ awsParameterStorePropertySource.enabled=true
aws.ssm=${SSM_ENABLED}
aws.ssm.prefix=/osdu/${ENVIRONMENT}
aws.elasticsearch.host=${aws.ssm.prefix}/elasticsearch/end-point
aws.elasticsearch.port=${aws.ssm.prefix}/elasticsearch/end-point-port
aws.elasticsearch.credentials.secret=${aws.ssm.prefix}/elasticsearch/credentials
aws.elasticsearch.host=elasticsearch_host
aws.elasticsearch.port=elasticsearch_port
aws.elasticsearch.credentials.secret=elasticsearch_credentials
server.ssl.enabled=${SSL_ENABLED:true}
server.ssl.key-store-type=PKCS12
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment