Skip to content

Commit 83fd95a

Browse files
authored
Allow Fn::Transform alongside keys in mappings (#3920)
1 parent 5d9282d commit 83fd95a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/cfnlint/jsonschema/_resolvers_cfn.py

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ def find_in_map(validator: Validator, instance: Any) -> ResolutionResult:
8585

8686
if all(not (equal(map_name, each)) for each in mappings):
8787
if not default_value_found:
88+
# Validated again as Fn::Transform can be used along side
89+
# other key/values
90+
if validator.context.mappings.is_transform:
91+
continue
8892
results.append(
8993
(
9094
None,

test/unit/module/jsonschema/test_resolvers_cfn.py

+28
Original file line numberDiff line numberDiff line change
@@ -849,3 +849,31 @@ def test_valid_functions(name, instance, response):
849849
)
850850
def test_no_mapping(name, instance, response):
851851
_resolve(name, instance, response)
852+
853+
854+
@pytest.mark.parametrize(
855+
"name,instance,response",
856+
[
857+
(
858+
"Valid FindInMap using transform key (maybe) with fn",
859+
{"Fn::FindInMap": [{"Ref": "AWS::Region"}, "B", "C"]},
860+
[],
861+
),
862+
(
863+
"Valid FindInMap using transform key (maybe)",
864+
{"Fn::FindInMap": ["A", "B", "C"]},
865+
[],
866+
),
867+
],
868+
)
869+
def test_find_in_map_with_transform(name, instance, response):
870+
context = Context(
871+
mappings=Mappings.create_from_dict(
872+
{
873+
"foo": {"first": {"second": "bar"}},
874+
"Fn::Transform": "foobar",
875+
}
876+
),
877+
resources={},
878+
)
879+
_resolve(name, instance, response, context=context)

0 commit comments

Comments
 (0)