-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
546 lines (544 loc) · 18.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>AWeSome Step Functions</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/reveal.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/theme/black.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/lib/css/zenburn.css">
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'https://cdn.jsdelivr.net/npm/[email protected]/css/print/paper.css' : 'https://cdn.jsdelivr.net/npm/[email protected]/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<style>
h1, h2, h3 {
text-transform: none !important;
font-variant: small-caps !important;
}
.slides img {
max-height: 55vh !important;
}
.aws-orange {
color: #e9903a !important;
}
.left {
text-align: left !important;
}
.pros {
color: green !important;
}
.pros::before {
content: '+ ' !important;
}
.cons {
color: red !important;
}
.cons::before {
content: '- ' !important;
}
.octocat {
width: 35px !important;
height: 35px !important;
border: none !important;
background: white !important;
box-shadow: none !important;
vertical-align: middle !important;
padding: 10px !important;
border-radius: 50px !important;
margin-top: 0 !important;
margin-bottom: 0 !important;
margin-left: 15px !important;
margin-right: 15px !important;
}
.done {
color: green !important;
}
.done::after {
content: ' ✓' !important;
}
footer {
position: absolute !important;
bottom: 10px !important;
left: 10px !important;
}
footer img {
height: 25px !important;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>
<span class="aws-orange">AW</span>e<span class="aws-orange">S</span>ome<br />
<span class="aws-orange">Step Functions</span>
</h1>
</section>
<section>
<h2>Who am I?</h2>
<p class="left">
<img alt="Me" src="images/me.png" style="float: right;" height="200" width="200"/><br />
<a href="https://github.com/ChristopheBougere">
<img alt="Github" src="images/octocat.png" class="octocat" />
<span class="aws-orange">Christophe Bougère</span>
</a><br /><br />
<a href="https://github.com/airware">
<img alt="Github" src="images/octocat.png" class="octocat" />
Full Stack Developer at Airware
</a><br />
</p>
</section>
<section>
<section>
<h2>Agenda</h2>
<img alt="Agenda" src="images/agenda.png" />
</section>
<section>
<h2>Meetup definition</h2>
<pre><code class="json">{
"StartAt": "Introduction",
"States": {
"Introduction": {
"Type": "Pass",
"Catch": [ {
"ErrorEquals": [ "Not interested" ],
"Next": "Escape"
} ],
"Next": "Presentation"
},
"Escape": {
"Type": "Pass",
"End": true
},
"Presentation": {
"Type": "Pass",
"Next": "Questions ?"
},
"Questions ?": {
"Type" : "Choice",
"Choices": [ {
"Variable": "$.crystalClear",
"BooleanEquals": true,
"Next": "Answer"
} ],
"Default": "Have fun"
},
"Answer": {
"Type": "Pass",
"Next": "Questions ?"
},
"Have fun": {
"Type": "Parallel",
"Next": "Return home and start building awesome stuff",
"Branches": [ {
"StartAt": "Have a beer",
"States": {
"Have a beer": {
"Type": "Pass",
"End": true
}
}
}, {
"StartAt": "Eat some pizza",
"States": {
"Eat some pizza": {
"Type": "Pass",
"End": true
}
}
}, {
"StartAt": "Network",
"States": {
"Network": {
"Type": "Pass",
"End": true
}
}
} ]
},
"Return home and start building awesome stuff": {
"Type": "Pass",
"End": true
}
}
}</code></pre>
</section>
</section>
<section>
<h2>What is an orchestrator?</h2>
<img alt="Lego bricks" src="images/lego.gif" />
<p>Component coordination layer</p>
</section>
<section>
<section>
<h2>Why do I need an orchestrator?</h2>
<br />
<p>TL;DR: To do what FaaS can't</p>
</section>
<section>
<h2>Manage states</h2>
<br />
<ul>
<li>Manual step (Ex: validation link in an email)</li>
<li>Send an email 24 hours after user's subscription</li>
<li>Asynchronous task</li>
</ul>
</section>
<section>
<h2>Simplify a process</h2>
<ul>
<li>Segregate activities (fetch data, compute, save results)</li>
<li>Ease debugging</li>
<li>Adapt your resources (memory, timeout)</li>
<li>Reuse your functions across your services</li>
</ul>
</section>
<section>
<h2>Assemble different compute layers</h2>
<ul>
<li>Lambda</li>
<li>Batch/Fargate job</li>
<li>Activity (custom task)</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Other solutions</h2>
</section>
<section>
<h3>Invoke a function from within another one</h3>
<div class="left">
<p class="pros">use only FaaS</p>
<p class="cons">code should be focusing on business logic, not on what should happen after</p>
<p class="cons">strong dependency between your functions</p>
</div>
</script></section>
<section>
<h3>Build your own state management system</h3>
<div class="left">
<p class="pros">suits your exact requirements</p>
<p class="pros">could be fun (see <a href="https://medium.com/netflix-techblog/netflix-conductor-a-microservices-orchestrator-2e8d4771bf40">Netflix Conductor</a>)</p>
<p class="cons">requires time to develop and maintain</p>
<p class="cons">don't you have higher priorities?! 🤔</p>
</div>
</section>
<section>
<h3>Use a non-serverless solution</h3>
<img alt="Batman" src="images/batman.jpg" />
</section>
</section>
<section>
<section>
<h2>Language overview</h2>
<p>
<span class="aws-orange">A</span>mazon <span class="aws-orange">S</span>tate <span class="aws-orange">L</span>anguage<br />
<a href="https://states-language.net/spec.html">https://states-language.net/spec.html</a>
</p>
</section>
<section>
<h3>State machine</h3>
<pre style="float: left; width: 45%;"><code class="json">{
"StartAt": "FirstState",
"TimeoutSeconds": 3600,
"States": {
"FirstState": {
"Type": "Pass",
"End": true
}
}
}</code></pre>
<br />
<ul style="float: right; width: 45%;">
<li>Entry point</li>
<li>List of states</li>
<li>Configuration (timeout)</li>
</ul>
</section>
<section>
<h3>Task state</h3>
<pre><code class="json">{
"Type": "Task",
"Resource": "arn:aws:states:us-east-1:123456789012:activity:HelloWorld",
"Next": "NextState"
}</code></pre>
<br />
<p>Works with Lambda and Activity</p>
</section>
<section>
<h3>Choice state</h3>
<div style="float: left; width: 60%;">
<pre><code class="json">{
"Type": "Choice",
"Choices": [ {
"Not": {
"Variable": "$.type",
"StringEquals": "Private"
},
"Next": "Public"
} ],
"Default": "DefaultState"
}</code></pre>
</div>
<div style="float: right; width: 40%;">
<br />
<br />
<ul>
<li>Use of JSON path</li>
<li>19 comparison operators</li>
</ul>
</div>
</section>
<section>
<h3>Wait state</h3>
<div style="float: left; width: 60%;">
<pre><code class="json">{
"Type": "Wait",
"Seconds": 10,
"Next": "NextState"
}</code></pre>
</div>
<p style="float: right; width: 40%;">
Time/Timestamp fixed or from the input (JSON path)
</p>
</section>
<section>
<h3>Parallel state</h3>
<div style="float: left; width: 50%;">
<pre><code class="json">{
"Type": "Parallel",
"Branches": [ {
"StartAt": "Worker1",
"States": {
"Worker1": {
"Type": "Task",
}
}
}, {
"StartAt": "Worker2",
"States": {
"Worker2": {
"Type": "Task",
}
}
} ]
}</code></pre>
</div>
<div style="float: right; width: 50%;">
<br /><br />
<ul>
<li>Parallelisation for unrelated tasks.</li>
<li>Each branch contains a sub state machine.</li>
</ul>
</div>
</section>
<section>
<h3>And many others...</h3>
<ul>
<li>Pass (useful to bind data)</li>
<li>Wait (interval can be dynamic)</li>
<li>Succeed</li>
<li>Fail</li>
</ul>
</section>
<section>
<h3>Common fields</h3>
<img alt="Ćommon fields" src="./images/common-fields.png" />
</section>
<section>
<h3>Reference paths</h3>
<div style="float: left; width: 70%;">
<pre><code class="javascript">{ // Input
"title": "Numbers to add",
"numbers": { "val1": 3, "val2": 4 }
}</code></pre>
<pre><code class="javascript">{ // State definition
"InputPath": "$.numbers",
"ResultPath": "$.sum"
}</code></pre>
<pre><code class="javascript">{ // Output
"title": "Numbers to add",
"numbers": { "val1": 3, "val2": 4 },
"sum": 7
}</code></pre>
</div>
<div style="float: right; width: 30%;">
<br /><br />
<ul>
<li>InputPath</li>
<li>ResultPath</li>
<li>OutputPath</li>
</ul>
</div>
</section>
<section>
<h3>Retry/Catch</h3>
<pre><code class="javascript">{
"Retry": [ {
"ErrorEquals": [ "ErrorA", "ErrorB" ],
"IntervalSeconds": 1,
"BackoffRate": 2,
"MaxAttempts": 2
}, {
"ErrorEquals": [ "ErrorC" ],
"IntervalSeconds": 5
} ],
"Catch": [ {
"ErrorEquals": [ "States.ALL" ],
"Next": "Z"
} ]
}</code></pre>
</section>
</section>
<section>
<section>
<h2>A few examples of what we've built</h2>
</section>
<section>
<h3>Data classification algorithm</h3>
<p>Was executed once a day on EC2, now divided in 8 lambdas<p>
<ul>
<li>Event driven</li>
<li>Cleaner</li>
<li>Easier to maintain and debug</li>
<li>Visual logic</li>
<li>Reprocessing workflow easily done by reassembling lambdas</li>
</ul>
</section>
<section>
<h3>Wrap a long/heavy job with Batch</h3>
<p class="pros">Stateless</p>
<p class="cons">Long to start</p>
<p class="cons">Need to wait and loop in the state machine</p>
</section>
<section>
<h3>Wrap a long/heavy job with Fargate</h3>
<p class="pros">Stateless</p>
<p class="cons">More limited (no EFS access)</p>
</section>
<section>
<h3>Wrap a long/heavy job with Activities</h3>
<p class="pros">Can't be faster</p>
<p class="cons">Need a full time running poller</p>
</section>
<section>
<h3>Reuse generic functions in many workflows</h3>
<ul>
<li>Push notification, slack, email</li>
<li>Error management</li>
<li>Scale up/down resources before/after your process (DynamoDB capacities)</li>
</ul>
</section>
</section>
<section>
<section>
<h2>Tooling</h2>
</section>
<section>
<h3>Serverless framework integration</h3>
<a href="https://github.com/horike37/serverless-step-functions">serverless-step-functions</a><br />
<pre><code class="bash">$ serverless invoke stepf --name MyStepFunction --path my-input.json</code></pre>
</section>
<section>
<h3>State machine validation</h3>
<a href="https://github.com/airware/asl-validator">asl-validator</a>
<pre><code class="bash">$ npm install -g asl-validator
$ asl-validator --json-path definition.json
✓ State machine definition is valid</code></pre>
<a href="https://github.com/piercus/serverless-stepfunction-validator#readme">serverless-stepfunction-validator</a>
<pre><code class="bash">$ serverless validate</code></pre>
</section>
<section>
<h3>Local execution</h3>
<a href="https://github.com/airware/stepfunctions-local">stepfunctions-local</a>
<pre><code class="bash">$ npm install -g stepfunctions-local
$ stepfunctions-local start
$ aws stepfunctions --endpoint http://localhost:4584
create-state-machine
--name my-state-machine
--definition '{"Comment":"A Hello World example of the Amazon States Language using a Pass state","StartAt":"HelloWorld","States":{"HelloWorld":{"Type":"Pass","End":true}}}'
--role-arn arn:aws:iam::0123456789:role/service-role/MyRole
$ aws stepfunctions --endpoint http://localhost:4584
start-execution
--state-machine-arn arn:aws:states:local:0123456789:stateMachine:my-state-machine
--name my-execution
--input '{"comment":"I am a great input !"}'</code></pre>
<a href="https://hub.docker.com/r/amazon/aws-stepfunctions-local">And now officially supported by AWS 👏</a>
</section>
</section>
<section>
<section>
<h2>Whishlist to AWS</h2>
<ul>
<li>Better monitoring (aggregate CloudWatch streams)</li>
<li>Access to the execution ID (add a context object)</li>
<li>Dynamic and non-waiting parallel branches</li>
<li>Greater event size</li>
<li><code class="bash">tmp</code> space available from all the execution</li>
<li>Ability to trigger execution from other services (API Gateway, SNS, S3 or CloudWatch, etc.)</li>
<li>Defining reusable sub state machines</li>
<li>Official local execution support</li>
</ul>
</section>
<section>
<h2>Update 04/2019</h2>
<ul>
<li class="done">Ability to trigger execution from other services (API Gateway, SNS, S3 or CloudWatch, etc.)</li>
<li class="done">Official local execution support</li>
</ul>
</section>
<section>
<h2>Update 04/2019</h2>
<p>Adding integration with services:</p>
<ul>
<li>AWS Batch</li>
<li>Amazon DynamoDB</li>
<li>Amazon ECS/Fargate</li>
<li>Amazon SNS</li>
<li>Amazon SQS</li>
<li>AWS Glue</li>
<li>Amazon SageMaker</li>
</ul>
</section>
</section>
<section>
<h2>Readings</h2>
<ul>
<li><a href="https://epsagon.com/blog/hitchhikers-guide-to-aws-step-functions/">Hitchhiker’s Guide to AWS Step Functions
</a></li>
<li><a href="https://serverless.com/blog/how-to-manage-your-aws-step-functions-with-serverless">How to manage your AWS Step Functions With Serverless?</a></li>
<li><a href="https://medium.com/netflix-techblog/netflix-conductor-a-microservices-orchestrator-2e8d4771bf40">Netflix Conductor: a microservices orchestrator</a></li>
<li><a href="https://aws.amazon.com/blogs/devops/using-aws-step-functions-state-machines-to-handle-workflow-driven-aws-codepipeline-actions/">Using AWS Step Functions State Machines to Handle Workflow-Driven AWS CodePipeline Actions</a></li>
</ul>
</section>
<section>
<h3>Questions?</h3>
<img alt="Questions?" src="./images/questions.gif" />
</section>
</div>
<footer>
<img alt="Airware" src="./images/airware.svg" />
</footer>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/js/head.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/reveal.js"></script>
<script>
Reveal.initialize({
slideNumber: 'c/t',
transition: 'concave',
history: true,
dependencies: [
{ src: 'https://cdn.jsdelivr.net/npm/[email protected]/plugin/markdown/marked.js' },
{ src: 'https://cdn.jsdelivr.net/npm/[email protected]/plugin/markdown/markdown.js' },
{ src: 'https://cdn.jsdelivr.net/npm/[email protected]/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'https://cdn.jsdelivr.net/npm/[email protected]/plugin/zoom-js/zoom.js', async: true },
]
});
</script>
</body>
</html>