11[ ![ 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 )
22# Serverless Step Functions
3- Serverless plugin for AWS Step Functions.
3+ This is Serverless Framework plugin for AWS Step Functions.
44
55## Install
66Run ` npm install ` in your Serverless project.
@@ -16,11 +16,9 @@ plugins:
1616
1717## Setup
1818Specifies 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`.
1920
2021` ` ` yml
21- custom:
22- accountId: xxxxxxxx
23-
2422functions:
2523 hellofunc:
2624 handler: handler.hello
@@ -47,19 +45,23 @@ stepFunctions:
4745 States:
4846 HelloWorld1:
4947 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
5149 End: true
5250 hellostepfunc2:
5351 definition:
5452 StartAt: HelloWorld2
5553 States:
5654 HelloWorld2:
5755 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
5957 End: true
6058 activities:
6159 - myTask
6260 - yourTask
61+
62+ plugins:
63+ - serverless-step-functions
64+ - serverless-pseudo-parameters
6365` ` `
6466
6567# ## Adding a custom name for a stateMachine
@@ -280,9 +282,6 @@ plugins:
280282## Sample statemachines setting in serverless.yml
281283### Wait State
282284` ` ` yaml
283- custom :
284- accountId : <Here is your accountId>
285-
286285functions :
287286 hello :
288287 handler : handler.hello
@@ -296,7 +295,7 @@ stepFunctions:
296295 States :
297296 FirstState :
298297 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
300299 Next : wait_using_seconds
301300 wait_using_seconds :
302301 Type : Wait
@@ -316,15 +315,15 @@ stepFunctions:
316315 Next : FinalState
317316 FinalState :
318317 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
320319 End : true
320+ plugins :
321+ - serverless-step-functions
322+ - serverless-pseudo-parameters
321323` ` `
322324
323325### Retry Failture
324326` ` ` yaml
325- custom :
326- accountId : <Here is your accountId>
327-
328327functions :
329328 hello :
330329 handler : handler.hello
@@ -338,7 +337,7 @@ stepFunctions:
338337 States :
339338 HelloWorld :
340339 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
342341 Retry :
343342 - ErrorEquals :
344343 - HandledError
@@ -356,14 +355,14 @@ stepFunctions:
356355 MaxAttempts : 5
357356 BackoffRate : 2
358357 End : true
358+ plugins :
359+ - serverless-step-functions
360+ - serverless-pseudo-parameters
359361` ` `
360362
361363### Parallel
362364
363365` ` ` yaml
364- custom :
365- accountId : <Here is your accountId>
366-
367366functions :
368367 hello :
369368 handler : handler.hello
@@ -397,14 +396,14 @@ stepFunctions:
397396 Final State :
398397 Type : Pass
399398 End : true
399+ plugins :
400+ - serverless-step-functions
401+ - serverless-pseudo-parameters
400402` ` `
401403
402404### Catch Failure
403405
404406` ` ` yaml
405- custom :
406- accountId : <Here is your accountId>
407-
408407functions :
409408 hello :
410409 handler : handler.hello
@@ -418,7 +417,7 @@ stepFunctions:
418417 States :
419418 HelloWorld :
420419 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
422421 Catch :
423422 - ErrorEquals :
424423 - HandledError
@@ -442,14 +441,14 @@ stepFunctions:
442441 Type : Pass
443442 Result : " This is a fallback from a reserved error code"
444443 End : true
444+ plugins :
445+ - serverless-step-functions
446+ - serverless-pseudo-parameters
445447` ` `
446448
447449### Choice
448450
449451` ` ` yaml
450- custom :
451- accountId : <Here is your account Id>
452-
453452functions :
454453 hello1 :
455454 handler : handler.hello1
@@ -483,17 +482,20 @@ stepFunctions:
483482 Default : DefaultState
484483 FirstMatchState :
485484 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
487486 Next : NextState
488487 SecondMatchState :
489488 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
491490 Next : NextState
492491 DefaultState :
493492 Type : Fail
494493 Cause : " No Matches!"
495494 NextState :
496495 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
498497 End : true
498+ plugins :
499+ - serverless-step-functions
500+ - serverless-pseudo-parameters
499501` ` `
0 commit comments