@@ -3,36 +3,10 @@ const BbPromise = require('bluebird');
33const path = require ( 'path' ) ;
44const _ = require ( 'lodash' ) ;
55
6- class AwsStepFunctionsDeploy {
7- constructor ( serverless , options ) {
8- this . serverless = serverless ;
9- this . options = options ;
10- this . provider = this . serverless . getProvider ( 'aws' ) ;
6+ module . exports = {
7+ deploy ( ) {
118 this . awsStateLanguage = { } ;
129 this . functionArns = { } ;
13- this . commands = {
14- deploy : {
15- commands : {
16- stepf : {
17- usage : 'Deploy Step functions' ,
18- lifecycleEvents : [
19- 'deploy' ,
20- ] ,
21- options : {
22- statemachine : {
23- usage : 'Name of the State Machine' ,
24- shortcut : 'sm' ,
25- required : true ,
26- } ,
27- } ,
28- } ,
29- } ,
30- } ,
31- } ;
32-
33- this . hooks = {
34- 'deploy:stepf:deploy' : this . action . bind ( this ) ,
35- } ;
3610
3711 this . iamPolicyStatement = `{
3812 "Version": "2012-10-17",
@@ -47,11 +21,6 @@ class AwsStepFunctionsDeploy {
4721 ]
4822 }
4923 ` ;
50- this . iamRoleName = 'serverless-step-functions-executerole' ;
51- }
52-
53- action ( ) {
54- this . serverless . cli . consoleLog ( 'Start Deploy Step Functions' ) ;
5524 BbPromise . bind ( this )
5625 . then ( this . yamlParse )
5726 . then ( this . getStateMachineArn )
@@ -60,7 +29,9 @@ class AwsStepFunctionsDeploy {
6029 . then ( this . getIamRole )
6130 . then ( this . deleteStateMachine )
6231 . then ( this . createStateMachine ) ;
63- }
32+
33+ return BbPromise . resolve ( ) ;
34+ } ,
6435
6536 getIamRole ( ) {
6637 return this . provider . request ( 'IAM' ,
@@ -79,7 +50,7 @@ class AwsStepFunctionsDeploy {
7950 }
8051 return BbPromise . reject ( ) ;
8152 } ) ;
82- }
53+ } ,
8354
8455 getFunctionArns ( ) {
8556 return this . provider . request ( 'STS' ,
@@ -95,7 +66,7 @@ class AwsStepFunctionsDeploy {
9566 } ) ;
9667 return BbPromise . resolve ( ) ;
9768 } ) ;
98- }
69+ } ,
9970
10071 createIamRole ( ) {
10172 return this . provider . request ( 'IAM' ,
@@ -110,7 +81,7 @@ class AwsStepFunctionsDeploy {
11081 this . iamRoleArn = result . Role . Arn ;
11182 return BbPromise . resolve ( ) ;
11283 } ) ;
113- }
84+ } ,
11485
11586 getStateMachineArn ( ) {
11687 return this . provider . request ( 'STS' ,
@@ -124,7 +95,7 @@ class AwsStepFunctionsDeploy {
12495 `arn:aws:states:${ region } :${ result . Account } :stateMachine:${ this . options . statemachine } ` ;
12596 return BbPromise . resolve ( ) ;
12697 } ) ;
127- }
98+ } ,
12899
129100 yamlParse ( ) {
130101 const servicePath = this . serverless . config . servicePath ;
@@ -145,7 +116,7 @@ class AwsStepFunctionsDeploy {
145116 this . stepFunctions = serverlessFileParam . stepFunctions ;
146117 return BbPromise . resolve ( ) ;
147118 } ) ;
148- }
119+ } ,
149120
150121 compile ( ) {
151122 if ( ! this . stepFunctions ) {
@@ -169,7 +140,7 @@ class AwsStepFunctionsDeploy {
169140 this . awsStateLanguage [ this . options . statemachine ] =
170141 JSON . stringify ( this . stepFunctions [ this . options . statemachine ] ) ;
171142 return BbPromise . resolve ( ) ;
172- }
143+ } ,
173144
174145 deleteStateMachine ( ) {
175146 return this . provider . request ( 'StepFunctions' ,
@@ -180,7 +151,7 @@ class AwsStepFunctionsDeploy {
180151 this . options . stage ,
181152 this . options . region )
182153 . then ( ( ) => BbPromise . resolve ( ) ) ;
183- }
154+ } ,
184155
185156 createStateMachine ( ) {
186157 return this . provider . request ( 'StepFunctions' ,
@@ -198,6 +169,5 @@ class AwsStepFunctionsDeploy {
198169 setTimeout ( this . createStateMachine . bind ( this ) , 5000 ) ;
199170 }
200171 } ) ;
201- }
202- }
203- module . exports = AwsStepFunctionsDeploy ;
172+ } ,
173+ } ;
0 commit comments