State
The State class is the base class for all states in StepFunctions state
machine.
This is used for reference only.
Constructor
new State(args)Parameters
-
argsStateArgs
StateArgs
assign?
Type Record<string, any>
Store variables that can be accessed by any state later in the workflow, instead of passing it through each state.
This takes a set of key/value pairs. Where the key is the name of the variable that can be accessed by any subsequent state.
The value can be any JSON value; object, array, string, number, boolean, null.
{ assign: { productName: "product1", count: 42, available: true }}Or, you can pass in a JSONata expression.
{ assign: { product: "{% $states.input.order.product %}", currentPrice: "{% $states.result.Payload.current_price %}" }}Learn more about passing data between states with variables.
name
Type string
The name of the state. This needs to be unique within the state machine.
output?
Type Input<Record<string, any> | “{% ${string} %}”>
Transform the output of the state. When specified, the value overrides the default output from the state.
This takes any JSON value; object, array, string, number, boolean, null.
{ output: { charged: true }}Or, you can pass in a JSONata expression.
{ output: { product: "{% $states.input.product %}" }}Learn more about transforming data with JSONata.
CatchArgs
errors?
Type string[]
Default [“States.ALL”]
A list of errors that are being caught. By default, this catches all errors.
RetryArgs
backoffRate?
Type number
Default 2
The backoff rate. This is a multiplier that increases the interval between retries.
For example, if the interval is 1 second and the backoff rate is 2, the
first retry will happen after 1 second, and the second retry will happen
after 2 * 1 second = 2 seconds.
errors?
Type string[]
Default [“States.ALL”]
A list of errors that are being retried. By default, this retries all errors.
interval?
Type “${number} minute” | “${number} minutes” | “${number} hour” | “${number} hours” | “${number} second” | “${number} seconds” | “${number} day” | “${number} days”
Default “1 second”
The amount of time to wait before the first retry attempt. The maximum value is
99999999 seconds.
Following attempts will retry based on the backoffRate multiplier.
maxAttempts?
Type number
Default 3
The maximum number of retries before it falls back to the normal error handling.
A value of 0 means the error won’t be retried. The maximum value is
99999999.