'Basic Step function with error handling & SNS notification Improvement suggestions required

I have basic step function with error handling & SNS notification.

Need some suggestions &/or improvements and not sure if current process works.

Step1 glue job kicks off, If failed, needs to send SNS notification and do nothing.

If step1 glue job is successful then kick off Step2 glue job.

If step2 glue job is failed then SNS notification and done.

enter image description here

  "Comment": "A description of my state machine",
  "StartAt": "gluejob_step1",
  "States": {
    "gluejob_step1": {
      "Type": "Task",
      "Resource": "arn:aws:states:::glue:startJobRun.sync",
      "Parameters": {
        "JobName": "gluejob_step1"
      },
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "SNS Publish"
        }
      ],
      "Next": "gluejob_step2"
    },
    "gluejob_step2": {
      "Type": "Task",
      "Resource": "arn:aws:states:::glue:startJobRun.sync",
      "Parameters": {
        "JobName": "gluejob_step2"
      },
      "End": true,
      "Catch": [
        {
          "ErrorEquals": [
            "States.ALL"
          ],
          "Next": "SNS Publish"
        }
      ]
    },
    "SNS Publish": {
      "Type": "Task",
      "Resource": "arn:aws:states:::sns:publish",
      "Parameters": {
        "Message.$": "$"
      },
      "End": true
    }
  }
}


Solution 1:[1]

FWIW, I'm looking at a similar scenario. I don't have "best practices" to share but I've taken a very similar approach to you.

I've defined "Next" on the SNS step to go to a "fail" state so that the overall status is failed - which is a truer representation of what has actually happened.

"FailState": {
    "Type": "Fail"
}

Also, I have a requirement to update a sibling application of the failure so I've implemented a Lambda "in front" of the SNS step to fire a rest/http call. (Of course now I need to handle errors/failures there - :eyeroll:).

Best of luck, interested to see any other responses.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CPH