Skip to content
v2.274.0

DistributedMap ​

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.

Example ​

ts
/**
 * JSON state input:
 *  {
 *    "bucketName": "my-bucket"
 *  }
 */
const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', {
  resultWriterV2: new sfn.ResultWriterV2({
    bucketNamePath: sfn.JsonPath.stringAt('$.bucketName'),
  }),
});
distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'));
python
#
# JSON state input:
#  {
#    "bucketName": "my-bucket"
#  }
#
distributed_map = sfn.DistributedMap(self, "DistributedMap",
    result_writer_v2=sfn.ResultWriterV2(
        bucket_name_path=sfn.JsonPath.string_at("$.bucketName")
    )
)
distributed_map.item_processor(sfn.Pass(self, "Pass"))
java
/**
 * JSON state input:
 *  {
 *    "bucketName": "my-bucket"
 *  }
 */
DistributedMap distributedMap = DistributedMap.Builder.create(this, "DistributedMap")
        .resultWriterV2(ResultWriterV2.Builder.create()
                .bucketNamePath(JsonPath.stringAt("$.bucketName"))
                .build())
        .build();
distributedMap.itemProcessor(new Pass(this, "Pass"));
csharp
// Install: dotnet add package Amazon.CDK.Lib
/**
 * JSON state input:
 *  {
 *    "bucketName": "my-bucket"
 *  }
 */
var distributedMap = new DistributedMap(this, "DistributedMap", new DistributedMapProps {
    ResultWriterV2 = new ResultWriterV2(new ResultWriterV2Props {
        BucketNamePath = JsonPath.StringAt("$.bucketName")
    })
});
distributedMap.ItemProcessor(new Pass(this, "Pass"));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
/**
 * JSON state input:
 *  {
 *    "bucketName": "my-bucket"
 *  }
 */
distributedMap := sfn.NewDistributedMap(this, jsii.String("DistributedMap"), &DistributedMapProps{
	ResultWriterV2: sfn.NewResultWriterV2(&ResultWriterV2Props{
		BucketNamePath: sfn.JsonPath_StringAt(jsii.String("$.bucketName")),
	}),
})
distributedMap.ItemProcessor(sfn.NewPass(this, jsii.String("Pass")))

Initializer ​

ts
new DistributedMap(scope: Construct, id: string, props?: DistributedMapProps)
python
DistributedMap(scope: Construct, id: str, props: typing.Optional[DistributedMapProps] = None)
java
new DistributedMap(Construct scope, String id, DistributedMapProps props)
csharp
new DistributedMap(Construct scope, string id, DistributedMapProps? props = null)
go
NewDistributedMap(Scope Construct, Id *string, Props DistributedMapProps)

Construct Props ​

assign{ [key: string]: any }assigntyping.Mapping[str, Any]assignMap<String, Object>AssignIDictionary<string, object>Assign*map[string]interface{}= Not assign variables#
Workflow variables to store in this step.

Using workflow variables, you can store data in a step and retrieve that data in future steps.

commentstringcommentstrcommentStringCommentstringComment*string= No comment#
A comment describing this state.
inputPathstringinput_pathstrinputPathStringInputPathstringInputPath*string= $#
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 {}.

itemBatcherItemBatcheritem_batcherItemBatcheritemBatcherItemBatcherItemBatcherItemBatcherItemBatcherItemBatcher= No itemBatcher#
Specifies to process a group of items in a single child workflow execution.
itemReaderIItemReaderitem_readerIItemReaderitemReaderIItemReaderItemReaderIItemReaderItemReaderIItemReader= No itemReader#
ItemReader.

Configuration for where to read items dataset in S3 to iterate

itemsProvideItemsitemsProvideItemsitemsProvideItemsItemsProvideItemsItemsProvideItems= The state input as is.#
The array that the Map state will iterate over.
itemSelector{ [key: string]: any }item_selectortyping.Mapping[str, Any]itemSelectorMap<String, Object>ItemSelectorIDictionary<string, object>ItemSelector*map[string]interface{}= $#
The JSON that you want to override your default iteration input (mutually exclusive with `parameters` and `jsonataItemSelector`).
itemsPathstringitems_pathstritemsPathStringItemsPathstringItemsPath*string= $#
JSONPath expression to select the array to iterate over.
jsonataItemSelectorstringjsonata_item_selectorstrjsonataItemSelectorStringJsonataItemSelectorstringJsonataItemSelector*string= $#
Jsonata expression that evaluates to a JSON array to override your default iteration input (mutually exclusive with `parameters` and `itemSelector`).

Example value: {% {\"foo\": \"foo\", \"input\": $states.input} %}

jsonataMaxConcurrencystringjsonata_max_concurrencystrjsonataMaxConcurrencyStringJsonataMaxConcurrencystringJsonataMaxConcurrency*string= full concurrency#
JSONata expression for MaxConcurrency.

A JSONata expression that evaluates to an integer, specifying the maximum concurrency dynamically. Mutually exclusive with maxConcurrency and maxConcurrencyPath.

Example value: {% $states.input.maxConcurrency %}

labelstringlabelstrlabelStringLabelstringLabel*string= No label#
Label.

Unique name for the Distributed Map state added to each Map Run

mapExecutionTypeStateMachineTypemap_execution_typeStateMachineTypemapExecutionTypeStateMachineTypeMapExecutionTypeStateMachineTypeMapExecutionTypeStateMachineType= StateMachineType.STANDARD#
MapExecutionType.

The execution type of the distributed map state

This property overwrites ProcessorConfig.executionType

maxConcurrencynumbermax_concurrencyint | floatmaxConcurrencyNumberMaxConcurrencydoubleMaxConcurrency*float64= full concurrency#
MaxConcurrency.

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

maxConcurrencyPathstringmax_concurrency_pathstrmaxConcurrencyPathStringMaxConcurrencyPathstringMaxConcurrencyPath*string= full concurrency#
MaxConcurrencyPath.

A JsonPath that specifies the maximum concurrency dynamically from the state input.

outputPathstringoutput_pathstroutputPathStringOutputPathstringOutputPath*string= $#
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 {}.

outputsanyoutputsAnyoutputsObjectOutputsobjectOutputsinterface{}= $states.result or $states.errorO…#
Used to specify and transform output from the state.
notes · default

When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly.

Default: $states.result or $states.errorOutput

queryLanguageQueryLanguagequery_languageQueryLanguagequeryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguage= JSONPath#
The name of the query language used by the state.

If the state does not contain a queryLanguage field, then it will use the query language specified in the top-level queryLanguage field.

resultPathstringresult_pathstrresultPathStringResultPathstringResultPath*string= $#
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{ [key: string]: any }result_selectortyping.Mapping[str, Any]resultSelectorMap<String, Object>ResultSelectorIDictionary<string, object>ResultSelector*map[string]interface{}= 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.

resultWriterResultWriterresult_writerResultWriterresultWriterResultWriterResultWriterResultWriterResultWriterResultWriter= No resultWriterdeprecated#
Use {@link resultWriterV2 }
resultWriterV2ResultWriterV2result_writer_v2ResultWriterV2resultWriterV2ResultWriterV2ResultWriterV2ResultWriterV2ResultWriterV2ResultWriterV2= No resultWriterV2#
Configuration for S3 location in which to save Map Run results Enable "@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2" feature in the context to use resultWriterV2 Example: stack.node.setContext("@aws-cdk/aws-stepfunctions:useDistributedMapResultWriterV2", true);
stateNamestringstate_namestrstateNameStringStateNamestringStateName*string= The construct ID will be used as…#
Optional name for this state.
default

Default: The construct ID will be used as state name

toleratedFailureCountnumbertolerated_failure_countint | floattoleratedFailureCountNumberToleratedFailureCountdoubleToleratedFailureCount*float64= No toleratedFailureCount#
ToleratedFailureCount.

Number of failed items to tolerate in a Map Run, as static number

toleratedFailureCountPathstringtolerated_failure_count_pathstrtoleratedFailureCountPathStringToleratedFailureCountPathstringToleratedFailureCountPath*string= No toleratedFailureCountPath#
ToleratedFailureCountPath.

Number of failed items to tolerate in a Map Run, as JsonPath

toleratedFailurePercentagenumbertolerated_failure_percentageint | floattoleratedFailurePercentageNumberToleratedFailurePercentagedoubleToleratedFailurePercentage*float64= No toleratedFailurePercentage#
ToleratedFailurePercentage.

Percentage of failed items to tolerate in a Map Run, as static number

toleratedFailurePercentagePathstringtolerated_failure_percentage_pathstrtoleratedFailurePercentagePathStringToleratedFailurePercentagePathstringToleratedFailurePercentagePath*string= No toleratedFailurePercentagePat…#
ToleratedFailurePercentagePath.

Percentage of failed items to tolerate in a Map Run, as JsonPath

default

Default: No toleratedFailurePercentagePath

Properties ​

endStatesINextable[]end_statestyping.List[INextable]endStatesList<INextable>EndStatesINextable[]EndStates*[]INextablerequired#
Continuable states of this Chainable.
idstringidstridStringIdstringId*stringrequired#
Descriptive identifier for this chainable.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
startStateStatestart_stateStatestartStateStateStartStateStateStartStateStaterequired#
First state of this Chainable.
stateIdstringstate_idstrstateIdStringStateIdstringStateId*stringrequired#
Tokenized string that evaluates to the state's ID.

Methods ​

addCatch(handler: IChainable, props?: CatchProps): DistributedMap // chainabledef add_catch(self, handler: IChainable, props: typing.Optional[CatchProps] = None) -> DistributedMappublic DistributedMap addCatch(IChainable handler, CatchProps props)public DistributedMap AddCatch(IChainable handler, CatchProps? props = null)func AddCatch(Handler IChainable, Props CatchProps) DistributedMap#
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: string): voiddef add_prefix(self, x: str) -> Nonepublic void addPrefix(String x)public void AddPrefix(string x)func AddPrefix(X *string)#
Add a prefix to the stateId of this state.
addRetry(props?: RetryProps): DistributedMap // chainabledef add_retry(self, props: typing.Optional[RetryProps] = None) -> DistributedMappublic DistributedMap addRetry(RetryProps props)public DistributedMap AddRetry(RetryProps? props = null)func AddRetry(Props RetryProps) DistributedMap#
Add retry configuration for this state.

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

bindToGraph(graph: StateGraph): voiddef bind_to_graph(self, graph: StateGraph) -> Nonepublic void bindToGraph(StateGraph graph)public void BindToGraph(StateGraph graph)func BindToGraph(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.

filterNextables(states: State[]): INextable[]@staticmethod def filter_nextables(states: typing.List[State]) -> typing.List[INextable]public static List<INextable> filterNextables(List<State> states)public static INextable[] FilterNextables(State[] states)func FilterNextables(States *[]State) *[]INextablestatic#
Return only the states that allow chaining from an array of states.
findReachableEndStates(start: State, options?: FindStateOptions): State[]@staticmethod def find_reachable_end_states(start: State, options: typing.Optional[FindStateOptions] = None) -> typing.List[State]public static List<State> findReachableEndStates(State start, FindStateOptions options)public static State[] FindReachableEndStates(State start, FindStateOptions? options = null)func FindReachableEndStates(Start State, Options FindStateOptions) *[]Statestatic#
Find the set of end states states reachable through transitions from the given start state.
findReachableStates(start: State, options?: FindStateOptions): State[]@staticmethod def find_reachable_states(start: State, options: typing.Optional[FindStateOptions] = None) -> typing.List[State]public static List<State> findReachableStates(State start, FindStateOptions options)public static State[] FindReachableStates(State start, FindStateOptions? options = null)func FindReachableStates(Start State, Options FindStateOptions) *[]Statestatic#
Find the set of states reachable through transitions from the given start state.

This does not retrieve states from within sub-graphs, such as states within a Parallel state's branch.

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isDistributedMap(x: any): boolean@staticmethod def is_distributed_map(x: Any) -> boolpublic static Boolean isDistributedMap(Object x)public static bool IsDistributedMap(object x)func IsDistributedMap(X interface{}) *boolstatic#
Return whether the given object is a DistributedMap.
itemProcessor(processor: IChainable, config?: ProcessorConfig): DistributedMap // chainabledef item_processor(self, processor: IChainable, config: typing.Optional[ProcessorConfig] = None) -> DistributedMappublic DistributedMap itemProcessor(IChainable processor, ProcessorConfig config)public DistributedMap ItemProcessor(IChainable processor, ProcessorConfig? config = null)func ItemProcessor(Processor IChainable, Config ProcessorConfig) DistributedMap#
Define item processor in a Distributed Map.

A Distributed Map must have a non-empty item processor

jsonata(scope: Construct, id: string, props?: DistributedMapJsonataProps): DistributedMap // chainable@staticmethod def jsonata(scope: Construct, id: str, props: typing.Optional[DistributedMapJsonataProps] = None) -> DistributedMappublic static DistributedMap jsonata(Construct scope, String id, DistributedMapJsonataProps props)public static DistributedMap Jsonata(Construct scope, string id, DistributedMapJsonataProps? props = null)func Jsonata(Scope Construct, Id *string, Props DistributedMapJsonataProps) DistributedMapstatic#
Define a Distributed Mode Map state using JSONata in the state machine.
notes

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.

jsonPath(scope: Construct, id: string, props?: DistributedMapJsonPathProps): DistributedMap // chainable@staticmethod def json_path(scope: Construct, id: str, props: typing.Optional[DistributedMapJsonPathProps] = None) -> DistributedMappublic static DistributedMap jsonPath(Construct scope, String id, DistributedMapJsonPathProps props)public static DistributedMap JsonPath(Construct scope, string id, DistributedMapJsonPathProps? props = null)func JsonPath(Scope Construct, Id *string, Props DistributedMapJsonPathProps) DistributedMapstatic#
Define a Distributed Mode Map state using JSONPath in the state machine.
notes

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.

prefixStates(root: IConstruct, prefix: string): void@staticmethod def prefix_states(root: IConstruct, prefix: str) -> Nonepublic static void prefixStates(IConstruct root, String prefix)public static void PrefixStates(IConstruct root, string prefix)func PrefixStates(Root IConstruct, Prefix *string)static#
Add a prefix to the stateId of all States found in a construct tree.
toStateJson(stateMachineQueryLanguage?: QueryLanguage): jsondef to_state_json(self, state_machine_query_language: typing.Optional[QueryLanguage] = None) -> Anypublic Object toStateJson(QueryLanguage stateMachineQueryLanguage)public object ToStateJson(QueryLanguage? stateMachineQueryLanguage = null)func ToStateJson(StateMachineQueryLanguage QueryLanguage) interface{}#
Return the Amazon States Language object for this state.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining