Step Function to Send Email on Error/Success

0

Dear Sir/Madam,

We have a couple of Step Functions running on a weekly basis, and we would like to know right after a Step Function encounter an error. Hence we place a "Send Email" Task (Amazon Pin Point Email Service) before the fail State.All the main task's error handling will Catch any error and continue the the "Send Email" State before failing the Step Function.

in side the "Send Email" configuration, there is one API Parameters field, and i filled it in with :

{
  "Content": {
    "Body": {
      "Text": {
        "Data": "ERROR"
      }
    },
    "Subject": {
      "Data": "ERROR"
    }
  },
  "Source": "source@me.com",
  "Destination": {
    "ToAddresses": [
      "notify@me.com"
    ]
  }
}

However, when i try to save the state machine, i got an error saying: The field "Body" is not supported by Step Functions It seems like i dont know what need to be fill inside the API Parameters for Send Email task, unfortunately i cant find any reference for it.

May i ask where to read up or refer for Step Function Send Email?

4개 답변
1

If you want to get a notification on the Step Function execution failure (or even successful runs), you can setup a CloudWatch rule to monitor the execution status and then set the target as SNS topic to send an email when the rule is triggered.

More information can be found here: https://aws.amazon.com/blogs/developer/handling-errors-retries-and-adding-alerting-to-step-function-state-machine-executions/

profile picture
joahna
답변함 2년 전
  • This solution is workable, since no code required.
    However, i wonder if anybody know how to use the Step Function Sent Email Task at all (it is more powerful since it is part of the step function)?

0
profile picture
Sri
답변함 2년 전
  • The above is using Lambda. What about directly from Step Function "Send Email" task?

0

You need to follow the structure of SES API V2 https://docs.aws.amazon.com/ses/latest/APIReference-V2/API_SendEmail.html

In your case you are sending a Simple email:

{
    "Content": {
        "Simple": {
            "Body": {
                "Text": {
                    "Data": "ERROR"
                }
            },
            "Subject": {
                "Data": "ERROR"
            }
        }
    },
    "Source": "source@me.com",
    "Destination": {
        "ToAddresses": [
            "notify@me.com"
        ]
    }
}
AWS
답변함 일 년 전
0

I ran into this today. The SES API V2 endpoint for state machines seems broken; I couldn't add Destination, which makes it pointless. I messed around with the GUI builder and could generate something that worked from a step using ses v1.

  "SendEmail": {
    "Type": "Task",
    "Resource": "arn:aws:states:::aws-sdk:ses:sendEmail",
    "Next": "Failure",
    "Parameters": {
      "Source": "from-email",
      "Message": {
        "Body": {
          "Text": {
            "Data": "text"
          }
        },
        "Subject": {
          "Data": "subject"
        }
      },
      "Destination": {
        "ToAddresses": []
      }
    }
  }
답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠