mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
add cache to ssm variables
This commit is contained in:
parent
7730a65d50
commit
de22ae698b
@ -23,6 +23,8 @@ class Variables {
|
||||
this.s3RefSyntax = RegExp(/^s3:(.+?)\/(.+)$/);
|
||||
this.stringRefSynax = RegExp(/('.*')|(".*")/g);
|
||||
this.ssmRefSyntax = RegExp(/^ssm:([a-zA-Z0-9_.\-/]+)[~]?(true|false)?/);
|
||||
|
||||
this.ssmCache = {}
|
||||
}
|
||||
|
||||
loadVariableSyntax() {
|
||||
@ -365,10 +367,13 @@ class Variables {
|
||||
}
|
||||
|
||||
getValueFromSsm(variableString) {
|
||||
const cached = this.ssmCache[variableString];
|
||||
if (cached) return cached;
|
||||
const groups = variableString.match(this.ssmRefSyntax);
|
||||
const param = groups[1];
|
||||
const decrypt = (groups[2] === 'true');
|
||||
return this.serverless.getProvider('aws')
|
||||
|
||||
const promise = this.serverless.getProvider('aws')
|
||||
.request('SSM',
|
||||
'getParameter',
|
||||
{
|
||||
@ -387,6 +392,8 @@ class Variables {
|
||||
return BbPromise.resolve(undefined);
|
||||
}
|
||||
);
|
||||
this.ssmCache[variableString] = promise;
|
||||
return promise;
|
||||
}
|
||||
|
||||
getDeepValue(deepProperties, valueToPopulate) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user