Class Chain
A collection of states to chain onto.
Implements
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Chain : DeputyBase, IChainable
Syntax (vb)
Public Class Chain Inherits DeputyBase Implements IChainable
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Examples
var map = new Map(this, "Map State", new MapProps {
MaxConcurrency = 1,
ItemsPath = JsonPath.StringAt("$.inputForMap"),
ItemSelector = new Dictionary<string, object> {
{ "item", 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
var choice = new Choice(this, "Choice");
var condition1 = Condition.StringEquals("$.item.status", "SUCCESS");
var step1 = new Pass(this, "Step1");
var step2 = new Pass(this, "Step2");
var finish = new Pass(this, "Finish");
var definition = choice.When(condition1, step1).Otherwise(step2).Afterwards().Next(finish);
map.ItemProcessor(definition);
Synopsis
Properties
| EndStates | The chainable end state(s) of this chain. |
| Id | Identify this Chain. |
| StartState | The start state of this chain. |
Methods
| Custom(State, INextable[], IChainable) | Make a Chain with specific start and end states, and a last-added Chainable. |
| Next(IChainable) | Continue normal execution with the given state. |
| Sequence(IChainable, IChainable) | Make a Chain with the start from one chain and the ends from another. |
| Start(IChainable) | Begin a new Chain from one chainable. |
| ToSingleState(string, IParallelProps?) | Return a single state that encompasses all states in the chain. |
Properties
EndStates
The chainable end state(s) of this chain.
public virtual INextable[] EndStates { get; }
Property Value
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Id
Identify this Chain.
public virtual string Id { get; }
Property Value
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
StartState
The start state of this chain.
public virtual State StartState { get; }
Property Value
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Methods
Custom(State, INextable[], IChainable)
Make a Chain with specific start and end states, and a last-added Chainable.
public static Chain Custom(State startState, INextable[] endStates, IChainable lastAdded)
Parameters
- startState State
- endStates INextable[]
- lastAdded IChainable
Returns
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Next(IChainable)
Continue normal execution with the given state.
public virtual Chain Next(IChainable next)
Parameters
- next IChainable
Returns
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Sequence(IChainable, IChainable)
Make a Chain with the start from one chain and the ends from another.
public static Chain Sequence(IChainable start, IChainable next)
Parameters
- start IChainable
- next IChainable
Returns
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
Start(IChainable)
Begin a new Chain from one chainable.
public static Chain Start(IChainable state)
Parameters
- state IChainable
Returns
Remarks
A Chain has a start and zero or more chainable ends. If there are zero ends, calling next() on the Chain will fail.
ExampleMetadata: infused
ToSingleState(string, IParallelProps?)
Return a single state that encompasses all states in the chain.
public virtual Parallel ToSingleState(string id, IParallelProps? props = null)
Parameters
- id string
- props IParallelProps
Returns
Remarks
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]'.