File tree 3 files changed +30
-0
lines changed
packages/@aws-cdk/aws-lambda-event-sources
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ declare const fn: lambda.Function;
71
71
fn .addEventSource (new SqsEventSource (queue , {
72
72
batchSize: 10 , // default
73
73
maxBatchingWindow: Duration .minutes (5 ),
74
+ reportBatchItemFailures: true , // default to false
74
75
}));
75
76
```
76
77
Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ export interface SqsEventSourceProps {
24
24
*/
25
25
readonly maxBatchingWindow ?: Duration ;
26
26
27
+ /**
28
+ * Allow functions to return partially successful responses for a batch of records.
29
+ *
30
+ * @see https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting
31
+ *
32
+ * @default false
33
+ */
34
+ readonly reportBatchItemFailures ?: boolean ;
35
+
27
36
/**
28
37
* If the SQS event source mapping should be enabled.
29
38
*
@@ -61,6 +70,7 @@ export class SqsEventSource implements lambda.IEventSource {
61
70
const eventSourceMapping = target . addEventSourceMapping ( `SqsEventSource:${ Names . nodeUniqueId ( this . queue . node ) } ` , {
62
71
batchSize : this . props . batchSize ,
63
72
maxBatchingWindow : this . props . maxBatchingWindow ,
73
+ reportBatchItemFailures : this . props . reportBatchItemFailures ,
64
74
enabled : this . props . enabled ,
65
75
eventSourceArn : this . queue . queueArn ,
66
76
} ) ;
Original file line number Diff line number Diff line change @@ -264,5 +264,24 @@ describe('SQSEventSource', () => {
264
264
} ) ;
265
265
266
266
267
+ } ) ;
268
+
269
+ test ( 'reportBatchItemFailures' , ( ) => {
270
+ // GIVEN
271
+ const stack = new cdk . Stack ( ) ;
272
+ const fn = new TestFunction ( stack , 'Fn' ) ;
273
+ const q = new sqs . Queue ( stack , 'Q' ) ;
274
+
275
+ // WHEN
276
+ fn . addEventSource ( new sources . SqsEventSource ( q , {
277
+ reportBatchItemFailures : true ,
278
+ } ) ) ;
279
+
280
+ // THEN
281
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::EventSourceMapping' , {
282
+ 'FunctionResponseTypes' : [ 'ReportBatchItemFailures' ] ,
283
+ } ) ;
284
+
285
+
267
286
} ) ;
268
287
} ) ;
You can’t perform that action at this time.
0 commit comments