title: Retry logic in AWS step function
body: <p>I am testing the retry logic of the step function.
  Theoretically following step function should have been retried to execute the lambda 3 times if it fails.</p>
  <pre><code>{
    &quot;StartAt&quot;: &quot;Bazinga&quot;,
    &quot;States&quot;: {
      &quot;Bazinga&quot;: {
        &quot;Type&quot;: &quot;Task&quot;,
        &quot;Resource&quot;: &quot;arn:aws:states:::lambda:invoke&quot;,
        &quot;Parameters&quot;: {
          &quot;FunctionName&quot;: &quot;arn:aws:lambda:ap-southeast-2:518815385770:function:errorTest:$LATEST&quot;,
          &quot;Payload&quot;: {
            &quot;Input.$&quot;: &quot;$&quot;
          }
        },
        &quot;Retry&quot; : [
          {
            &quot;ErrorEquals&quot;: [ &quot;States.All&quot;, &quot;States.Timeout&quot; ],
            &quot;IntervalSeconds&quot;: 1,
            &quot;MaxAttempts&quot;: 3,
            &quot;BackoffRate&quot;: 1.0
          }
        ],
         &quot;Next&quot;: &quot;Fail&quot;
      },
      &quot;Fail&quot;: {
        &quot;Type&quot;: &quot;Fail&quot;
      }
    }
  }
  </code></pre>
  <p>The lambda it calls is set to timeout in 3 seconds. The lambda freezes for 4 seconds. This means the lambda times out and throws <code> States.Timeout</code> error. The code is given below:</p>
  <pre class="lang-js prettyprint-override"><code>function sleep(ms){
      return new Promise(resolve=&gt;{
          setTimeout(resolve,ms)
      })
  }
  
  exports.handler = async (event) =&gt; {
      console.log('------------&gt; executing ....')
      await sleep(4000)
  };
  
  </code></pre>
  <p>The problem is step function does not retry the task. This can be confirmed from the following <code>CloudWatch</code> logs.</p>
  <pre><code>
  05:59:36
  START RequestId: dd1a2ee9-f389-44be-aaa6-07f2ca7983b0 Version: $LATEST
  
  05:59:36
  2019-07-24T05:59:36.340Z dd1a2ee9-f389-44be-aaa6-07f2ca7983b0 INFO ------------&gt; executing ....
  
  05:59:39
  END RequestId: dd1a2ee9-f389-44be-aaa6-07f2ca7983b0
  
  05:59:39
  REPORT RequestId: dd1a2ee9-f389-44be-aaa6-07f2ca7983b0 Duration: 3003.29 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 26 MB
  
  05:59:39
  2019-07-24T05:59:39.317Z dd1a2ee9-f389-44be-aaa6-07f2ca7983b0 Task timed out after 3.00 seconds 
  </code></pre>
  <p>Not sure what went wrong. Any help is appreciated, thanks in advance.</p>