1
1
[ ![ serverless] ( http://public.serverless.com/badges/v3.svg )] ( http://www.serverless.com ) [ ![ Build Status] ( https://travis-ci.org/horike37/serverless-step-functions.svg?branch=master )] ( https://travis-ci.org/horike37/serverless-step-functions ) [ ![ npm version] ( https://badge.fury.io/js/serverless-step-functions.svg )] ( https://badge.fury.io/js/serverless-step-functions ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/horike37/serverless-step-functions/badge.svg?branch=master )] ( https://coveralls.io/github/horike37/serverless-step-functions?branch=master ) [ ![ MIT License] ( http://img.shields.io/badge/license-MIT-blue.svg?style=flat )] ( LICENSE )
2
2
# Serverless Step Functions
3
- Serverless plugin for AWS Step Functions.
3
+ This is Serverless Framework plugin for AWS Step Functions.
4
4
5
5
## Install
6
6
Run ` npm install ` in your Serverless project.
@@ -16,11 +16,9 @@ plugins:
16
16
17
17
## Setup
18
18
Specifies your statemachine definition using Amazon States Language in a ` definition` statement in serverless.yml.
19
+ We recommend to use [serverless-pseudo-parameters](https://www.npmjs.com/package/serverless-pseudo-parameters) plugin together so that it makes it easy to set up `Resource` section under `definition`.
19
20
20
21
` ` ` yml
21
- custom:
22
- accountId: xxxxxxxx
23
-
24
22
functions:
25
23
hellofunc:
26
24
handler: handler.hello
@@ -47,19 +45,23 @@ stepFunctions:
47
45
States:
48
46
HelloWorld1:
49
47
Type: Task
50
- Resource: arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello
48
+ Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello
51
49
End: true
52
50
hellostepfunc2:
53
51
definition:
54
52
StartAt: HelloWorld2
55
53
States:
56
54
HelloWorld2:
57
55
Type: Task
58
- Resource: arn:aws:states:${opt:region}:${self:custom.accountId }:activity:myTask
56
+ Resource: arn:aws:states:#{AWS::Region}:#{AWS::AccountId }:activity:myTask
59
57
End: true
60
58
activities:
61
59
- myTask
62
60
- yourTask
61
+
62
+ plugins:
63
+ - serverless-step-functions
64
+ - serverless-pseudo-parameters
63
65
` ` `
64
66
65
67
# ## Adding a custom name for a stateMachine
@@ -280,9 +282,6 @@ plugins:
280
282
## Sample statemachines setting in serverless.yml
281
283
### Wait State
282
284
` ` ` yaml
283
- custom :
284
- accountId : <Here is your accountId>
285
-
286
285
functions :
287
286
hello :
288
287
handler : handler.hello
@@ -296,7 +295,7 @@ stepFunctions:
296
295
States :
297
296
FirstState :
298
297
Type : Task
299
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello
298
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello
300
299
Next : wait_using_seconds
301
300
wait_using_seconds :
302
301
Type : Wait
@@ -316,15 +315,15 @@ stepFunctions:
316
315
Next : FinalState
317
316
FinalState :
318
317
Type : Task
319
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello
318
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello
320
319
End : true
320
+ plugins :
321
+ - serverless-step-functions
322
+ - serverless-pseudo-parameters
321
323
` ` `
322
324
323
325
### Retry Failture
324
326
` ` ` yaml
325
- custom :
326
- accountId : <Here is your accountId>
327
-
328
327
functions :
329
328
hello :
330
329
handler : handler.hello
@@ -338,7 +337,7 @@ stepFunctions:
338
337
States :
339
338
HelloWorld :
340
339
Type : Task
341
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello
340
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello
342
341
Retry :
343
342
- ErrorEquals :
344
343
- HandledError
@@ -356,14 +355,14 @@ stepFunctions:
356
355
MaxAttempts : 5
357
356
BackoffRate : 2
358
357
End : true
358
+ plugins :
359
+ - serverless-step-functions
360
+ - serverless-pseudo-parameters
359
361
` ` `
360
362
361
363
### Parallel
362
364
363
365
` ` ` yaml
364
- custom :
365
- accountId : <Here is your accountId>
366
-
367
366
functions :
368
367
hello :
369
368
handler : handler.hello
@@ -397,14 +396,14 @@ stepFunctions:
397
396
Final State :
398
397
Type : Pass
399
398
End : true
399
+ plugins :
400
+ - serverless-step-functions
401
+ - serverless-pseudo-parameters
400
402
` ` `
401
403
402
404
### Catch Failure
403
405
404
406
` ` ` yaml
405
- custom :
406
- accountId : <Here is your accountId>
407
-
408
407
functions :
409
408
hello :
410
409
handler : handler.hello
@@ -418,7 +417,7 @@ stepFunctions:
418
417
States :
419
418
HelloWorld :
420
419
Type : Task
421
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello
420
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello
422
421
Catch :
423
422
- ErrorEquals :
424
423
- HandledError
@@ -442,14 +441,14 @@ stepFunctions:
442
441
Type : Pass
443
442
Result : " This is a fallback from a reserved error code"
444
443
End : true
444
+ plugins :
445
+ - serverless-step-functions
446
+ - serverless-pseudo-parameters
445
447
` ` `
446
448
447
449
### Choice
448
450
449
451
` ` ` yaml
450
- custom :
451
- accountId : <Here is your account Id>
452
-
453
452
functions :
454
453
hello1 :
455
454
handler : handler.hello1
@@ -483,17 +482,20 @@ stepFunctions:
483
482
Default : DefaultState
484
483
FirstMatchState :
485
484
Type : Task
486
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello2
485
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello2
487
486
Next : NextState
488
487
SecondMatchState :
489
488
Type : Task
490
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello3
489
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello3
491
490
Next : NextState
492
491
DefaultState :
493
492
Type : Fail
494
493
Cause : " No Matches!"
495
494
NextState :
496
495
Type : Task
497
- Resource : arn:aws:lambda:${opt:region}:${self:custom.accountId }:function:${self:service}-${opt:stage}-hello4
496
+ Resource : arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId }:function:${self:service}-${opt:stage}-hello4
498
497
End : true
498
+ plugins :
499
+ - serverless-step-functions
500
+ - serverless-pseudo-parameters
499
501
` ` `
0 commit comments