class DistributedMap (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.StepFunctions.DistributedMap |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsstepfunctions#DistributedMap |
Java | software.amazon.awscdk.services.stepfunctions.DistributedMap |
Python | aws_cdk.aws_stepfunctions.DistributedMap |
TypeScript (source) | aws-cdk-lib » aws_stepfunctions » DistributedMap |
Implements
IConstruct
, IDependable
, IChainable
, INextable
Define a Distributed Mode 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.
A Map
state in Distributed
mode will execute a child workflow for each iteration of the Map state.
This serves to increase concurrency and allows for larger workloads to be run in a single state machine.
See also: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-asl-use-map-state-distributed.html
Example
const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', {
mapExecutionType: sfn.StateMachineType.EXPRESS, // mapExecutionType property is applied.
});
distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'), {
mode: sfn.ProcessorMode.DISTRIBUTED,
executionType: sfn.ProcessorType.STANDARD, // ProcessorConfig.executionType is ignored
});
Initializer
new DistributedMap(scope: Construct, id: string, props?: DistributedMapProps)
Parameters
- scope
Construct
- id
string
— Descriptive identifier for this chainable. - props
Distributed
Map Props
Construct Props
Name | Type | Description |
---|---|---|
comment? | string | An optional description for this state. |
input | string | JSONPath expression to select part of the state to be the input to this state. |
item | Item | Specifies to process a group of items in a single child workflow execution. |
item | IItem | ItemReader. |
item | { [string]: any } | The JSON that you want to override your default iteration input (mutually exclusive with parameters ). |
items | string | JSONPath expression to select the array to iterate over. |
label? | string | Label. |
map | State | MapExecutionType. |
max | number | MaxConcurrency. |
max | string | MaxConcurrencyPath. |
output | string | JSONPath expression to select part of the state to be the output to this state. |
result | string | JSONPath expression to indicate where to inject the state's output. |
result | { [string]: any } | The JSON that will replace the state's raw result and become the effective result before ResultPath is applied. |
result | Result | Configuration for S3 location in which to save Map Run results. |
state | string | Optional name for this state. |
tolerated | number | ToleratedFailureCount. |
tolerated | string | ToleratedFailureCountPath. |
tolerated | number | ToleratedFailurePercentage. |
tolerated | string | ToleratedFailurePercentagePath. |
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 {}.
itemBatcher?
Type:
Item
(optional, default: No itemBatcher)
Specifies to process a group of items in a single child workflow execution.
itemReader?
Type:
IItem
(optional, default: No itemReader)
ItemReader.
Configuration for where to read items dataset in S3 to iterate
itemSelector?
Type:
{ [string]: any }
(optional, default: $)
The JSON that you want to override your default iteration input (mutually exclusive with parameters
).
See also: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-itemselector.html
itemsPath?
Type:
string
(optional, default: $)
JSONPath expression to select the array to iterate over.
label?
Type:
string
(optional, default: No label)
Label.
Unique name for the Distributed Map state added to each Map Run
mapExecutionType?
Type:
State
(optional, default: StateMachineType.STANDARD)
MapExecutionType.
The execution type of the distributed map state
This property overwrites ProcessorConfig.executionType
maxConcurrency?
Type:
number
(optional, default: full concurrency)
MaxConcurrency.
An upper bound on the number of iterations you want running at once.
maxConcurrencyPath?
Type:
string
(optional, default: full concurrency)
MaxConcurrencyPath.
A JsonPath that specifies the maximum concurrency dynamically from the state input.
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 {}.
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.
resultWriter?
Type:
Result
(optional, default: No resultWriter)
Configuration for S3 location in which to save Map Run results.
stateName?
Type:
string
(optional, default: The construct ID will be used as state name)
Optional name for this state.
toleratedFailureCount?
Type:
number
(optional, default: No toleratedFailureCount)
ToleratedFailureCount.
Number of failed items to tolerate in a Map Run, as static number
toleratedFailureCountPath?
Type:
string
(optional, default: No toleratedFailureCountPath)
ToleratedFailureCountPath.
Number of failed items to tolerate in a Map Run, as JsonPath
toleratedFailurePercentage?
Type:
number
(optional, default: No toleratedFailurePercentage)
ToleratedFailurePercentage.
Percentage of failed items to tolerate in a Map Run, as static number
toleratedFailurePercentagePath?
Type:
string
(optional, default: No toleratedFailurePercentagePath)
ToleratedFailurePercentagePath.
Percentage of failed items to tolerate in a Map Run, as JsonPath
Properties
Name | Type | Description |
---|---|---|
end | INextable [] | Continuable states of this Chainable. |
id | string | Descriptive identifier for this chainable. |
node | Node | The tree node. |
start | State | First state of this Chainable. |
state | string | Tokenized 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
Name | Description |
---|---|
add | Add a recovery handler for this state. |
add | Add a prefix to the stateId of this state. |
add | Add retry configuration for this state. |
bind | Register this state as part of the given graph. |
item | Define item processor in a Distributed Map. |
next(next) | Continue normal execution with the given state. |
to | Return the Amazon States Language object for this state. |
to | Returns a string representation of this construct. |
protected validate | Validate this state. |
protected when | Called whenever this state is bound to a graph. |
static is | Return whether the given object is a DistributedMap. |
Catch(handler, props?)
addpublic addCatch(handler: IChainable, props?: CatchProps): DistributedMap
Parameters
- handler
IChainable
- props
Catch
Props
Returns
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.
Prefix(x)
addpublic addPrefix(x: string): void
Parameters
- x
string
Add a prefix to the stateId of this state.
Retry(props?)
addpublic addRetry(props?: RetryProps): DistributedMap
Parameters
- props
Retry
Props
Returns
Add retry configuration for this state.
This controls if and how the execution will be retried if a particular error occurs.
ToGraph(graph)
bindpublic bindToGraph(graph: StateGraph): void
Parameters
- graph
State
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.
Processor(processor, config?)
itempublic itemProcessor(processor: IChainable, config?: ProcessorConfig): DistributedMap
Parameters
- processor
IChainable
- config
Processor
Config
Returns
Define item processor in a Distributed Map.
A Distributed Map must have a non-empty item processor
next(next)
public next(next: IChainable): Chain
Parameters
- next
IChainable
Returns
Continue normal execution with the given state.
StateJson()
topublic toStateJson(): json
Returns
json
Return the Amazon States Language object for this state.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
State()
protected validateprotected validateState(): string[]
Returns
string[]
Validate this state.
BoundToGraph(graph)
protected whenprotected whenBoundToGraph(graph: StateGraph): void
Parameters
- graph
State
Graph
Called whenever this state is bound to a graph.
Can be overridden by subclasses.
DistributedMap(x)
static ispublic static isDistributedMap(x: any): boolean
Parameters
- x
any
Returns
boolean
Return whether the given object is a DistributedMap.