File tree Expand file tree Collapse file tree 4 files changed +2649
-4
lines changed
lib/deploy/events/apiGateway Expand file tree Collapse file tree 4 files changed +2649
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ module.exports = {
1010 this . pluginhttpValidated . events . forEach ( ( event ) => {
1111 const resourceId = this . getResourceId ( event . http . path ) ;
1212 const resourceName = this . getResourceName ( event . http . path ) ;
13+ const stateMachineObj = this . getStateMachine ( event . stateMachineName ) ;
1314
1415 const template = {
1516 Type : 'AWS::ApiGateway::Method' ,
@@ -23,7 +24,7 @@ module.exports = {
2324 } ;
2425
2526 _ . merge ( template ,
26- this . getMethodIntegration ( event . stateMachineName ) ,
27+ this . getMethodIntegration ( event . stateMachineName , stateMachineObj . name ) ,
2728 this . getMethodResponses ( )
2829 ) ;
2930
@@ -40,8 +41,8 @@ module.exports = {
4041 return BbPromise . resolve ( ) ;
4142 } ,
4243
43- getMethodIntegration ( stateMachineName ) {
44- const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName ) ;
44+ getMethodIntegration ( stateMachineName , customName ) {
45+ const stateMachineLogicalId = this . getStateMachineLogicalId ( stateMachineName , customName ) ;
4546 const apiToStepFunctionsIamRoleLogicalId = this . getApiToStepFunctionsIamRoleLogicalId ( ) ;
4647 const integration = {
4748 IntegrationHttpMethod : 'POST' ,
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ describe('#methods()', () => {
2121 region : 'us-east-1' ,
2222 } ;
2323 serverlessStepFunctions = new ServerlessStepFunctions ( serverless , options ) ;
24+ serverlessStepFunctions . serverless . service . stepFunctions = {
25+ stateMachines : {
26+ first : { } ,
27+ } ,
28+ } ;
2429 serverlessStepFunctions . apiGatewayResourceLogicalIds
2530 = { 'foo/bar' : 'apiGatewayResourceLogicalId' } ;
2631 serverlessStepFunctions . apiGatewayResourceNames
@@ -53,6 +58,19 @@ describe('#methods()', () => {
5358 expect ( serverlessStepFunctions . getMethodIntegration ( 'stateMachine' ) . Properties )
5459 . to . have . property ( 'Integration' ) ;
5560 } ) ;
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+ } ) ;
5674 } ) ;
5775
5876 describe ( '#getMethodResponses()' , ( ) => {
You can’t perform that action at this time.
0 commit comments