diff --git a/lib/plugins/aws/package/compile/functions/index.js b/lib/plugins/aws/package/compile/functions/index.js index dcebf88cf9b..89dc9a7338e 100644 --- a/lib/plugins/aws/package/compile/functions/index.js +++ b/lib/plugins/aws/package/compile/functions/index.js @@ -581,40 +581,19 @@ class AwsCompileFunctions { compileFunctionEventInvokeConfig(functionName) { const functionObject = this.serverless.service.getFunction(functionName); - const { - destinations, - maximumEventAge: maximumEventAgeOnFunction, - maximumRetryAttempts: maximumRetryAttemptsOnFunction, - } = functionObject; - let maximumEventAgeOnDestinations; - let maximumRetryAttemptsOnDestinations; - - if (!destinations && !maximumEventAgeOnFunction && maximumRetryAttemptsOnFunction == null) { + const { destinations, maximumEventAge, maximumRetryAttempts } = functionObject; + + if (!destinations && !maximumEventAge && maximumRetryAttempts == null) { return; } const destinationConfig = {}; if (destinations) { - if (destinations.maximumRetryAttempts != null) { - this.serverless._logDeprecation( - 'AWS_FUNCTION_DESTINATIONS_ASYNC_CONFIG', - 'destinations.maximumRetryAttempts is deprecated, use maximumRetryAttempts on function instead' - ); - maximumRetryAttemptsOnDestinations = destinations.maximumRetryAttempts; - } - - if (destinations.maximumEventAge) { - this.serverless._logDeprecation( - 'AWS_FUNCTION_DESTINATIONS_ASYNC_CONFIG', - 'destinations.maximumEventAge is deprecated, use maximumEventAge on function instead' - ); - maximumEventAgeOnDestinations = destinations.maximumEventAge; - } - const hasAccessPoliciesHandledExternally = Boolean( functionObject.role || this.serverless.service.provider.role ); + if (destinations.onSuccess) { if (!hasAccessPoliciesHandledExternally) { this.ensureTargetExecutionPermission(destinations.onSuccess); @@ -625,6 +604,7 @@ class AwsCompileFunctions { : this.provider.resolveFunctionArn(destinations.onSuccess), }; } + if (destinations.onFailure) { if (!hasAccessPoliciesHandledExternally) { this.ensureTargetExecutionPermission(destinations.onFailure); @@ -640,13 +620,6 @@ class AwsCompileFunctions { const cfResources = this.serverless.service.provider.compiledCloudFormationTemplate.Resources; const functionLogicalId = this.provider.naming.getLambdaLogicalId(functionName); - const maximumEventAge = maximumEventAgeOnFunction || maximumEventAgeOnDestinations; - // For maximumRetryAttempts we cannot rely on "||" as the value can be Falsy, 0 - const maximumRetryAttempts = - maximumRetryAttemptsOnFunction == null - ? maximumRetryAttemptsOnDestinations - : maximumRetryAttemptsOnFunction; - const resource = { Type: 'AWS::Lambda::EventInvokeConfig', Properties: { diff --git a/lib/plugins/aws/package/compile/functions/index.test.js b/lib/plugins/aws/package/compile/functions/index.test.js index 33a1bad5d3e..60f7e1a0be6 100644 --- a/lib/plugins/aws/package/compile/functions/index.test.js +++ b/lib/plugins/aws/package/compile/functions/index.test.js @@ -2708,48 +2708,6 @@ describe('AwsCompileFunctions #2', () => { }); }); - it('Should support maximumEventAge defined on destination', () => { - const maximumEventAge = 3600; - return runServerless({ - fixture: 'functionDestinations', - configExt: { - functions: { trigger: { destinations: { maximumEventAge } } }, - }, - cliArgs: ['package'], - }).then(({ awsNaming, cfTemplate }) => { - const cfResources = cfTemplate.Resources; - const naming = awsNaming; - const eventInvokeConfig = - cfResources[naming.getLambdaEventConfigLogicalId('trigger')].Properties; - - expect(eventInvokeConfig.MaximumEventAgeInSeconds).to.equal(maximumEventAge); - }); - }); - - it('Should prefer maximumEventAge defined on function over defined on destination', () => { - const maximumEventAgeOnFunction = 3600; - const maximumEventAgeOnDestination = 7200; - return runServerless({ - fixture: 'functionDestinations', - configExt: { - functions: { - trigger: { - maximumEventAge: maximumEventAgeOnFunction, - destinations: { maximumEventAge: maximumEventAgeOnDestination }, - }, - }, - }, - cliArgs: ['package'], - }).then(({ awsNaming, cfTemplate }) => { - const cfResources = cfTemplate.Resources; - const naming = awsNaming; - const eventInvokeConfig = - cfResources[naming.getLambdaEventConfigLogicalId('trigger')].Properties; - - expect(eventInvokeConfig.MaximumEventAgeInSeconds).to.equal(maximumEventAgeOnFunction); - }); - }); - it('Should support maximumRetryAttempts defined on function', () => { const maximumRetryAttempts = 0; return runServerless({ @@ -2767,48 +2725,6 @@ describe('AwsCompileFunctions #2', () => { expect(eventInvokeConfig.MaximumRetryAttempts).to.equal(maximumRetryAttempts); }); }); - - it('Should support maximumRetryAttempts defined on destination', () => { - const maximumRetryAttempts = 0; - return runServerless({ - fixture: 'functionDestinations', - configExt: { - functions: { trigger: { destinations: { maximumRetryAttempts } } }, - }, - cliArgs: ['package'], - }).then(({ awsNaming, cfTemplate }) => { - const cfResources = cfTemplate.Resources; - const naming = awsNaming; - const eventInvokeConfig = - cfResources[naming.getLambdaEventConfigLogicalId('trigger')].Properties; - - expect(eventInvokeConfig.MaximumRetryAttempts).to.equal(maximumRetryAttempts); - }); - }); - - it('Should prefer maximumRetryAttempts defined on function over on destination', () => { - const maximumRetryAttemptsOnFunction = 0; - const maximumRetryAttemptsOnDestination = 1; - return runServerless({ - fixture: 'functionDestinations', - configExt: { - functions: { - trigger: { - maximumRetryAttempts: maximumRetryAttemptsOnFunction, - destinations: { maximumRetryAttempts: maximumRetryAttemptsOnDestination }, - }, - }, - }, - cliArgs: ['package'], - }).then(({ awsNaming, cfTemplate }) => { - const cfResources = cfTemplate.Resources; - const naming = awsNaming; - const eventInvokeConfig = - cfResources[naming.getLambdaEventConfigLogicalId('trigger')].Properties; - - expect(eventInvokeConfig.MaximumRetryAttempts).to.equal(maximumRetryAttemptsOnFunction); - }); - }); }); describe('when using fileSystemConfig', () => {