diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js index 1a1a36039..abc454fff 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/methods.js @@ -20,7 +20,7 @@ module.exports = { const lambdaUri = `arn:aws:apigateway:${ this.options.region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${ this.options.region}:${awsAccountNumber}:function:${ - serviceName}-${functionName}/invocations`; + serviceName}-${this.options.stage}-${functionName}/invocations`; // universal velocity template // provides `{body, method, headers, query, path, identity, stageVariables} = event` diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/methods.js b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/methods.js index ff2fffbb0..8cd60113a 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/methods.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/methods.js @@ -65,4 +65,23 @@ describe('#compileMethods()', () => { ).to.equal('AWS::ApiGateway::Method'); }) ); + + it('should set the correct lambdaUri', () => { + const lambdaUri = `arn:aws:apigateway:${ + awsCompileApigEvents.options.region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${ + awsCompileApigEvents.options.region}:12345678:function:${ + awsCompileApigEvents.serverless.service.service}-${ + awsCompileApigEvents.options.stage}-first/invocations`; + + return awsCompileApigEvents.compileMethods().then(() => { + expect( + awsCompileApigEvents.serverless.service.resources.Resources.PostMethodApigEvent0.Properties + .Integration.Uri + ).to.equal(lambdaUri); + expect( + awsCompileApigEvents.serverless.service.resources.Resources.GetMethodApigEvent1.Properties + .Integration.Uri + ).to.equal(lambdaUri); + }); + }); });