diff --git a/src/cfnlint/data/schemas/other/functions/select.json b/src/cfnlint/data/schemas/other/functions/select.json index dc321d7be..37434f960 100644 --- a/src/cfnlint/data/schemas/other/functions/select.json +++ b/src/cfnlint/data/schemas/other/functions/select.json @@ -8,7 +8,9 @@ "cfnContext": { "functions": [ "Ref", - "Fn::FindInMap" + "Fn::FindInMap", + "Fn::If", + "Fn::Select" ], "schema": { "minimum": 0, @@ -37,7 +39,9 @@ "functions": [ "Ref", "Fn::FindInMap", - "Fn::Length" + "Fn::Length", + "Fn::If", + "Fn::Select" ], "schema": { "minimum": 0, diff --git a/test/unit/rules/functions/test_select.py b/test/unit/rules/functions/test_select.py index 453762d01..27912dcee 100644 --- a/test/unit/rules/functions/test_select.py +++ b/test/unit/rules/functions/test_select.py @@ -210,6 +210,23 @@ def template(): {"type": "string"}, [], ), + ( + "Valid Fn::Select with Fn::If as the index", + {"Fn::Select": [{"Fn::If": ["IsSet", "1", "0"]}, ["zero", "one"]]}, + {"type": "string"}, + [], + ), + ( + "Valid Fn::Select with a nested Fn::Select as the index", + { + "Fn::Select": [ + {"Fn::Select": [1, {"Fn::Split": [",", "0,1"]}]}, + ["zero", "one"], + ] + }, + {"type": "string"}, + [], + ), ( "Invalid Fn::Select with an invalid function", {"Fn::Select": [1, ["foo", {"foo": "bar"}]]}, diff --git a/test/unit/rules/functions/test_select_language_extension.py b/test/unit/rules/functions/test_select_language_extension.py index 0319c3b6f..649101f5b 100644 --- a/test/unit/rules/functions/test_select_language_extension.py +++ b/test/unit/rules/functions/test_select_language_extension.py @@ -57,6 +57,23 @@ def template(): {"type": "string"}, [], ), + ( + "Valid Fn::If as the index with language extension", + {"Fn::Select": [{"Fn::If": ["IsSet", "1", "0"]}, ["zero", "one"]]}, + {"type": "string"}, + [], + ), + ( + "Valid nested Fn::Select as the index with language extension", + { + "Fn::Select": [ + {"Fn::Select": [1, {"Fn::Split": [",", "0,1"]}]}, + ["zero", "one"], + ] + }, + {"type": "string"}, + [], + ), ], ) def test_validate(name, instance, schema, expected, rule, validator):