Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(aws-stepfunctions): Support dynamic Task timeouts (TimeoutSecondsPath/HeartbeatSecondsPath)

See original GitHub issue

Amazon States Language supports dynamic Task state timeout and heartbeat configurations by the TimeoutSecondsPath and HeartbeatSecondsPath properties respectively. TimeoutSecondsPath has the same effect as TimeoutSeconds but reads the seconds value at runtime from the state input using JSONPath. This is not supported in CDK without a CustomState.

Use Case

Allows CDK users to specify Task state timeout and heartbeat settings at runtime instead of hardcoding static values in the state machine definition.

Proposed Solution

  • Option 1 - Expose explicit timeoutPath and heartbeatPath in TaskBaseProps
const myTask = new EcsRunTask(scope, "MyTask", {
    timeoutPath: JsonPath.numberAt("$.myTimeoutInSeconds")

// OR

const myTask = new EcsRunTask(scope, "MyTask", {
    timeoutPath: "$.myTimeoutInSeconds"
  • Option 2 - Use the existing timeout and heartbeat properties and append “Path” to the generated ASL if the provided value is JSONPath, similar to how Parameters works in json-path.ts
const myTask = new EcsRunTask(scope, "MyTask", {
    timeout: JsonPath.numberAt("$.myTimeoutInSeconds")

Both would render the same ASL:

  "Type": "Task",
  "Resource": "...",
  "TimeoutSecondsPath": "$.myTimeoutInSeconds",


  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

natenezcommented, Jul 19, 2021

+1 on this feature request. I am developing a new step function and need to use the heartbeatPath since a compile time heartbeat isn’t appropriate. I’ll give the work around a try until the feature is available.

mzyilcommented, Mar 8, 2022

Here is a workaround that does not break the synth

  let renderer: any = LambdaInvoke.prototype["renderTaskBase"];
  LambdaInvoke.prototype["renderTaskBase"] = function () {
    let result = renderer.apply(this);
    let timeoutSecondsPath = (this as any)["timeoutSecondsPath"];
    if (timeoutSecondsPath) {
      result["TimeoutSecondsPath"] = timeoutSecondsPath;
    return result;


(theStep as any)["timeoutSecondsPath"] = JsonPath.stringAt("$.somePath")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use timeouts to avoid stuck executions - AWS Step Functions
If something goes wrong and the TimeoutSeconds field isn't specified for an Activity or Task state, an execution is stuck waiting for a...
Read more >
How to add dynamic TimeoutSeconds for activity in AWS ...
I have an activity in step function with TimeoutSeconds , like this: ActivityWaiting: Type: Task ...
Read more >
Dynamic Task Mapping — Airflow Documentation
Dynamic Task Mapping allows a way for a workflow to create a number of tasks at runtime based upon current data, rather than...
Read more >
AWS Step Functions: Handling errors - YouTube
In this session, viewers learn how to use AWS Step Functions workflows to handle errors in their serverless applications.
Read more >
Standard Task With Timeout (External Forms) activity
This activity is often used for time-based escalations. For example, if a Tier 1 Customer Support representative does not answer a support query...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found