Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 2f5269e

Browse files
Update elasticsearch host to support elastic cloud since we are using enrich feature, which is unsupported by AWS ES
1 parent 07ea1ad commit 2f5269e

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Configuration for the application is at config/default.js and config/production.
3535
- UBAHN_UPDATE_TOPIC: Kafka topic for update message
3636
- UBAHN_DELETE_TOPIC: Kafka topic for delete message
3737
- UBAHN_AGGREGATE_TOPIC: Kafka topic that is used to combine all create, update and delete message(s)
38-
- ES.HOST: Elasticsearch host
38+
- ES_HOST: Elasticsearch host
3939
- ES.DOCUMENTS: Elasticsearch index, type and id mapping for resources.
4040
- ATTRIBUTE_GROUP_PIPELINE_ID: The pipeline id for enrichment with attribute group. Default is `attributegroup-pipeline`
4141
- SKILL_PROVIDER_PIPELINE_ID: The pipeline id for enrichment with skill provider. Default is `skillprovider-pipeline`
@@ -46,6 +46,9 @@ Configuration for the application is at config/default.js and config/production.
4646
- ACHIEVEMENT_PROVIDER_ENRICH_POLICYNAME: The enrich policy for achievement provider. Default is `achievementprovider-policy`
4747
- SKILL_ENRICH_POLICYNAME: The enrich policy for skill. Default is `skill-policy`
4848
- ATTRIBUTE_ENRICH_POLICYNAME: The enrich policy for skill. Default is `attribute-policy`
49+
- ELASTICCLOUD_ID: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
50+
- ELASTICCLOUD_USERNAME: The elastic cloud username for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
51+
- ELASTICCLOUD_PASSWORD: The elastic cloud password for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
4952

5053
For `ES.DOCUMENTS` configuration, you will find multiple other configurations below it. Each has default values that you can override using the environment variables
5154

config/default.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ module.exports = {
5151
// ElasticSearch
5252
ES: {
5353
HOST: process.env.ES_HOST || 'http://localhost:9200',
54+
55+
ELASTICCLOUD: {
56+
id: process.env.ELASTICCLOUD_ID,
57+
username: process.env.ELASTICCLOUD_USERNAME,
58+
password: process.env.ELASTICCLOUD_PASSWORD
59+
},
60+
5461
// es mapping: _index, _type, _id
5562
DOCUMENTS: {
5663
achievementprovider: {

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"@hapi/joi": "^16.1.8",
2020
"@hapi/joi-date": "^2.0.1",
2121
"amazon-qldb-driver-nodejs": "^0.1.1-preview.2",
22-
"aws-elasticsearch-connector": "^9.0.0",
2322
"aws-sdk": "^2.627.0",
2423
"axios": "^0.19.2",
2524
"body-parser": "^1.19.0",

src/common/es-client.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const config = require('config')
22
const AWS = require('aws-sdk')
33
const elasticsearch = require('@elastic/elasticsearch')
4-
const createAwsElasticsearchConnector = require('aws-elasticsearch-connector')
54

65
AWS.config.region = config.AWS_REGION
76

@@ -17,12 +16,18 @@ function getESClient () {
1716
return esClient
1817
}
1918
const host = config.ES.HOST
19+
const cloudId = config.ES.ELASTICCLOUD.id
2020
if (!esClient) {
21-
// AWS ES configuration is different from other providers
22-
if (/.*amazonaws.*/.test(host)) {
21+
if (cloudId) {
22+
// Elastic Cloud configuration
2323
esClient = new elasticsearch.Client({
24-
...createAwsElasticsearchConnector(AWS.config),
25-
node: host
24+
cloud: {
25+
id: cloudId
26+
},
27+
auth: {
28+
username: config.ES.ELASTICCLOUD.username,
29+
password: config.ES.ELASTICCLOUD.password
30+
}
2631
})
2732
} else {
2833
esClient = new elasticsearch.Client({

0 commit comments

Comments
 (0)