@@ -126,7 +126,7 @@ def _walk(self, item: Any, params: MutableMapping[str, Any], cfn: Any):
126
126
# only translate the foreach if its valid
127
127
foreach = _ForEach (k , v , self ._collections )
128
128
# get the values will flatten the foreach
129
- for collection_value in foreach .items (cfn ):
129
+ for collection_value in foreach .items (cfn , params ):
130
130
flattened = self ._walk (
131
131
v [2 ], {** params , ** {v [0 ]: collection_value }}, cfn
132
132
)
@@ -523,7 +523,10 @@ def __init__(self, obj: Any) -> None:
523
523
raise _TypeError ("Collection must be a list or an object" , obj )
524
524
525
525
def values (
526
- self , cfn : Any , collection_cache : MutableMapping [str , Any ]
526
+ self ,
527
+ cfn : Any ,
528
+ collection_cache : MutableMapping [str , Any ],
529
+ params : MutableMapping [str , Any ],
527
530
) -> Iterator [str | dict [Any , Any ]]:
528
531
if self ._collection :
529
532
for item in self ._collection :
@@ -536,7 +539,7 @@ def values(
536
539
return
537
540
if self ._fn :
538
541
try :
539
- values = self ._fn .value (cfn , {} , False )
542
+ values = self ._fn .value (cfn , params , False )
540
543
if values is not None :
541
544
if isinstance (values , list ):
542
545
for value in values :
@@ -594,6 +597,8 @@ def __init__(
594
597
self ._collection = _ForEachCollection (value [1 ])
595
598
self ._output = _ForEachOutput (value [2 ])
596
599
597
- def items (self , cfn : Any ) -> Iterator [str | dict [str , str ]]:
598
- items = self ._collection .values (cfn , self ._collection_cache )
600
+ def items (
601
+ self , cfn : Any , params : MutableMapping [str , Any ]
602
+ ) -> Iterator [str | dict [str , str ]]:
603
+ items = self ._collection .values (cfn , self ._collection_cache , params )
599
604
yield from iter (items )
0 commit comments