File tree 4 files changed +2649
-4
lines changed
lib/deploy/events/apiGateway 4 files changed +2649
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ module.exports = {
10
10
this . pluginhttpValidated . events . forEach ( ( event ) => {
11
11
const resourceId = this . getResourceId ( event . http . path ) ;
12
12
const resourceName = this . getResourceName ( event . http . path ) ;
13
+ const stateMachineObj = this . getStateMachine ( event . stateMachineName ) ;
13
14
14
15
const template = {
15
16
Type : 'AWS::ApiGateway::Method' ,
@@ -23,7 +24,7 @@ module.exports = {
23
24
} ;
24
25
25
26
_ . merge ( template ,
26
- this . getMethodIntegration ( event . stateMachineName ) ,
27
+ this . getMethodIntegration ( event . stateMachineName , stateMachineObj . name ) ,
27
28
this . getMethodResponses ( )
28
29
) ;
29
30
@@ -40,8 +41,8 @@ module.exports = {
40
41
return BbPromise . resolve ( ) ;
41
42
} ,
42
43
43
- getMethodIntegration ( stateMachineName ) {
44
- const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName ) ;
44
+ getMethodIntegration ( stateMachineName , customName ) {
45
+ const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName , customName ) ;
45
46
const apiToStepFunctionsIamRoleLogicalId = this . getApiToStepFunctionsIamRoleLogicalId ( ) ;
46
47
const integration = {
47
48
IntegrationHttpMethod : 'POST' ,
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ describe('#methods()', () => {
21
21
region : 'us-east-1' ,
22
22
} ;
23
23
serverlessStepFunctions = new ServerlessStepFunctions ( serverless , options ) ;
24
+ serverlessStepFunctions . serverless . service . stepFunctions = {
25
+ stateMachines : {
26
+ first : { } ,
27
+ } ,
28
+ } ;
24
29
serverlessStepFunctions . apiGatewayResourceLogicalIds
25
30
= { 'foo/bar' : 'apiGatewayResourceLogicalId' } ;
26
31
serverlessStepFunctions . apiGatewayResourceNames
@@ -53,6 +58,19 @@ describe('#methods()', () => {
53
58
expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' ) . Properties )
54
59
. to . have . property ( 'Integration' ) ;
55
60
} ) ;
61
+
62
+ it ( 'should set stateMachinelogical ID to RequestTemplates when customName is not set' , ( ) => {
63
+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' ) . Properties
64
+ . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
65
+ . to . be . equal ( 'StateMachineStepFunctionsStateMachine' ) ;
66
+ } ) ;
67
+
68
+ it ( 'should set custom stateMachinelogical ID to RequestTemplates when customName is set' ,
69
+ ( ) => {
70
+ expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' , 'custom' ) . Properties
71
+ . Integration . RequestTemplates [ 'application/json' ] [ 'Fn::Join' ] [ 1 ] [ 2 ] . Ref )
72
+ . to . be . equal ( 'Custom' ) ;
73
+ } ) ;
56
74
} ) ;
57
75
58
76
describe ( '#getMethodResponses()' , ( ) => {
You can’t perform that action at this time.
0 commit comments