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
) –props –
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 pass a collection of keyvalue pairs, either static values or JSONPath expressions that select from the input. Default: No parametersresult_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
) –props –
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
props –
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, *, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Return the given named metric for this Task.
 Parameters
metric_name (
str
) –props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_failed
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times this activity fails.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_heartbeat_timed_out
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times the heartbeat times out for this activity.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_run_time
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ The interval, in milliseconds, between the time the Task starts and the time it closes.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_schedule_time
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ The interval, in milliseconds, for which the activity stays in the schedule state.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_scheduled
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times this activity is scheduled.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_started
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times this activity is started.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_succeeded
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times this activity succeeds.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: sum over 5 minutes
stability :stability: experimental
 Return type

metric_time
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ The interval, in milliseconds, between the time the activity is scheduled and the time it closes.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
default :default: average over 5 minutes
stability :stability: experimental
 Return type

metric_timed_out
(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)¶ Metric for the number of times this activity times out.
 Parameters
props –
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)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 for the metric that is associated with the alarm.
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
) –options –
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
