|
41 | 41 | sanitize_resource_key_for_mapping, |
42 | 42 | substitute_loop_variable, |
43 | 43 | ) |
| 44 | +from samcli.lib.cfn_language_extensions.utils import is_foreach_key |
44 | 45 | from samcli.lib.intrinsic_resolver.intrinsics_symbol_table import IntrinsicsSymbolTable |
45 | 46 | from samcli.lib.providers.provider import LayerVersion, ResourcesToBuildCollector, Stack |
46 | 47 | from samcli.lib.providers.sam_api_provider import SamApiProvider |
@@ -493,7 +494,7 @@ def _update_original_template_paths(self, original_template: Dict, modified_temp |
493 | 494 | # Process each resource in the original template |
494 | 495 | for resource_key, resource_value in original_resources.items(): |
495 | 496 | # Check if this is a Fn::ForEach construct |
496 | | - if resource_key.startswith("Fn::ForEach::"): |
| 497 | + if is_foreach_key(resource_key): |
497 | 498 | generated_mappings = self._update_foreach_artifact_paths( |
498 | 499 | resource_key, |
499 | 500 | resource_value, |
@@ -579,7 +580,7 @@ def _update_foreach_artifact_paths( |
579 | 580 | dynamic_props_count = self._count_dynamic_properties(body, loop_variable, collection_values) |
580 | 581 |
|
581 | 582 | for resource_template_key, resource_template in body.items(): |
582 | | - if isinstance(resource_template_key, str) and resource_template_key.startswith("Fn::ForEach::"): |
| 583 | + if is_foreach_key(resource_template_key): |
583 | 584 | nested_mappings = self._update_foreach_artifact_paths( |
584 | 585 | resource_template_key, |
585 | 586 | resource_template, |
@@ -711,7 +712,7 @@ def _count_dynamic_properties( |
711 | 712 |
|
712 | 713 | count: Counter = Counter() |
713 | 714 | for rtk, rt in body.items(): |
714 | | - if isinstance(rtk, str) and rtk.startswith("Fn::ForEach::"): |
| 715 | + if is_foreach_key(rtk): |
715 | 716 | continue |
716 | 717 | if not isinstance(rt, dict): |
717 | 718 | continue |
|
0 commit comments