diff --git a/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py b/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py index 1fee887de78..667b222a935 100644 --- a/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py +++ b/samcli/lib/intrinsic_resolver/intrinsic_property_resolver.py @@ -492,7 +492,7 @@ def handle_find_in_map(self, intrinsic_value, ignore_errors): ) second_level_value = top_level_value.get(second_level_key) - verify_intrinsic_type_str( + verify_non_null( second_level_value, IntrinsicResolver.FN_FIND_IN_MAP, message="The SecondLevelKey is missing in the Mappings dictionary in Fn::FindInMap " diff --git a/tests/unit/lib/intrinsic_resolver/test_intrinsic_resolver.py b/tests/unit/lib/intrinsic_resolver/test_intrinsic_resolver.py index e7d4be3b5fe..fe0bf2dfa66 100644 --- a/tests/unit/lib/intrinsic_resolver/test_intrinsic_resolver.py +++ b/tests/unit/lib/intrinsic_resolver/test_intrinsic_resolver.py @@ -209,6 +209,7 @@ def setUp(self): "Basic": {"Test": {"key": "value"}}, "value": {"anotherkey": {"key": "result"}}, "result": {"value": {"key": "final"}}, + "IntegerValue": {"Test": {"key": 0}}, } } self.resolver = IntrinsicResolver(symbol_resolver=IntrinsicsSymbolTable(), template=template) @@ -218,6 +219,11 @@ def test_basic_find_in_map(self): result = self.resolver.intrinsic_property_resolver(intrinsic, True) self.assertEqual(result, "value") + def test_basic_find_in_map_with_non_string_value(self): + intrinsic = {"Fn::FindInMap": ["Basic", "Test", "key"]} + result = self.resolver.intrinsic_property_resolver(intrinsic, True) + self.assertEqual(result, 0) + def test_nested_find_in_map(self): intrinsic_base_1 = {"Fn::FindInMap": ["Basic", "Test", "key"]} intrinsic_base_2 = {"Fn::FindInMap": [intrinsic_base_1, "anotherkey", "key"]}