From 48172e3a9f2db80d96d36bb71223059437971652 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Thu, 5 Dec 2024 14:06:52 -0800 Subject: [PATCH] Skip findinmap resolution when hitting a Sub --- src/cfnlint/jsonschema/_resolvers_cfn.py | 3 +++ test/unit/module/jsonschema/test_resolvers_cfn.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/cfnlint/jsonschema/_resolvers_cfn.py b/src/cfnlint/jsonschema/_resolvers_cfn.py index 2c0bb487e9..31c90eb858 100644 --- a/src/cfnlint/jsonschema/_resolvers_cfn.py +++ b/src/cfnlint/jsonschema/_resolvers_cfn.py @@ -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) diff --git a/test/unit/module/jsonschema/test_resolvers_cfn.py b/test/unit/module/jsonschema/test_resolvers_cfn.py index b0d316a32f..223ee606b3 100644 --- a/test/unit/module/jsonschema/test_resolvers_cfn.py +++ b/test/unit/module/jsonschema/test_resolvers_cfn.py @@ -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"}]},