diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/authorizers.js b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/authorizers.js index 16846755f..e78943f8e 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/lib/authorizers.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/lib/authorizers.js @@ -51,7 +51,8 @@ module.exports = { throw new this.serverless.classes .Error('Please provide either an authorizer name or ARN'); } - resultTtlInSeconds = Number.parseInt(authorizer.resultTtlInSeconds, 10) || 300; + resultTtlInSeconds = Number.parseInt(authorizer.resultTtlInSeconds, 10); + resultTtlInSeconds = Number.isNaN(resultTtlInSeconds) ? 300 : resultTtlInSeconds; identitySource = authorizer.identitySource || 'method.request.header.Authorization'; } else { const errorMessage = [ diff --git a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/authorizers.js b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/authorizers.js index 75eea0e00..6648a55de 100644 --- a/lib/plugins/aws/deploy/compile/events/apiGateway/tests/authorizers.js +++ b/lib/plugins/aws/deploy/compile/events/apiGateway/tests/authorizers.js @@ -108,7 +108,7 @@ describe('#compileAuthorizers()', () => { it('should create authorizer with the given config object', () => { awsCompileApigEvents.serverless.service.functions.first.events[0].http.authorizer = { name: 'authorizer', - resultTtlInSeconds: 400, + resultTtlInSeconds: 0, identitySource: 'method.request.header.Custom', identityValidationExpression: 'regex', }; @@ -117,7 +117,7 @@ describe('#compileAuthorizers()', () => { expect( awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate .Resources.AuthorizerApiGatewayAuthorizer.Properties.AuthorizerResultTtlInSeconds - ).to.equal(400); + ).to.equal(0); expect( awsCompileApigEvents.serverless.service.provider.compiledCloudFormationTemplate