Map
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.
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',
});
map.itemProcessor(new sfn.Pass(this, 'Pass State'), {
mode: sfn.ProcessorMode.DISTRIBUTED,
executionType: sfn.ProcessorType.STANDARD,
});
map = sfn.Map(self, "Map State",
max_concurrency=1,
items_path=sfn.JsonPath.string_at("$.inputForMap"),
item_selector={
"item": sfn.JsonPath.string_at("$.Map.Item.Value")
},
result_path="$.mapOutput"
)
map.item_processor(sfn.Pass(self, "Pass State"),
mode=sfn.ProcessorMode.DISTRIBUTED,
execution_type=sfn.ProcessorType.STANDARD
)
Map map = Map.Builder.create(this, "Map State")
.maxConcurrency(1)
.itemsPath(JsonPath.stringAt("$.inputForMap"))
.itemSelector(Map.of(
"item", JsonPath.stringAt("$.Map.Item.Value")))
.resultPath("$.mapOutput")
.build();
map.itemProcessor(new Pass(this, "Pass State"), ProcessorConfig.builder()
.mode(ProcessorMode.DISTRIBUTED)
.executionType(ProcessorType.STANDARD)
.build());
// Install: dotnet add package Amazon.CDK.Lib
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"
});
map.ItemProcessor(new Pass(this, "Pass State"), new ProcessorConfig {
Mode = ProcessorMode.DISTRIBUTED,
ExecutionType = ProcessorType.STANDARD
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
map := sfn.NewMap(this, jsii.String("Map State"), &MapProps{
MaxConcurrency: jsii.Number(1),
ItemsPath: sfn.JsonPath_StringAt(jsii.String("$.inputForMap")),
ItemSelector: map[string]interface{}{
"item": sfn.JsonPath_*StringAt(jsii.String("$.Map.Item.Value")),
},
ResultPath: jsii.String("$.mapOutput"),
})
map.ItemProcessor(sfn.NewPass(this, jsii.String("Pass State")), &ProcessorConfig{
Mode: sfn.ProcessorMode_DISTRIBUTED,
ExecutionType: sfn.ProcessorType_STANDARD,
})
Initializer
Construct Props
assign{ [key: string]: any }assigntyping.Mapping[str, Any]assignMap<String, Object>AssignIDictionary<string, object>Assign*map[string]interface{}= Not assign variables#Using workflow variables, you can store data in a step and retrieve that data in future steps.
May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}.
itemsProvideItemsitemsProvideItemsitemsProvideItemsItemsProvideItemsItemsProvideItems= The state input as is.#itemSelector{ [key: string]: any }item_selectortyping.Mapping[str, Any]itemSelectorMap<String, Object>ItemSelectorIDictionary<string, object>ItemSelector*map[string]interface{}= $#jsonataItemSelectorstringjsonata_item_selectorstrjsonataItemSelectorStringJsonataItemSelectorstringJsonataItemSelector*string= $#Example value: {% {\"foo\": \"foo\", \"input\": $states.input} %}
jsonataMaxConcurrencystringjsonata_max_concurrencystrjsonataMaxConcurrencyStringJsonataMaxConcurrencystringJsonataMaxConcurrency*string= full concurrency#A JSONata expression that evaluates to an integer, specifying the maximum concurrency dynamically. Mutually exclusive with maxConcurrency and maxConcurrencyPath.
Example value: {% $states.input.maxConcurrency %}
maxConcurrencynumbermax_concurrencyint | floatmaxConcurrencyNumberMaxConcurrencydoubleMaxConcurrency*float64= full concurrency#An upper bound on the number of iterations you want running at once.
maxConcurrencyPathstringmax_concurrency_pathstrmaxConcurrencyPathStringMaxConcurrencyPathstringMaxConcurrencyPath*string= full concurrency#A JsonPath that specifies the maximum concurrency dynamically from the state input.
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…#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
parameters{ [key: string]: any }parameterstyping.Mapping[str, Any]parametersMap<String, Object>ParametersIDictionary<string, object>Parameters*map[string]interface{}= $deprecated#queryLanguageQueryLanguagequery_languageQueryLanguagequeryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguageQueryLanguage= JSONPath#If the state does not contain a queryLanguage field, then it will use the query language specified in the top-level queryLanguage field.
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#You can use ResultSelector to create a payload with values that are static or selected from the state's raw result.
stateNamestringstate_namestrstateNameStringStateNamestringStateName*string= The construct ID will be used as…#default
Default: The construct ID will be used as state name
Properties
Methods
addCatch(handler: IChainable, props?: CatchProps): Map // chainabledef add_catch(self, handler: IChainable, props: typing.Optional[CatchProps] = None) -> Mappublic Map addCatch(IChainable handler, CatchProps props)public Map AddCatch(IChainable handler, CatchProps? props = null)func AddCatch(Handler IChainable, Props CatchProps) Map#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)#addRetry(props?: RetryProps): Map // chainabledef add_retry(self, props: typing.Optional[RetryProps] = None) -> Mappublic Map addRetry(RetryProps props)public Map AddRetry(RetryProps? props = null)func AddRetry(Props RetryProps) Map#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)#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#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#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#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#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.
itemProcessor(processor: IChainable, config?: ProcessorConfig): Map // chainabledef item_processor(self, processor: IChainable, config: typing.Optional[ProcessorConfig] = None) -> Mappublic Map itemProcessor(IChainable processor, ProcessorConfig config)public Map ItemProcessor(IChainable processor, ProcessorConfig? config = null)func ItemProcessor(Processor IChainable, Config ProcessorConfig) Map#A Map must either have a non-empty iterator or a non-empty item processor (mutually exclusive with iterator).
iterator(iterator: IChainable): Map // chainabledef iterator(self, iterator: IChainable) -> Mappublic Map iterator(IChainable iterator)public Map Iterator(IChainable iterator)func Iterator(Iterator IChainable) Mapdeprecated#A Map must either have a non-empty iterator or a non-empty item processor (mutually exclusive with itemProcessor).
jsonata(scope: Construct, id: string, props?: MapJsonataProps): Map // chainable@staticmethod def jsonata(scope: Construct, id: str, props: typing.Optional[MapJsonataProps] = None) -> Mappublic static Map jsonata(Construct scope, String id, MapJsonataProps props)public static Map Jsonata(Construct scope, string id, MapJsonataProps? props = null)func Jsonata(Scope Construct, Id *string, Props MapJsonataProps) Mapstatic#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.
jsonPath(scope: Construct, id: string, props?: MapJsonPathProps): Map // chainable@staticmethod def json_path(scope: Construct, id: str, props: typing.Optional[MapJsonPathProps] = None) -> Mappublic static Map jsonPath(Construct scope, String id, MapJsonPathProps props)public static Map JsonPath(Construct scope, string id, MapJsonPathProps? props = null)func JsonPath(Scope Construct, Id *string, Props MapJsonPathProps) Mapstatic#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.
next(next: IChainable): Chaindef next(self, next: IChainable) -> Chainpublic Chain next(IChainable next)public Chain Next(IChainable next)func Next(Next IChainable) Chain#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#toStateJson(queryLanguage?: QueryLanguage): jsondef to_state_json(self, query_language: typing.Optional[QueryLanguage] = None) -> Anypublic Object toStateJson(QueryLanguage queryLanguage)public object ToStateJson(QueryLanguage? queryLanguage = null)func ToStateJson(QueryLanguage QueryLanguage) interface{}#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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