Skip to content

Commit 8ed8265

Browse files
authored
Better resolution of mappings in transform (#3392)
1 parent 25bfb1a commit 8ed8265

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/cfnlint/template/transforms/_language_extensions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def value(
364364

365365
if mapping:
366366
try:
367-
t_map[1].value(cfn)
367+
t_map[1].value(cfn, params, only_params)
368368
except _ResolveError:
369369
try:
370370
t_map[2].value(cfn)

test/unit/module/template/transforms/test_language_extensions.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ def setUp(self) -> None:
188188
"Development": "1",
189189
"Stage": ["1", "2"],
190190
"Production": ["1", "2", "3"],
191-
}
191+
},
192+
"Instances": {
193+
"Development": "A",
194+
"Stage": ["A", "B"],
195+
"Production": ["A", "B", "C"],
196+
},
192197
},
193198
},
194199
}
@@ -289,6 +294,17 @@ def test_find_in_map_values_without_default(self):
289294
with self.assertRaises(_ResolveError):
290295
map.value(self.cfn, None, False, False)
291296

297+
def test_second_key_resolution(self):
298+
map = _ForEachValueFnFindInMap("a", ["Config", {"Ref": "Value"}, "Production"])
299+
300+
self.assertEqual(
301+
map.value(self.cfn, {"Value": "DBInstances"}, False, True), ["1", "2", "3"]
302+
)
303+
304+
self.assertEqual(
305+
map.value(self.cfn, {"Value": "Instances"}, False, True), ["A", "B", "C"]
306+
)
307+
292308
def test_find_in_map_values_without_default_resolve_error(self):
293309
map = _ForEachValueFnFindInMap(
294310
"a", ["Bucket", "Production", {"Ref": "SSMParameter"}]

0 commit comments

Comments
 (0)