How to use the @cumulus/aws-client/StepFunctions.getExecutionHistory function in @cumulus/aws-client

To help you get started, we’ve selected a few @cumulus/aws-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nasa / cumulus / packages / api / lib / cwSfExecutionEventUtils.js View on Github external
const getFailedExecutionMessage = async (inputMessage) => {
  try {
    const executionArn = getMessageExecutionArn(inputMessage);
    const { events } = await StepFunctions.getExecutionHistory({ executionArn });

    const stepFailedEvents = events.filter(
      (event) =>
        ['ActivityFailed', 'LambdaFunctionFailed'].includes(event.type)
    );
    if (stepFailedEvents.length === 0) {
      log.info(`No failed step events found in execution ${executionArn}`);
      return inputMessage;
    }

    const lastStepFailedEvent = stepFailedEvents[stepFailedEvents.length - 1];
    const failedStepExitedEvent = getStepExitedEvent(events, lastStepFailedEvent);

    if (!failedStepExitedEvent) {
      log.info(
        `Could not retrieve output from last failed step in execution ${executionArn}, falling back to execution input`,