aws-cdk-lib.aws_stepfunctions.Map

class Map (construct)

LanguageType name
.NETAmazon.CDK.AWS.StepFunctions.Map
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#Map
Javasoftware.amazon.awscdk.services.stepfunctions.Map
Pythonaws_cdk.aws_stepfunctions.Map
TypeScript (source)aws-cdk-lib » aws_stepfunctions » Map

Implements IConstruct, IDependable, IChainable, INextable

Define a Map state in the state machine.

A Map state can be used to run a set of steps for each element of an input array. A Map state will execute the same steps for multiple entries of an array in the state input.

While the Parallel state executes multiple branches of steps using the same input, a Map state will execute the same steps for multiple entries of an array in the state input.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-map-state.html

Example

const map = new sfn.Map(this, 'Map State', {
  maxConcurrency: 1,
  itemsPath: sfn.JsonPath.stringAt('$.inputForMap'),
});
map.iterator(new sfn.Pass(this, 'Pass State'));

Initializer

new Map(scope: Construct, id: string, props?: MapProps)

Parameters

  • scope Construct
  • id string — Descriptive identifier for this chainable.
  • props MapProps

Construct Props

NameTypeDescription
comment?stringAn optional description for this state.
inputPath?stringJSONPath expression to select part of the state to be the input to this state.
itemsPath?stringJSONPath expression to select the array to iterate over.
maxConcurrency?numberMaxConcurrency.
outputPath?stringJSONPath expression to select part of the state to be the output to this state.
parameters?{ [string]: any }The JSON that you want to override your default iteration input.
resultPath?stringJSONPath expression to indicate where to inject the state's output.
resultSelector?{ [string]: any }The JSON that will replace the state's raw result and become the effective result before ResultPath is applied.

comment?

Type: string (optional, default: No comment)

An optional description for this state.


inputPath?

Type: string (optional, default: $)

JSONPath expression to select part of the state to be the input to this state.

May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}.


itemsPath?

Type: string (optional, default: $)

JSONPath expression to select the array to iterate over.


maxConcurrency?

Type: number (optional, default: full concurrency)

MaxConcurrency.

An upper bound on the number of iterations you want running at once.


outputPath?

Type: string (optional, default: $)

JSONPath expression to select part of the state to be the output to this state.

May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}.


parameters?

Type: { [string]: any } (optional, default: $)

The JSON that you want to override your default iteration input.


resultPath?

Type: string (optional, default: $)

JSONPath expression to indicate where to inject the state's output.

May also be the special value JsonPath.DISCARD, which will cause the state's input to become its output.


resultSelector?

Type: { [string]: any } (optional, default: None)

The JSON that will replace the state's raw result and become the effective result before ResultPath is applied.

You can use ResultSelector to create a payload with values that are static or selected from the state's raw result.

See also: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector

Properties

NameTypeDescription
endStatesINextable[]Continuable states of this Chainable.
idstringDescriptive identifier for this chainable.
nodeNodeThe tree node.
startStateStateFirst state of this Chainable.
stateIdstringTokenized string that evaluates to the state's ID.

endStates

Type: INextable[]

Continuable states of this Chainable.


id

Type: string

Descriptive identifier for this chainable.


node

Type: Node

The tree node.


startState

Type: State

First state of this Chainable.


stateId

Type: string

Tokenized string that evaluates to the state's ID.

Methods

NameDescription
addCatch(handler, props?)Add a recovery handler for this state.
addPrefix(x)Add a prefix to the stateId of this state.
addRetry(props?)Add retry configuration for this state.
bindToGraph(graph)Register this state as part of the given graph.
iterator(iterator)Define iterator state machine in Map.
next(next)Continue normal execution with the given state.
toStateJson()Return the Amazon States Language object for this state.
toString()Returns a string representation of this construct.
protected validateState()Validate this state.

addCatch(handler, props?)

public addCatch(handler: IChainable, props?: CatchProps): Map

Parameters

  • handler IChainable
  • props CatchProps

Returns

  • Map

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.


addPrefix(x)

public addPrefix(x: string): void

Parameters

  • x string

Add a prefix to the stateId of this state.


addRetry(props?)

public addRetry(props?: RetryProps): Map

Parameters

  • props RetryProps

Returns

  • Map

Add retry configuration for this state.

This controls if and how the execution will be retried if a particular error occurs.


bindToGraph(graph)

public bindToGraph(graph: StateGraph): void

Parameters

  • graph StateGraph

Register this state as part of the given graph.

Don't call this. It will be called automatically when you work with states normally.


iterator(iterator)

public iterator(iterator: IChainable): Map

Parameters

  • iterator IChainable

Returns

  • Map

Define iterator state machine in Map.


next(next)

public next(next: IChainable): Chain

Parameters

  • next IChainable

Returns

  • Chain

Continue normal execution with the given state.


toStateJson()

public toStateJson(): json

Returns

  • json

Return the Amazon States Language object for this state.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


protected validateState()

protected validateState(): string[]

Returns

  • string[]

Validate this state.