Skip to content

Commit

Permalink
Skip findinmap resolution when hitting a Sub
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Dec 5, 2024
1 parent 58dc21c commit 48172e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cfnlint/jsonschema/_resolvers_cfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def find_in_map(validator: Validator, instance: Any) -> ResolutionResult:
):
continue

second_level_fn, _ = is_function(instance[2])
if second_level_fn == "Fn::Sub":
continue
for second_level_key, second_v, err in validator.resolve_value(instance[2]):
if validator.is_type(second_level_key, "integer"):
second_level_key = str(second_level_key)
Expand Down
11 changes: 11 additions & 0 deletions test/unit/module/jsonschema/test_resolvers_cfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,17 @@ def test_invalid_functions(name, instance, response):
{"Fn::FindInMap": ["transformSecondKey", "first", "third"]},
[],
),
(
"Valid FindInMap using a Sub",
{
"Fn::FindInMap": [
"transformSecondKey",
"first",
{"Fn::Sub": "${AWS::AccountId}Extra"},
]
},
[],
),
(
"Valid Sub with a resolvable values",
{"Fn::Sub": ["${a}-${b}", {"a": "foo", "b": "bar"}]},
Expand Down

0 comments on commit 48172e3

Please sign in to comment.