1
00:00:00,210 --> 00:00:07,320
In this video, we are going to create a state machine from scratch with a of functions workflow studio.

2
00:00:07,590 --> 00:00:14,460
So we are going to create a high level state machine with using a dual step functions workflow studio.

3
00:00:14,520 --> 00:00:19,740
In the last video we will use template, but this time we will develop from the scratch with learning

4
00:00:19,740 --> 00:00:21,300
a step function workflows.

5
00:00:21,300 --> 00:00:24,420
To do so, the topics are the exact same.

6
00:00:24,420 --> 00:00:30,240
We will navigate the workflow studio, create a new state machine and review auto generated Amazon,

7
00:00:30,240 --> 00:00:36,030
set language definition, start execution and update state machine and start any execution.

8
00:00:36,030 --> 00:00:38,610
So let's get started for that purpose.

9
00:00:38,610 --> 00:00:44,100
I'm going to open a console step functions and the state machines.

10
00:00:44,100 --> 00:00:48,420
We can see that we have created a level before, so that's why it is stay in here.

11
00:00:48,420 --> 00:00:54,210
So now I'm going to create a new state machine with click this button, please click this button and

12
00:00:54,210 --> 00:00:56,940
we are going to choose automatic method.

13
00:00:56,940 --> 00:00:59,880
There is three automatic method which is a design your workflow.

14
00:00:59,880 --> 00:01:04,110
Visually write your workflow input and run a sample project.

15
00:01:04,110 --> 00:01:07,560
So we will select a design your workflow studio.

16
00:01:07,590 --> 00:01:12,450
This will provide drag and drop our workflow together with the step function workflow studio.

17
00:01:12,480 --> 00:01:18,750
And after that if you scroll down, you can see that the type of the state machine there is a tool type.

18
00:01:18,750 --> 00:01:24,600
As you remember that we explained in the technical sections, standard and express, you can choose

19
00:01:24,600 --> 00:01:30,090
for the express for short, short running task and you can choose for the standard for the long running

20
00:01:30,090 --> 00:01:30,690
task.

21
00:01:30,690 --> 00:01:32,850
If you click this, help me decide.

22
00:01:32,850 --> 00:01:39,960
You can see the different properties standard and express state machine in terms of the pricing, duration,

23
00:01:39,960 --> 00:01:41,520
execution and so on.

24
00:01:41,730 --> 00:01:46,050
So basically please select the standard and click the next button is you can see that here.

25
00:01:46,050 --> 00:01:47,970
You can see the for step visit.

26
00:01:48,000 --> 00:01:52,140
We will finish the first step and continue the next step.

27
00:01:52,440 --> 00:01:55,260
The step two is design workflow.

28
00:01:55,260 --> 00:02:02,820
So design workflow is the important step that we are going to explain for the workflow studio of a step

29
00:02:02,850 --> 00:02:03,390
functions.

30
00:02:03,390 --> 00:02:07,380
So this is the workflow studio for a step function.

31
00:02:07,380 --> 00:02:13,200
It is a low code visual workflow designer for step function that is basically let us to create serverless

32
00:02:13,200 --> 00:02:16,050
workflows by orchestrating a services.

33
00:02:16,200 --> 00:02:21,570
So in order to understand Workflow Studio, I would like to explain the parts.

34
00:02:21,720 --> 00:02:26,130
First of all, there are four main parts in the in this window.

35
00:02:26,160 --> 00:02:30,180
We can see that in here in the actions and flow box.

36
00:02:30,180 --> 00:02:35,280
This is the state browser that contains the two panels.

37
00:02:35,280 --> 00:02:36,720
The first panel is the action.

38
00:02:36,720 --> 00:02:38,100
The second panel is the flow.

39
00:02:38,130 --> 00:02:45,110
The action panel provides a list of APIs that we can drag and drop into our workflow in the cosmos.

40
00:02:45,120 --> 00:02:47,730
Each action represent as a task state.

41
00:02:47,730 --> 00:02:54,450
So if you click the flow panel, it is basically provide a list of the flow states that we can also

42
00:02:54,450 --> 00:02:57,600
drag and drop into our workflow group in the canvas.

43
00:02:57,600 --> 00:03:03,390
So basically you can remember that we have a choice parallel map, paste, weight, success and fail.

44
00:03:03,420 --> 00:03:09,930
These are the flow states that we can use from these box, which is the browser of the stateless browser.

45
00:03:09,930 --> 00:03:12,510
We can call these box as a status browser.

46
00:03:12,540 --> 00:03:14,670
We can select actions and flows.

47
00:03:14,670 --> 00:03:19,200
If you come here, you can see the area that we can drag and drop this area.

48
00:03:19,200 --> 00:03:21,000
This is name is a canvas.

49
00:03:21,030 --> 00:03:23,850
The cosmos is where we can drag and drop the states.

50
00:03:23,850 --> 00:03:25,290
In our workflow graph.

51
00:03:25,320 --> 00:03:29,490
We can change the order of the states and select the states to configure view.

52
00:03:29,490 --> 00:03:32,610
And also we have inspector panel.

53
00:03:32,610 --> 00:03:39,510
So in order to explain, well let me drag and drop from the actions lambda into the commerce and when

54
00:03:39,510 --> 00:03:45,930
I drop, drag and drop in here, when you select this task, you can see that there is an inspector

55
00:03:45,930 --> 00:03:52,800
panel is basically formed which basically let us view and edit the properties of any state that we select

56
00:03:52,800 --> 00:03:54,030
and the definition.

57
00:03:54,030 --> 00:04:00,990
So as you can see that these are the inspector properties about Islam that we can set the configuration,

58
00:04:00,990 --> 00:04:07,380
input, output and error handling according to these bugs will be changed according to this task that

59
00:04:07,380 --> 00:04:09,930
comes from the our state browser.

60
00:04:10,230 --> 00:04:11,340
Okay, very good.

61
00:04:11,340 --> 00:04:15,300
So the last thing is the our information.

62
00:04:15,300 --> 00:04:21,480
You can see the old information by clicking the other task while from the information panel.

63
00:04:21,510 --> 00:04:27,360
That is very good explanation for the state functions and step function items in here.

64
00:04:28,240 --> 00:04:28,960
Okay.

65
00:04:28,990 --> 00:04:33,910
Now we can extend and understand these parts one by one.

66
00:04:33,940 --> 00:04:36,370
The first part is states border.

67
00:04:36,400 --> 00:04:41,980
The state border is where we select and drag and drop all items from the services.

68
00:04:42,010 --> 00:04:44,710
There's the action and Flow Panel in the action panel.

69
00:04:44,740 --> 00:04:48,610
There's a WAC API and services in the Flow Panel.

70
00:04:48,640 --> 00:04:54,790
We can see the list of the flow states that is affecting our workflow.

71
00:04:54,820 --> 00:05:00,370
So there are seven workflow flow states in you can see in here.

72
00:05:00,400 --> 00:05:06,040
Basically, in the choice state, we can add the choice state for creating violence in our workflow

73
00:05:06,040 --> 00:05:12,010
and we can add the parallel for running the parallel branch of execution or workflow.

74
00:05:12,040 --> 00:05:18,970
We can set map for the dynamically iterate steps for each element on the input array and we can set

75
00:05:18,970 --> 00:05:26,200
a paste for let us to paste input parameter from the output of the next task and we can set the wait

76
00:05:26,200 --> 00:05:29,800
for passing workflow in a certain amount of time.

77
00:05:29,800 --> 00:05:32,350
And lastly, we can have success and fade.

78
00:05:32,380 --> 00:05:35,890
These are the stops or workflow with a success or a fail.

79
00:05:36,030 --> 00:05:43,300
Okay, you understand this state browser and now if you come back to our commas, we can see that this

80
00:05:43,300 --> 00:05:49,750
is the basically drag and drop tool that we can add drag and drop and also change the order of the task

81
00:05:49,750 --> 00:05:51,010
in the cosmos.

82
00:05:51,010 --> 00:05:55,360
And here you can see the inspector date, including the old communication.

83
00:05:55,360 --> 00:06:00,670
You can edit and see all configuration from this inspector page.

84
00:06:00,880 --> 00:06:06,410
Okay, now we have understood how we can configure the workflow and design the workload steps.

85
00:06:06,430 --> 00:06:10,600
Now I'm going to create a state machine for that purpose.

86
00:06:10,600 --> 00:06:13,390
I would like to choose a word example.

87
00:06:13,420 --> 00:06:20,710
In order to do that, I'm going to delete this task and now I'm going to follow the our helloworld example.

88
00:06:20,710 --> 00:06:27,280
So basically in workflow studio we can get the state browser on the left hand side and open the flow

89
00:06:27,280 --> 00:06:30,250
and I'm going to run the paste it.

90
00:06:30,250 --> 00:06:36,310
We can then again drop to pass the state in order to paste the state input parameter in the next task.

91
00:06:36,310 --> 00:06:43,480
So in the state, as the name suggested, we will pass the incoming parameters to the output of the

92
00:06:43,480 --> 00:06:44,680
next state.

93
00:06:44,680 --> 00:06:52,690
So at this stage I would like to open a state functions and go to our previous example that we create

94
00:06:52,690 --> 00:06:54,850
from the template file.

95
00:06:54,850 --> 00:06:58,810
So please open the helloworld and open the success execution.

96
00:06:58,810 --> 00:07:05,350
And basically we will perform the exact same workflow from the scratch and that's why I'm adding to

97
00:07:05,350 --> 00:07:06,340
paste the statement.

98
00:07:06,340 --> 00:07:12,910
And after that I will follow this Helloworld example choice yes and no paste statement.

99
00:07:12,910 --> 00:07:14,470
Wait state.

100
00:07:14,500 --> 00:07:20,170
After that we will use parallel state and we will use again paste state and go to the end state.

101
00:07:20,170 --> 00:07:27,790
So please try to make our workflow as the same way from the our previous helloworld example.

102
00:07:27,790 --> 00:07:32,890
So we add a paste statement and after that we are going to add a choice state.

103
00:07:33,240 --> 00:07:35,890
After the paste I am drag and drop the choice state.

104
00:07:35,890 --> 00:07:40,660
And the name of the choice state is the is Helloworld example.

105
00:07:40,660 --> 00:07:47,170
This will be look at the input parameter and after that according to input parameter, we will redirect

106
00:07:47,170 --> 00:07:51,430
to choice statement from the paste statement or the fail statement.

107
00:07:51,430 --> 00:07:59,140
For that purpose, I'm going to add a paste statement in the rule one and also I'm going to add a fail

108
00:07:59,140 --> 00:08:01,660
statement for the default one.

109
00:08:01,660 --> 00:08:05,680
But we will explain and set these values one by one.

110
00:08:05,980 --> 00:08:06,760
For that purpose.

111
00:08:06,760 --> 00:08:09,940
Please focus on the this choice statement.

112
00:08:09,940 --> 00:08:12,250
Which name is is Helloworld example.

113
00:08:12,250 --> 00:08:16,060
So if you scroll down, you can see that we can specify rule definition in here.

114
00:08:16,060 --> 00:08:18,640
So default rule name is one.

115
00:08:18,640 --> 00:08:22,900
So if you click this edit button, you can see that we can add conditions.

116
00:08:22,900 --> 00:08:28,420
So before we start, if you again look at our example, we should have yes or no.

117
00:08:28,450 --> 00:08:31,900
I'm going to give the name as a paste statement as a yes.

118
00:08:32,700 --> 00:08:34,530
It means the correct one.

119
00:08:34,740 --> 00:08:40,440
Matching our input parameters and the phase statement will be no OC.

120
00:08:40,470 --> 00:08:40,890
Very good.

121
00:08:40,890 --> 00:08:42,110
We have yes and no.

122
00:08:42,120 --> 00:08:46,050
So that's why rule one should be indicated for the our example.

123
00:08:46,050 --> 00:08:51,810
If you select the choice state and click the edit button, you can see that we can give a condition.

124
00:08:51,810 --> 00:08:57,660
If you click the add condition, basically we will give a condition about the incoming parameter.

125
00:08:57,660 --> 00:09:04,170
So in our case, incoming parameter will be the is helloworld example to run false, you can show you

126
00:09:04,170 --> 00:09:09,960
should put a dollar sign and that statement in order to get incoming parameter from the task.

127
00:09:09,960 --> 00:09:17,520
So this is the one of the main important thing when you get parameter value from the one task state,

128
00:09:17,520 --> 00:09:23,280
from another task state, make sure that you have at the dollar sign that an is helloworld example an

129
00:09:23,280 --> 00:09:28,500
operator will be the is equal to and value will be the boolean constant.

130
00:09:28,500 --> 00:09:30,810
And I'm going to select a two rule.

131
00:09:30,870 --> 00:09:37,380
If the condition is a two rule, we can say the condition and after that we will then go to the next

132
00:09:37,380 --> 00:09:38,070
state, which is the.

133
00:09:38,070 --> 00:09:38,580
Yes.

134
00:09:38,580 --> 00:09:44,130
So basically view as you can see in the commas, the is helloworld parameter equal to rule.

135
00:09:44,130 --> 00:09:46,950
Then after that it goes to press statement which name is.

136
00:09:46,950 --> 00:09:47,460
Yes.

137
00:09:47,460 --> 00:09:50,820
So in here, if you scroll down, we can add a new choice.

138
00:09:50,820 --> 00:09:54,240
So in these new choice, we can add new condition again.

139
00:09:54,240 --> 00:10:01,020
And this time we will pass the same parameter and the parameter name equal to Boolean constant.

140
00:10:01,020 --> 00:10:02,820
And this time is a false.

141
00:10:02,850 --> 00:10:08,400
If we save this condition and this time we can navigate to no statement.

142
00:10:08,850 --> 00:10:12,060
Okay, we have rule one and rule two.

143
00:10:12,090 --> 00:10:14,790
Now I'm going to remove the default rule.

144
00:10:14,790 --> 00:10:16,330
We can clear the default loop.

145
00:10:16,410 --> 00:10:18,090
Okay, very good.

146
00:10:18,800 --> 00:10:21,110
So now we can see that we have two rules.

147
00:10:21,110 --> 00:10:23,060
The first rule is goes to press statement.

148
00:10:23,060 --> 00:10:29,240
The second rule goes to phase statement by looking the is helloworld example true or false?

149
00:10:29,390 --> 00:10:30,070
Okay.

150
00:10:30,080 --> 00:10:36,230
Now if you go back to our Helloworld example, you can see that if there is a yes, we can wait three

151
00:10:36,230 --> 00:10:36,800
second.

152
00:10:36,800 --> 00:10:43,700
So after that I'm going to drag and drop wait statement, come here and see that we have added wait

153
00:10:43,700 --> 00:10:47,750
statement and this time you can see the seconds as a three.

154
00:10:47,960 --> 00:10:51,050
So as you remember that it is a wait three sec.

155
00:10:51,050 --> 00:10:56,420
So that's why I have set a t second and save this file.

156
00:10:56,450 --> 00:10:57,560
Okay, very good.

157
00:10:57,560 --> 00:11:03,020
After saving 3 seconds, if you go back to our architecture, we have parallel state.

158
00:11:03,020 --> 00:11:04,460
So what is the parallel set?

159
00:11:04,460 --> 00:11:07,490
It is basically run two tasks in parallel.

160
00:11:07,490 --> 00:11:15,140
So when we can do to parallel statement, we can basically edit press statement by two.

161
00:11:15,140 --> 00:11:16,730
The first one is a halo.

162
00:11:17,650 --> 00:11:19,510
And the second one is a world.

163
00:11:24,340 --> 00:11:29,780
So that means we are waiting 2 seconds and after that we are running parallel statement.

164
00:11:29,800 --> 00:11:33,770
These are the pacing, these two state, which is the halo and world.

165
00:11:33,790 --> 00:11:40,060
And after that, if you go back, you can see that we have one more step, which is the helloworld.

166
00:11:40,060 --> 00:11:42,110
And this is also posted.

167
00:11:42,160 --> 00:11:48,730
You can come here and at the Post statement we basically give the name as a helloworld.

168
00:11:52,310 --> 00:11:52,510
Okay.

169
00:11:52,550 --> 00:11:55,280
I think we have finished our example.

170
00:11:55,520 --> 00:12:00,680
You can come here and see that if you.

171
00:12:02,010 --> 00:12:05,160
Open and expand this page and zoom out.

172
00:12:06,090 --> 00:12:11,370
You can see that we have a press statement and after the choice statement, according to a statement

173
00:12:11,370 --> 00:12:14,280
in the Yes blog, we are going to Penn State as a yes.

174
00:12:14,280 --> 00:12:17,550
Wait three second run statement and run also.

175
00:12:17,550 --> 00:12:18,630
Hello, world case.

176
00:12:18,720 --> 00:12:20,050
Okay, very good.

177
00:12:20,070 --> 00:12:26,820
So now if we complete the design statement, we basically click the next button and goes to the next

178
00:12:26,820 --> 00:12:29,250
step, which is the review generated code.

179
00:12:29,280 --> 00:12:34,080
These are the Amazon State language code that generate from the Amazon workflow studio.

180
00:12:34,110 --> 00:12:42,110
We can review our state machine in order to see all steps in a JSON format, Amazon State language format.

181
00:12:42,120 --> 00:12:48,580
We can verify from the task types, pace, choice, otherwise weights step and so on.

182
00:12:48,600 --> 00:12:56,210
These are the different task type that we are defined in a JSON format and verify from the our workflow

183
00:12:56,220 --> 00:12:57,640
in the right hand side.

184
00:12:57,660 --> 00:13:03,420
If you review the generated code and after that click the next button, basically we will create our

185
00:13:03,420 --> 00:13:12,120
new machine name, state machine name and this will be the are my hello world machine name, state machine

186
00:13:12,120 --> 00:13:12,300
name.

187
00:13:12,300 --> 00:13:18,090
If you scroll down it is basically create an execution role and I'm leaving as it is all this configuration

188
00:13:18,090 --> 00:13:20,040
and click to create state machine.

189
00:13:21,200 --> 00:13:24,770
So basically we have create our own helloworld example.

190
00:13:24,770 --> 00:13:32,030
So if you would like to start an execution, we can start an execution by clicking the start button.

191
00:13:32,030 --> 00:13:38,180
And now we basically provide this variable which is the is helloworld example.

192
00:13:38,210 --> 00:13:43,370
Now I'm going to set a true and start execution and see what's happened.

193
00:13:43,400 --> 00:13:49,010
If you scroll down, you can see that this is going to run our execution in the workflow.

194
00:13:49,010 --> 00:13:52,220
Now it is in the weight statement of the three second.

195
00:13:52,220 --> 00:13:55,040
This will be it goes the other steps and go to end.

196
00:13:55,040 --> 00:13:59,240
So basically we will see the whole illustration in the execution.

197
00:13:59,240 --> 00:14:00,830
All the step functions very good.

198
00:14:00,830 --> 00:14:08,180
So this is the our effect and scroll down, you can see the execution event history and we basically

199
00:14:08,180 --> 00:14:09,350
come to choice state.

200
00:14:09,350 --> 00:14:12,470
After that we will go to the weight step and so on.

201
00:14:12,470 --> 00:14:14,870
So execution is succeed.

202
00:14:14,870 --> 00:14:17,690
That means we have successfully finished our execution.

203
00:14:17,690 --> 00:14:24,050
If you go on top of this page and click the execution and this time I'm going to pass this variable

204
00:14:24,050 --> 00:14:29,870
as a post and see that we got fail for this workflow statement.

205
00:14:29,870 --> 00:14:34,640
When we set a parameter as a force click start execution and see what's happened.

206
00:14:34,670 --> 00:14:41,300
See that this time we got fail in the no statement because we are passing the other value, which is

207
00:14:41,300 --> 00:14:41,780
the force.

208
00:14:41,780 --> 00:14:48,350
If you click this choice statement, you can see the step input and output parameters as a level is

209
00:14:48,350 --> 00:14:49,780
a false OC.

210
00:14:49,820 --> 00:14:56,930
As you can see that we have designed our own helloworld by default from the Secret using the A workflow

211
00:14:56,930 --> 00:14:57,530
studio.
