@@ -61,68 +61,51 @@ Resources:
6161 - !Sub " https://sqs.${AWS::Region}.amazonaws.com/${AWS::AccountId}/${SQSQueue.QueueName}"
6262
6363 CustomCVStateMachine :
64- Type : AWS::StepFunctions ::StateMachine
64+ Type : AWS::Serverless ::StateMachine
6565 Properties :
66- DefinitionString : !Sub |-
67- {
68- "StartAt": "Check Queue",
69- "States": {
70- "Check Queue": {
71- "Type": "Task",
72- "Resource": "${SQSPollerFunction.Arn}",
73- "ResultPath": "$.messageinqueue",
74- "Next": "Choice State"
75- },
76- "Choice State": {
77- "Type": "Choice",
78- "Choices": [
79- {
80- "Variable": "$.messageinqueue",
81- "StringEquals": "incoming",
82- "Next": "Start Model"
83- }
84- ],
85- "Default": "Disable SQS Trigger"
86- },
87- "Start Model": {
88- "Type": "Task",
89- "Resource": "${StartModelFunction.Arn}",
90- "ResultPath": "$.runningstatus",
91- "Next": "Start States"
92- },
93- "Start States": {
94- "Type": "Choice",
95- "Choices": [
96- {
97- "Variable": "$.runningstatus",
98- "StringEquals": "RUNNING",
99- "Next": "Enable SQS Trigger"
100- }
101- ],
102- "Default": "Wait for Model to start"
103- },
104- "Wait for Model to start": {
105- "Type": "Wait",
106- "Seconds": 600,
107- "Next": "Enable SQS Trigger"
108- },
109- "Enable SQS Trigger": {
110- "Type": "Task",
111- "Resource": "${ToggleTriggerFunction.Arn}",
112- "Next": "Check Queue"
113- },
114- "Disable SQS Trigger": {
115- "Type": "Task",
116- "Resource": "${ToggleTriggerFunction.Arn}",
117- "Next": "Stop Model"
118- },
119- "Stop Model": {
120- "Type": "Task",
121- "Resource": "${StopModelFunction.Arn}",
122- "End": true
123- }
124- }
125- }
66+ Definition :
67+ StartAt : Check Queue
68+ States :
69+ Check Queue :
70+ Type : Task
71+ Resource : !GetAtt SQSPollerFunction.Arn
72+ ResultPath : " $.messageinqueue"
73+ Next : Choice State
74+ Choice State :
75+ Type : Choice
76+ Choices :
77+ - Variable : " $.messageinqueue"
78+ StringEquals : incoming
79+ Next : Start Model
80+ Default : Disable SQS Trigger
81+ Start Model :
82+ Type : Task
83+ Resource : !GetAtt StartModelFunction.Arn
84+ ResultPath : " $.runningstatus"
85+ Next : Start States
86+ Start States :
87+ Type : Choice
88+ Choices :
89+ - Variable : " $.runningstatus"
90+ StringEquals : RUNNING
91+ Next : Enable SQS Trigger
92+ Default : Wait for Model to start
93+ Wait for Model to start :
94+ Type : Wait
95+ Seconds : 600
96+ Next : Enable SQS Trigger
97+ Enable SQS Trigger :
98+ Type : Task
99+ Resource : !GetAtt ToggleTriggerFunction.Arn
100+ Next : Check Queue
101+ Disable SQS Trigger :
102+ Type : Task
103+ Resource : !GetAtt ToggleTriggerFunction.Arn
104+ Next : Stop Model
105+ Stop Model :
106+ Type : Task
107+ Resource : !GetAtt StopModelFunction.Arn
108+ End : true
126109 Events :
127110 HourlyPollingSchedule :
128111 Type : Schedule # More info about Schedule Event Source: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-statemachine-schedule.html
0 commit comments