@gradientedge/cdk-utils 8.66.0 → 8.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,7 @@ exports.LambdaManager = void 0;
27
27
  const cdk = __importStar(require("aws-cdk-lib"));
28
28
  const iam = __importStar(require("aws-cdk-lib/aws-iam"));
29
29
  const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
30
+ const eventSources = __importStar(require("aws-cdk-lib/aws-lambda-event-sources"));
30
31
  const common_1 = require("../../common");
31
32
  const utils = __importStar(require("../../utils"));
32
33
  const cloudfront_manager_1 = require("./cloudfront-manager");
@@ -126,6 +127,11 @@ class LambdaManager {
126
127
  insightsVersion: props.insightsVersion,
127
128
  },
128
129
  });
130
+ if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
131
+ lambdaFunction.addEventSource(new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
132
+ reportBatchItemFailures: true,
133
+ }));
134
+ }
129
135
  if (props.lambdaAliases && props.lambdaAliases.length > 0) {
130
136
  props.lambdaAliases.forEach(alias => {
131
137
  const aliasId = alias.id ?? `${id}-${alias.aliasName}`;
@@ -218,6 +224,11 @@ class LambdaManager {
218
224
  insightsVersion: props.insightsVersion,
219
225
  },
220
226
  });
227
+ if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
228
+ lambdaFunction.addEventSource(new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
229
+ reportBatchItemFailures: true,
230
+ }));
231
+ }
221
232
  utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
222
233
  utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName);
223
234
  return lambdaFunction;
@@ -845,5 +845,6 @@ export interface QueueProps extends sqs.QueueProps {
845
845
  deliveryDelayInSecs?: number;
846
846
  retentionInDays?: number;
847
847
  tags?: TagProps[];
848
+ retriesEnabled?: boolean;
848
849
  }
849
850
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.66.0",
3
+ "version": "8.67.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -3,6 +3,7 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2'
3
3
  import * as efs from 'aws-cdk-lib/aws-efs'
4
4
  import * as iam from 'aws-cdk-lib/aws-iam'
5
5
  import * as lambda from 'aws-cdk-lib/aws-lambda'
6
+ import * as eventSources from 'aws-cdk-lib/aws-lambda-event-sources'
6
7
  import * as common from '../../common'
7
8
  import { CommonStack } from '../../common'
8
9
  import * as types from '../../types'
@@ -130,6 +131,14 @@ export class LambdaManager {
130
131
  },
131
132
  })
132
133
 
134
+ if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
135
+ lambdaFunction.addEventSource(
136
+ new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
137
+ reportBatchItemFailures: true,
138
+ })
139
+ )
140
+ }
141
+
133
142
  if (props.lambdaAliases && props.lambdaAliases.length > 0) {
134
143
  props.lambdaAliases.forEach(alias => {
135
144
  const aliasId = alias.id ?? `${id}-${alias.aliasName}`
@@ -271,6 +280,14 @@ export class LambdaManager {
271
280
  },
272
281
  })
273
282
 
283
+ if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
284
+ lambdaFunction.addEventSource(
285
+ new eventSources.SqsEventSource(lambdaFunction.deadLetterQueue, {
286
+ reportBatchItemFailures: true,
287
+ })
288
+ )
289
+ }
290
+
274
291
  utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
275
292
  utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
276
293
 
@@ -906,4 +906,5 @@ export interface QueueProps extends sqs.QueueProps {
906
906
  deliveryDelayInSecs?: number
907
907
  retentionInDays?: number
908
908
  tags?: TagProps[]
909
+ retriesEnabled?: boolean
909
910
  }