@@ -29,7 +29,7 @@ class StateMachineDefinition(CfnLintJsonSchema):
29
29
def __init__ (self ):
30
30
super ().__init__ (
31
31
keywords = [
32
- "Resources/AWS::StepFunctions::StateMachine/Properties/Definition " ,
32
+ "Resources/AWS::StepFunctions::StateMachine/Properties" ,
33
33
# https://github.com/aws-cloudformation/cfn-lint/issues/3518
34
34
# Resources/AWS::StepFunctions::StateMachine/Properties/DefinitionString
35
35
],
@@ -55,32 +55,57 @@ def _fix_message(self, err: ValidationError) -> ValidationError:
55
55
def validate (
56
56
self , validator : Validator , keywords : Any , instance : Any , schema : dict [str , Any ]
57
57
) -> ValidationResult :
58
+
59
+ definition_keys = ["Definition" ]
60
+ if not validator .cfn .has_serverless_transform ():
61
+ definition_keys .append ("DefinitionString" )
62
+
58
63
# First time child rules are configured against the rule
59
64
# so we can run this now
60
- add_path_to_message = False
61
- if validator .is_type (instance , "string" ):
62
- try :
65
+ for k in definition_keys :
66
+ value = instance .get (k )
67
+ if not value :
68
+ continue
69
+
70
+ add_path_to_message = False
71
+ if validator .is_type (value , "string" ):
72
+ try :
73
+ step_validator = validator .evolve (
74
+ context = validator .context .evolve (
75
+ functions = [],
76
+ ),
77
+ resolver = self .resolver ,
78
+ schema = self .schema ,
79
+ )
80
+ value = json .loads (value )
81
+ add_path_to_message = True
82
+ except json .JSONDecodeError :
83
+ return
84
+ else :
63
85
step_validator = validator .evolve (
64
- context = validator .context .evolve (
65
- functions = [],
66
- ),
67
86
resolver = self .resolver ,
68
87
schema = self .schema ,
69
88
)
70
- instance = json .loads (instance )
71
- add_path_to_message = True
72
- except json .JSONDecodeError :
73
- return
74
- else :
75
- step_validator = validator .evolve (
76
- resolver = self .resolver ,
77
- schema = self .schema ,
78
- )
79
-
80
- for err in step_validator .iter_errors (instance ):
81
- if add_path_to_message :
82
- err = self ._fix_message (err )
83
- if not err .validator .startswith ("fn_" ) and err .validator not in ["cfnLint" ]:
84
- err .rule = self
85
-
86
- yield self ._clean_error (err )
89
+
90
+ substitutions = []
91
+ props_substitutions = instance .get ("DefinitionSubstitutions" , {})
92
+ if validator .is_type (props_substitutions , "object" ):
93
+ substitutions = list (props_substitutions .keys ())
94
+
95
+ for err in step_validator .iter_errors (value ):
96
+ if validator .is_type (err .instance , "string" ):
97
+ if (
98
+ err .instance .replace ("${" , "" ).replace ("}" , "" ).strip ()
99
+ in substitutions
100
+ ):
101
+ continue
102
+ if add_path_to_message :
103
+ err = self ._fix_message (err )
104
+
105
+ err .path .appendleft (k )
106
+ if not err .validator .startswith ("fn_" ) and err .validator not in [
107
+ "cfnLint"
108
+ ]:
109
+ err .rule = self
110
+
111
+ yield self ._clean_error (err )
0 commit comments