Repository: serverless/serverless (JavaScript) — Feature

Issue:
AWS Now Supports Max Retry Attempts
Add support for the new lambda config option `MaximumRetryAttempts`.

Retry attempts – The number of times Lambda retries when the function returns an error, between 0 and 2.

https://aws.amazon.com/about-aws/whats-new/2019/11/aws-lambda-supports-max-retry-attempts-event-age-asynchronous-invocations/


Discussion:
Thanks @Gerst20051 We definitely should support that. Any help would be appreciated
Hey @Gerst20051. If you don't plan to implement this I'd like to try to take a stab at it. 
@keithalpichi Thank you!

Resolving patch:
diff --git a/docs/providers/aws/events/streams.md b/docs/providers/aws/events/streams.md
index 835de5c3b6d..f36aa98317f 100644
--- a/docs/providers/aws/events/streams.md
+++ b/docs/providers/aws/events/streams.md
@@ -80,6 +80,7 @@ functions:
           arn: arn:aws:kinesis:region:XXXXXX:stream/foo
           batchSize: 100
           startingPosition: LATEST
+          maximumRetryAttempts: 10
           enabled: false
 ```
 
@@ -109,6 +110,29 @@ functions:
           batchWindow: 10
 ```
 
+## Setting the MaximumRetryAttempts
+
+This configuration sets up the maximum number of times to retry when the function returns an error.
+
+**Note:** Serverless only sets this property if you explicitly add it to the stream configuration (see example below).
+
+[Related AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)
+
+**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you.
+
+```yml
+functions:
+  preprocess:
+    handler: handler.preprocess
+    events:
+      - stream:
+          arn: arn:aws:kinesis:region:XXXXXX:stream/foo
+          batchSize: 100
+          maximumRetryAttempts: 10
+          startingPosition: LATEST
+          enabled: false
+```
+
 ## Setting the ParallelizationFactor
 
 The configuration below sets up a Kinesis stream event for the `preprocess` function which has a parallelization factor of 10 (default is 1).
diff --git a/lib/plugins/aws/package/compile/events/stream/index.js b/lib/plugins/aws/package/compile/events/stream/index.js
index 6ae838eda85..3fab20ccb70 100644
--- a/lib/plugins/aws/package/compile/events/stream/index.js
+++ b/lib/plugins/aws/package/compile/events/stream/index.js
@@ -204,6 +204,10 @@ class AwsCompileStreamEvents {
               streamResource.Properties.MaximumBatchingWindowInSeconds = event.stream.batchWindow;
             }
 
+            if (event.stream.maximumRetryAttempts) {
+              streamResource.Properties.MaximumRetryAttempts = event.stream.maximumRetryAttempts;
+            }
+
             const newStreamObject = {
               [streamLogicalId]: streamResource,
             };


Test patch:
diff --git a/lib/plugins/aws/package/compile/events/stream/index.test.js b/lib/plugins/aws/package/compile/events/stream/index.test.js
index f3c129491dd..7be3fa156e7 100644
--- a/lib/plugins/aws/package/compile/events/stream/index.test.js
+++ b/lib/plugins/aws/package/compile/events/stream/index.test.js
@@ -373,6 +373,7 @@ describe('AwsCompileStreamEvents', () => {
                 stream: {
                   arn: 'arn:aws:dynamodb:region:account:table/bar/stream/2',
                   batchWindow: 15,
+                  maximumRetryAttempts: 4,
                 },
               },
               {
@@ -444,6 +445,10 @@ describe('AwsCompileStreamEvents', () => {
           awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate
             .Resources.FirstEventSourceMappingDynamodbBar.Properties.MaximumBatchingWindowInSeconds
         ).to.equal(15);
+        expect(
+          awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate
+            .Resources.FirstEventSourceMappingDynamodbBar.Properties.MaximumRetryAttempts
+        ).to.equal(4);
 
         // event 3
         expect(
@@ -738,6 +743,7 @@ describe('AwsCompileStreamEvents', () => {
                 stream: {
                   arn: 'arn:aws:kinesis:region:account:stream/bar',
                   batchWindow: 15,
+                  maximumRetryAttempts: 5,
                 },
               },
               {
@@ -820,6 +826,10 @@ describe('AwsCompileStreamEvents', () => {
           awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate
             .Resources.FirstEventSourceMappingKinesisBar.Properties.MaximumBatchingWindowInSeconds
         ).to.equal(15);
+        expect(
+          awsCompileStreamEvents.serverless.service.provider.compiledCloudFormationTemplate
+            .Resources.FirstEventSourceMappingKinesisBar.Properties.MaximumRetryAttempts
+        ).to.equal(5);
 
         // event 3
         expect(