Task¶

class
aws_cdk.aws_stepfunctions.
Task
(scope, id, *, task, comment=None, input_path=None, output_path=None, parameters=None, result_path=None, timeout=None)¶ Bases:
aws_cdk.aws_stepfunctions.State
Define a Task state in the state machine.
Reaching a Task state causes some work to be executed, represented by the Task’s resource property. Task constructs represent a generic Amazon States Language Task.
For some resource types, more specific subclasses of Task may be available which are more convenient to use.
stability :stability: experimental

__init__
(scope, id, *, task, comment=None, input_path=None, output_path=None, parameters=None, result_path=None, timeout=None)¶  Parameters
scope (
Construct
) –id (
str
) –task (
IStepFunctionsTask
) – Actual task to be invoked in this workflow.comment (
Optional
[str
]) – An optional description for this state. Default: No commentinput_path (
Optional
[str
]) – JSONPath expression to select part of the state to be the input to this state. May also be the special value DISCARD, which will cause the effective input to be the empty object {}. Default: $output_path (
Optional
[str
]) – JSONPath expression to select part of the state to be the output to this state. May also be the special value DISCARD, which will cause the effective output to be the empty object {}. Default: $parameters (
Optional
[Mapping
[str
,Any
]]) – Parameters to invoke the task with. It is not recommended to use this field. The object that is passed in thetask
property will take care of returning the right values for theParameters
field in the Step Functions definition. The various classes that implementIStepFunctionsTask
will take a properties which make sense for the task type. For example, forInvokeFunction
the field that populates theparameters
field will be calledpayload
, and for thePublishToTopic
theparameters
field will be populated via a combination of the referenced topic, subject and message. If passed anyway, the keys in this map will override the parameters returned by the task object. Default:  Use the parameters implied by thetask
propertyresult_path (
Optional
[str
]) – JSONPath expression to indicate where to inject the state’s output. May also be the special value DISCARD, which will cause the state’s input to become its output. Default: $timeout (
Optional
[Duration
]) – Maximum run time of this state. If the state takes longer than this amount of time to complete, a ‘Timeout’ error is raised. Default: 60
stability :stability: experimental
 Return type
None
Methods

add_catch
(handler, *, errors=None, result_path=None)¶ Add a recovery handler for this state.
When a particular error occurs, execution will continue at the error handler instead of failing the state machine execution.
 Parameters
handler (
IChainable
) –errors (
Optional
[List
[str
]]) – Errors to recover from by going to the given state. A list of error strings to retry, which can be either predefined errors (for example Errors.NoChoiceMatched) or a selfdefined error. Default: All errorsresult_path (
Optional
[str
]) – JSONPath expression to indicate where to inject the error data. May also be the special value DISCARD, which will cause the error data to be discarded. Default: $
stability :stability: experimental
 Return type

add_prefix
(x)¶ Add a prefix to the stateId of this state.
 Parameters
x (
str
) –
stability :stability: experimental
 Return type
None

add_retry
(*, backoff_rate=None, errors=None, interval=None, max_attempts=None)¶ Add retry configuration for this state.
This controls if and how the execution will be retried if a particular error occurs.
 Parameters
backoff_rate (
Union
[int
,float
,None
]) – Multiplication for how much longer the wait interval gets on every retry. Default: 2errors (
Optional
[List
[str
]]) – Errors to retry. A list of error strings to retry, which can be either predefined errors (for example Errors.NoChoiceMatched) or a selfdefined error. Default: All errorsinterval (
Optional
[Duration
]) – How many seconds to wait initially before retrying. Default: Duration.seconds(1)max_attempts (
Union
[int
,float
,None
]) – How many times to retry this particular error. May be 0 to disable retry for specific errors (in case you have a catchall retry policy). Default: 3
stability :stability: experimental
 Return type

bind_to_graph
(graph)¶ Register this state as part of the given graph.
Don’t call this. It will be called automatically when you work with states normally.
 Parameters
graph (
StateGraph
) –
stability :stability: experimental
 Return type
None

metric
(metric_name, *, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Return the given named metric for this Task.
 Parameters
metric_name (
str
) –account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_failed
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times this activity fails.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_heartbeat_timed_out
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times the heartbeat times out for this activity.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_run_time
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ The interval, in milliseconds, between the time the Task starts and the time it closes.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_schedule_time
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ The interval, in milliseconds, for which the activity stays in the schedule state.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_scheduled
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times this activity is scheduled.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_started
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times this activity is started.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_succeeded
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times this activity succeeds.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_time
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ The interval, in milliseconds, between the time the activity is scheduled and the time it closes.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_timed_out
(*, account=None, color=None, dimensions=None, label=None, period=None, region=None, statistic=None, unit=None)¶ Metric for the number of times this activity times out.
 Parameters
account (
Optional
[str
]) – Account which this metric comes from. Default: Deployment account.color (
Optional
[str
]) – Color for this metric when added to a Graph in a Dashboard.dimensions (
Optional
[Mapping
[str
,Any
]]) – Dimensions of the metric. Default:  No dimensions.label (
Optional
[str
]) – Label for this metric when added to a Graph in a Dashboard.period (
Optional
[Duration
]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)region (
Optional
[str
]) – Region which this metric comes from. Default: Deployment region.statistic (
Optional
[str
]) – What function to use for aggregating. Can be one of the following:  “Minimum”  “min”  “Maximum”  “max”  “Average”  “avg”  “Sum”  “sum”  “SampleCount  “n”  “pNN.NN” Default: Averageunit (
Optional
[Unit
]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: All metric datums in the given metric stream
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

next
(next)¶ Continue normal execution with the given state.
 Parameters
next (
IChainable
) –
stability :stability: experimental
 Return type

to_state_json
()¶ Return the Amazon States Language object for this state.
stability :stability: experimental
 Return type
Mapping
[Any
,Any
]

to_string
()¶ Returns a string representation of this construct.
 Return type
str
Attributes

end_states
¶ Continuable states of this Chainable.
stability :stability: experimental
 Return type
List
[INextable
]

id
¶ Descriptive identifier for this chainable.
stability :stability: experimental
 Return type
str

node
¶ Construct tree node which offers APIs for interacting with the construct tree.
 Return type

state_id
¶ Tokenized string that evaluates to the state’s ID.
stability :stability: experimental
 Return type
str
Static Methods

classmethod
filter_nextables
(states)¶ Return only the states that allow chaining from an array of states.
 Parameters
states (
List
[State
]) –
stability :stability: experimental
 Return type
List
[INextable
]

classmethod
find_reachable_end_states
(start, *, include_error_handlers=None)¶ Find the set of end states states reachable through transitions from the given start state.
 Parameters
start (
State
) –include_error_handlers (
Optional
[bool
]) – Whether or not to follow errorhandling transitions. Default: false
stability :stability: experimental
 Return type
List
[State
]

classmethod
is_construct
(x)¶ Return whether the given object is a Construct.
 Parameters
x (
Any
) – Return type
bool

classmethod
prefix_states
(root, prefix)¶ Add a prefix to the stateId of all States found in a construct tree.
 Parameters
root (
IConstruct
) –prefix (
str
) –
stability :stability: experimental
 Return type
None
