Skip to content

Commit

Permalink
Better resolution of mappings in transform (#3392)
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored Jun 24, 2024
1 parent 25bfb1a commit 8ed8265
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cfnlint/template/transforms/_language_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def value(

if mapping:
try:
t_map[1].value(cfn)
t_map[1].value(cfn, params, only_params)
except _ResolveError:
try:
t_map[2].value(cfn)
Expand Down
18 changes: 17 additions & 1 deletion test/unit/module/template/transforms/test_language_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ def setUp(self) -> None:
"Development": "1",
"Stage": ["1", "2"],
"Production": ["1", "2", "3"],
}
},
"Instances": {
"Development": "A",
"Stage": ["A", "B"],
"Production": ["A", "B", "C"],
},
},
},
}
Expand Down Expand Up @@ -289,6 +294,17 @@ def test_find_in_map_values_without_default(self):
with self.assertRaises(_ResolveError):
map.value(self.cfn, None, False, False)

def test_second_key_resolution(self):
map = _ForEachValueFnFindInMap("a", ["Config", {"Ref": "Value"}, "Production"])

self.assertEqual(
map.value(self.cfn, {"Value": "DBInstances"}, False, True), ["1", "2", "3"]
)

self.assertEqual(
map.value(self.cfn, {"Value": "Instances"}, False, True), ["A", "B", "C"]
)

def test_find_in_map_values_without_default_resolve_error(self):
map = _ForEachValueFnFindInMap(
"a", ["Bucket", "Production", {"Ref": "SSMParameter"}]
Expand Down

0 comments on commit 8ed8265

Please sign in to comment.