in source/services/queue-consumer/index.ts [147:172]
async function getNumberOfActiveStepsForAutomationId(automationID: string, maxResults: number): Promise<number> {
const ssmParams: AWS.SSM.DescribeAutomationStepExecutionsRequest = {
AutomationExecutionId: automationID,
Filters: [{ Key: 'StepExecutionStatus', 'Values': SSM_ACTIVE_AND_PENDING_STATUSES }],
MaxResults: maxResults
};
let data: AWS.SSM.DescribeAutomationStepExecutionsResult = null;
try {
data = await ssm.describeAutomationStepExecutions(ssmParams).promise();
} catch (err) {
logger.error(`SSM returned an error while looking up the number of active/pending automation steps for AutomationExecutionId: ${automationID}`);
throw (err);
}
if (!data) {
logger.error(`SSM did not return a valid response to ssm.describeAutomationStepExecutions when looking up the number of active/pending automation steps for AutomationExecutionId: ${automationID}`);
throw (new Error(`Issue while looking up the number of active/pending automation steps for AutomationExecutionId: ${automationID}`));
} else if (!data.StepExecutions) {
logger.error(`In the response from ssm.describeAutomationStepExecutions, StepExecutions array was empty or did not exist when looking up the number of active/pending automation steps for AutomationExecutionId: ${automationID}`);
throw (new Error(`Issue while looking up the number of active/pending automation steps for AutomationExecutionId: ${automationID}`));
}
return data.StepExecutions.length;
}