forked from Bardavon-Health/actions-aws-ssm-params-to-env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssm-helper.js
44 lines (40 loc) · 1.07 KB
/
ssm-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const AWS = require('aws-sdk');
const getParameters = async (ssmPath, getChildren, decryption, region) => {
AWS.config.update({region: region});
const ssm = new AWS.SSM();
let params;
const ssmParams = [];
let promise;
let nextToken;
while(!promise) {
if (getChildren)
{
params =
{
Path: ssmPath,
WithDecryption: decryption,
NextToken: nextToken
};
promise = ssm.getParametersByPath(params).promise();
}
else
{
params =
{
Names: [ssmPath],
WithDecryption: decryption,
NextToken: nextToken
};
promise = ssm.getParameters(params).promise();
}
const result = await promise;
ssmParams.push(...result.Parameters);
if (result.NextToken)
{
nextToken = result.NextToken;
promise = null;
}
}
return ssmParams;
}
module.exports = {getParameters};