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

Commit 8a86454

Browse files
Fix issue where elasticsearch would not connect
1 parent 1001b49 commit 8a86454

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
coverage
44

55
.DS_Store
6+
.env

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"aws-sdk": "^2.476.0",
3131
"bluebird": "^3.5.5",
3232
"config": "^3.1.0",
33-
"elasticsearch": "^16.1.1",
33+
"elasticsearch": "^16.7.1",
3434
"get-parameter-names": "^0.3.0",
3535
"http-aws-es": "^6.0.0",
3636
"lodash": "^4.17.15",

src/common/helper.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@ async function getESClient () {
3333
if (esClient) {
3434
return esClient
3535
}
36-
const hosts = config.ES.HOST
36+
const host = config.ES.HOST
3737
const apiVersion = config.ES.API_VERSION
3838

3939
// AWS ES configuration is different from other providers
40-
if (/.*amazonaws.*/.test(hosts)) {
41-
esClient = new elasticsearch.Client({
42-
apiVersion,
43-
hosts,
44-
connectionClass: require('http-aws-es'), // eslint-disable-line global-require
45-
amazonES: {
46-
region: config.ES.AWS_REGION,
47-
credentials: new AWS.EnvironmentCredentials('AWS')
48-
}
49-
})
40+
if (/.*amazonaws.*/.test(host)) {
41+
try {
42+
esClient = new elasticsearch.Client({
43+
apiVersion,
44+
host,
45+
connectionClass: require('http-aws-es') // eslint-disable-line global-require
46+
})
47+
} catch (error) { console.log(error) }
5048
} else {
5149
esClient = new elasticsearch.Client({
5250
apiVersion,
53-
hosts
51+
host
5452
})
5553
}
5654
return esClient

0 commit comments

Comments
 (0)