@coast/dynamic-config
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -17,2 +17,4 @@ "use strict"; | ||
this.configuration = {}; | ||
this.options.ssmMaxParams = this.options.ssmMaxParams !== undefined ? Math.min(this.options.ssmMaxParams, 10) : 10; | ||
this.options.skipSsm = this.options.skipSsm !== undefined ? this.options.skipSsm : false; | ||
} | ||
@@ -35,3 +37,3 @@ /** | ||
const missingEntries = this.getAllUnsetKeys(allKeys, entries); | ||
if (missingEntries.length > 0) { | ||
if (missingEntries.length > 0 && !this.options.skipSsm) { | ||
await this.loadFromSsm(missingEntries, dotEnvParse, entries); | ||
@@ -71,6 +73,12 @@ } | ||
}); | ||
const response = await this.ssmClient.getParameters({ Names: pathPrefixedEntries }).promise(); | ||
response.Parameters?.forEach((parameter) => { | ||
entries[parameter.Name] = parameter.Value; | ||
}); | ||
const splitNames = []; | ||
while (pathPrefixedEntries.length > 0) { | ||
splitNames.push(pathPrefixedEntries.splice(0, this.options.ssmMaxParams)); | ||
} | ||
for (const names of splitNames) { | ||
const response = await this.ssmClient.getParameters({ Names: names, WithDecryption: true }).promise(); | ||
response.Parameters?.forEach((parameter) => { | ||
entries[parameter.Name] = parameter.Value; | ||
}); | ||
} | ||
} | ||
@@ -77,0 +85,0 @@ getAllUnsetKeys(allKeys, entries) { |
@@ -8,2 +8,4 @@ /// <reference types="hapi__joi" /> | ||
* @property envFilePath: Path to a dotenv file. Ignored if file is not found | ||
* @property skipSsm: if true we will not attemp to use ssm at all | ||
* @property ssmMaxParams: testing only, default = 10 | ||
* @property ssmPaths: optional array of paths. Ex ['staging', 'core-api'] will lookup params at '/staging/core-api/.' | ||
@@ -15,5 +17,7 @@ * @property allowUnknownVariables: Allow variables not specified in the schema. | ||
schema: ObjectSchema; | ||
skipSsm?: boolean; | ||
ssmPaths?: string[]; | ||
ssmMaxParams?: number; | ||
envFilePath?: string; | ||
ssmPaths?: string[]; | ||
allowUnknownVariables?: boolean; | ||
} |
{ | ||
"name": "@coast/dynamic-config", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
12224
158