Commit 067d05f1 authored by Spencer Sutton's avatar Spencer Sutton
Browse files

Merge branch 'aws-blue-update' into 'master'

AWS Updates

See merge request !144
parents 01009ae5 3c08e196
Pipeline #53258 failed with stages
in 33 minutes and 30 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright © 2020 Amazon Web Services
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.​
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
......@@ -34,7 +35,7 @@
<id>gitlab-os-core-common-maven</id>
<url>https://community.opengroup.org/api/v4/projects/67/packages/maven</url>
</repository>
<repository>
<repository>
<id>gitlab-os-core-lib-aws-maven</id>
<url>https://community.opengroup.org/api/v4/projects/68/packages/maven</url>
</repository>
......@@ -63,15 +64,14 @@
</server>
</servers>
<!-- CodeArtifact doesn't support external repos yet that aren't Maven Central. ETA Q4 2020. -->
<!-- <mirrors> -->
<!-- <mirror> -->
<!-- <id>aws-osdu-dev-maven</id> -->
<!-- <name>aws-osdu-dev-maven</name> -->
<!-- <url>https://osdu-dev-888733619319.d.codeartifact.us-east-1.amazonaws.com/maven/osdu-maven/</url> -->
<!-- <mirrorOf>*,!gitlab-os-core-common-maven</mirrorOf> -->
<!-- </mirror> -->
<!-- </mirrors> -->
<mirrors>
<mirror>
<id>aws-osdu-dev-maven</id>
<name>aws-osdu-dev-maven</name>
<url>https://osdu-dev-${AWS_ACCOUNT_ID}.d.codeartifact.us-east-1.amazonaws.com/maven/osdu-maven/</url>
<mirrorOf>central,!gitlab-os-core-common-maven,!gitlab-os-core-lib-aws-maven</mirrorOf>
</mirror>
</mirrors>
<activeProfiles>
<activeProfile>credentialsConfiguration</activeProfile>
......
......@@ -34,8 +34,9 @@ public class CursorCacheImpl implements CursorCache {
*/
public CursorCacheImpl(@Value("${aws.elasticache.cluster.cursor.endpoint}") final String REDIS_SEARCH_HOST,
@Value("${aws.elasticache.cluster.cursor.port}") final String REDIS_SEARCH_PORT,
@Value("${aws.elasticache.cluster.cursor.key}") final String REDIS_SEARCH_KEY,
@Value("${aws.elasticache.cluster.cursor.expiration}") final String INDEX_CACHE_EXPIRATION) {
cache = new RedisCache<String, CursorSettings>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT),
cache = new RedisCache<String, CursorSettings>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT), REDIS_SEARCH_KEY,
Integer.parseInt(INDEX_CACHE_EXPIRATION) * 60, String.class, CursorSettings.class);
}
......
......@@ -15,6 +15,7 @@
package org.opengroup.osdu.search.provider.aws.cache;
import org.opengroup.osdu.core.common.cache.RedisCache;
import org.opengroup.osdu.core.common.model.search.CursorSettings;
import org.opengroup.osdu.search.cache.IFieldTypeMappingCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -34,9 +35,11 @@ public class FieldTypeMappingCacheImpl implements IFieldTypeMappingCache {
* @param REDIS_SEARCH_PORT - the port of the Cursor Cache Redis cluster.
*/
public FieldTypeMappingCacheImpl(@Value("${aws.elasticache.cluster.cursor.endpoint}") final String REDIS_SEARCH_HOST,
@Value("${aws.elasticache.cluster.cursor.port}") final String REDIS_SEARCH_PORT) {
cache = new RedisCache<String, Map>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT),
5 * 60, String.class, Map.class);
@Value("${aws.elasticache.cluster.cursor.port}") final String REDIS_SEARCH_PORT,
@Value("${aws.elasticache.cluster.cursor.key}") final String REDIS_SEARCH_KEY,
@Value("${aws.elasticache.cluster.cursor.expiration}") final String INDEX_CACHE_EXPIRATION) {
cache = new RedisCache<String, Map>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT), REDIS_SEARCH_KEY,
Integer.parseInt(INDEX_CACHE_EXPIRATION) * 60, String.class, Map.class);
}
/**
......
......@@ -26,8 +26,9 @@ public class IndexCacheImpl implements IIndexCache<String, Boolean>, AutoCloseab
public IndexCacheImpl(@Value("${aws.elasticache.cluster.index.endpoint}") final String REDIS_SEARCH_HOST,
@Value("${aws.elasticache.cluster.index.port}") final String REDIS_SEARCH_PORT,
@Value("${aws.elasticache.cluster.index.key}") final String REDIS_SEARCH_KEY,
@Value("${aws.elasticache.cluster.index.expiration}") final String INDEX_CACHE_EXPIRATION) {
cache = new RedisCache<>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT),
cache = new RedisCache<>(REDIS_SEARCH_HOST, Integer.parseInt(REDIS_SEARCH_PORT), REDIS_SEARCH_KEY,
Integer.parseInt(INDEX_CACHE_EXPIRATION) * 60, String.class, Boolean.class);
}
......
......@@ -14,6 +14,9 @@
package org.opengroup.osdu.search.provider.aws.persistence;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import javax.annotation.PostConstruct;
......@@ -24,6 +27,7 @@ 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;
@Component
public class ElasticRepositoryImpl implements IElasticRepository {
......@@ -51,27 +55,32 @@ public class ElasticRepositoryImpl implements IElasticRepository {
@Value("${aws.elasticsearch.host}")
String hostParameter;
@Value("${aws.elasticsearch.username}")
String usernameParameter;
@Value("${aws.elasticsearch.credentials.secret}")
String elasticCredentialsSecret;
@Value("${aws.region}")
private String amazonRegion;
@Value("${aws.elasticsearch.password}")
String passwordParameter;
@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());
username = ssm.getProperty(usernameParameter).toString();
password = ssm.getProperty(passwordParameter).toString();
port = Integer.parseInt(ssm.getProperty(portParameter).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);
......
......@@ -14,6 +14,7 @@
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 org.opengroup.osdu.core.common.model.search.ClusterSettings;
......@@ -52,27 +53,31 @@ public class ElasticSettingServiceImpl implements IElasticSettingService {
@Value("${aws.elasticsearch.host}")
String hostParameter;
@Value("${aws.elasticsearch.username}")
String usernameParameter;
@Value("${aws.elasticsearch.credentials.secret}")
String elasticCredentialsSecret;
@Value("${aws.elasticsearch.password}")
String passwordParameter;
@Value("${aws.region}")
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());
username = ssm.getProperty(usernameParameter).toString();
password = ssm.getProperty(passwordParameter).toString();
port = Integer.parseInt(ssm.getProperty(portParameter).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);
......
......@@ -23,11 +23,12 @@ server.port=${APPLICATION_PORT:8080}
## AWS ElastiCache configuration
aws.elasticache.cluster.cursor.endpoint=${CACHE_CLUSTER_ENDPOINT}
aws.elasticache.cluster.cursor.port=${CACHE_CLUSTER_PORT}
aws.elasticache.cluster.cursor.key=${CACHE_CLUSTER_KEY}
aws.elasticache.cluster.cursor.expiration=60
aws.elasticache.cluster.index.endpoint=${CACHE_CLUSTER_ENDPOINT}
aws.elasticache.cluster.index.port=${CACHE_CLUSTER_PORT}
aws.elasticache.cluster.index.expiration=60
aws.elasticache.cluster.index.key=${CACHE_CLUSTER_KEY}
## Default Elasticsearch Settings
aws.es.host=${ELASTIC_HOST:}
aws.es.port=${ELASTIC_PORT:0}
......@@ -56,8 +57,7 @@ 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.username=${aws.ssm.prefix}/elasticsearch/username
aws.elasticsearch.password=${aws.ssm.prefix}/elasticsearch/password
aws.elasticsearch.credentials.secret=${aws.ssm.prefix}/elasticsearch/credentials
server.ssl.enabled=${SSL_ENABLED:true}
server.ssl.key-store-type=PKCS12
......@@ -72,3 +72,5 @@ service.policy.endpoint=${ENTITLEMENTS_BASE_URL}/api/policy/v1
service.policy.id=search
PARTITION_API=${ENTITLEMENTS_BASE_URL}/api/partition/v1
aws.environment=${ENVIRONMENT}
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
\ No newline at end of file
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