Skip to content

Commit

Permalink
Merge pull request #3 from Kitsumon/a
Browse files Browse the repository at this point in the history
Update ssm-helper.js
  • Loading branch information
JayArrowz committed Apr 17, 2023
2 parents 2d04d53 + c2eb5a8 commit 4a853e6
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions ssm-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,41 @@ const getParameters = async (ssmPath, getChildren, decryption, region) => {
AWS.config.update({region: region});
const ssm = new AWS.SSM();
let params;
const ssmParams = [];

let promise;
if (getChildren)
{
params =
let nextToken;
while(!promise) {
if (getChildren)
{
Path: ssmPath,
WithDecryption: decryption
};
promise = ssm.getParametersByPath(params).promise();
}
else
{
params =
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)
{
Names: [ssmPath],
WithDecryption: decryption
};
promise = ssm.getParameters(params).promise();;
nextToken = result.NextToken;
promise = null;
}
}
const result = await promise;
return result.Parameters;
return ssmParams;
}

module.exports = {getParameters};

0 comments on commit 4a853e6

Please sign in to comment.