title: How to pass AWS Lambda error in AWS SNS notification through AWS Step Functions?
body: <p>I have created an AWS Step Function which triggers a Lambda python code, terminates without error if Lambda succeeds, otherwise calls an SNS topic to message the subscribed users if the Lambda fails. It is running, but the message was fixed. The Step Function JSON is as follows:</p>
  <pre><code>{
    &quot;StartAt&quot;: &quot;Lambda Trigger&quot;,
    &quot;States&quot;: {
      &quot;Lambda Trigger&quot;: {
        &quot;Type&quot;: &quot;Task&quot;,
        &quot;Resource&quot;: &quot;arn:aws:lambda:us-east-2:xxxxxxxxxxxx:function:helloworldTest&quot;,
        &quot;End&quot;: true,
        &quot;Catch&quot;: [
          {
            &quot;ErrorEquals&quot;: [
              &quot;States.ALL&quot;
            ],
            &quot;ResultPath&quot;: &quot;$.error&quot;,
            &quot;Next&quot;: &quot;Notify Failure&quot;
          }
        ]
      },
      &quot;Notify Failure&quot;: {
        &quot;Type&quot;: &quot;Task&quot;,
        &quot;Resource&quot;: &quot;arn:aws:states:::sns:publish&quot;,
        &quot;Parameters&quot;: {
          &quot;Message&quot;: &quot;Batch job submitted through Step Functions failed with the following error, $.error&quot;,
          &quot;TopicArn&quot;: &quot;arn:aws:sns:us-east-2:xxxxxxxxxxxx:lambda-execution-failure&quot;
        },
        &quot;End&quot;: true
      }
    }
  }
  </code></pre>
  <p>Only thing is, I want to append the failure error message to my message string, which I tried, but is not working as expected.</p>
  <p><a href="https://i.stack.imgur.com/cEIX4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cEIX4.png" alt="Eg: The step function run on failure" /></a></p>
  <p>But I get a mail as follows:</p>
  <p><a href="https://i.stack.imgur.com/HK3ES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HK3ES.png" alt="Mail Received" /></a></p>
  <p>How to go about it?</p>