class Chain
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.StepFunctions.Chain |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#Chain |
Java | software.amazon.awscdk.services.stepfunctions.Chain |
Python | aws_cdk.aws_stepfunctions.Chain |
TypeScript (source) | aws-cdk-lib » aws_stepfunctions » Chain |
Implements
IChainable
A collection of states to chain onto.
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
Example
const map = new sfn.Map(this, 'Map State', {
maxConcurrency: 1,
itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
itemSelector: {
item: sfn.JsonPath.stringAt('$$.Map.Item.Value'),
},
resultPath: '$.mapOutput',
});
// The Map iterator can contain a IChainable, which can be an individual or multiple steps chained together.
// Below example is with a Choice and Pass step
const choice = new sfn.Choice(this, 'Choice');
const condition1 = sfn.Condition.stringEquals('$.item.status', 'SUCCESS');
const step1 = new sfn.Pass(this, 'Step1');
const step2 = new sfn.Pass(this, 'Step2');
const finish = new sfn.Pass(this, 'Finish');
const definition = choice
.when(condition1, step1)
.otherwise(step2)
.afterwards()
.next(finish);
map.itemProcessor(definition);
Properties
Name | Type | Description |
---|---|---|
end | INextable [] | The chainable end state(s) of this chain. |
id | string | Identify this Chain. |
start | State | The start state of this chain. |
endStates
Type:
INextable
[]
The chainable end state(s) of this chain.
id
Type:
string
Identify this Chain.
startState
Type:
State
The start state of this chain.
Methods
Name | Description |
---|---|
next(next) | Continue normal execution with the given state. |
to | Return a single state that encompasses all states in the chain. |
static custom(startState, endStates, lastAdded) | Make a Chain with specific start and end states, and a last-added Chainable. |
static sequence(start, next) | Make a Chain with the start from one chain and the ends from another. |
static start(state) | Begin a new Chain from one chainable. |
next(next)
public next(next: IChainable): Chain
Parameters
- next
IChainable
Returns
Continue normal execution with the given state.
SingleState(id, props?)
topublic toSingleState(id: string, props?: ParallelProps): Parallel
Parameters
- id
string
- props
Parallel
Props
Returns
Return a single state that encompasses all states in the chain.
This can be used to add error handling to a sequence of states.
Be aware that this changes the result of the inner state machine to be an array with the result of the state machine in it. Adjust your paths accordingly. For example, change 'outputPath' to '$[0]'.
static custom(startState, endStates, lastAdded)
public static custom(startState: State, endStates: INextable[], lastAdded: IChainable): Chain
Parameters
- startState
State
- endStates
INextable
[]
- lastAdded
IChainable
Returns
Make a Chain with specific start and end states, and a last-added Chainable.
static sequence(start, next)
public static sequence(start: IChainable, next: IChainable): Chain
Parameters
- start
IChainable
- next
IChainable
Returns
Make a Chain with the start from one chain and the ends from another.
static start(state)
public static start(state: IChainable): Chain
Parameters
- state
IChainable
Returns
Begin a new Chain from one chainable.