@gradientedge/cdk-utils 5.10.0 → 5.13.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.
@@ -146,6 +146,11 @@ export declare class IamManager {
146
146
  * @param {string[]} resourceArns list of ARNs to allow access to
147
147
  */
148
148
  statementForReadTableItems(resourceArns?: string[]): cdk.aws_iam.PolicyStatement;
149
+ /**
150
+ * @summary Method to create iam statement to write items from dynamodb table
151
+ * @param {string[]} resourceArns list of ARNs to allow access to
152
+ */
153
+ statementForWriteTableItems(resourceArns?: string[]): cdk.aws_iam.PolicyStatement;
149
154
  /**
150
155
  * @summary Method to create iam statement for cloud trail
151
156
  * @param {string} id scoped id of the resource
@@ -337,6 +337,17 @@ class IamManager {
337
337
  resources: resourceArns ?? ['*'],
338
338
  });
339
339
  }
340
+ /**
341
+ * @summary Method to create iam statement to write items from dynamodb table
342
+ * @param {string[]} resourceArns list of ARNs to allow access to
343
+ */
344
+ statementForWriteTableItems(resourceArns) {
345
+ return new iam.PolicyStatement({
346
+ effect: iam.Effect.ALLOW,
347
+ actions: ['dynamodb:BatchWriteItem', 'dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem'],
348
+ resources: resourceArns ?? ['*'],
349
+ });
350
+ }
340
351
  /**
341
352
  * @summary Method to create iam statement for cloud trail
342
353
  * @param {string} id scoped id of the resource
@@ -58,12 +58,17 @@ class SqsManager {
58
58
  createQueue(id, scope, props, deadLetterQueue) {
59
59
  if (!props)
60
60
  throw `Queue props undefined`;
61
+ console.log(props);
61
62
  const queue = new sqs.Queue(scope, id, {
62
63
  queueName: props.queueName,
63
- visibilityTimeout: cdk.Duration.seconds(props.visibilityTimeoutInSecs),
64
- receiveMessageWaitTime: cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs),
64
+ visibilityTimeout: props.visibilityTimeoutInSecs
65
+ ? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
66
+ : undefined,
67
+ receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
68
+ ? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
69
+ : undefined,
65
70
  contentBasedDeduplication: props.contentBasedDeduplication,
66
- dataKeyReuse: cdk.Duration.seconds(props.dataKeyReuseInSecs),
71
+ dataKeyReuse: props.dataKeyReuseInSecs ? cdk.Duration.seconds(props.dataKeyReuseInSecs) : undefined,
67
72
  deadLetterQueue: !deadLetterQueue
68
73
  ? undefined
69
74
  : {
@@ -71,7 +76,7 @@ class SqsManager {
71
76
  maxReceiveCount: props.maxReceiveCount,
72
77
  },
73
78
  deduplicationScope: props.deduplicationScope,
74
- deliveryDelay: cdk.Duration.seconds(props.deliveryDelayInSecs),
79
+ deliveryDelay: props.deliveryDelayInSecs ? cdk.Duration.seconds(props.deliveryDelayInSecs) : undefined,
75
80
  encryption: props.encryption,
76
81
  encryptionMasterKey: props.encryptionMasterKey,
77
82
  fifo: props.fifo,
@@ -92,10 +97,9 @@ class SqsManager {
92
97
  * @param {types.LambdaProps} props the lambda properties
93
98
  */
94
99
  createRedriveQueueForLambda(id, scope, props) {
95
- if (!props.dlq || !props.redriveq)
100
+ if (!props.redriveq)
96
101
  throw `Redrive queue props for Lambda undefined`;
97
102
  return this.createQueue(`${id}`, scope, {
98
- ...props.dlq,
99
103
  ...props.redriveq,
100
104
  ...{
101
105
  queueName: `${props.functionName}-redriveq-${scope.props.stage}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "5.10.0",
3
+ "version": "5.13.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -46,52 +46,52 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@types/lodash": "^4.14.182",
49
- "@types/node": "^18.0.0",
49
+ "@types/node": "^18.6.1",
50
50
  "app-root-path": "^3.0.0",
51
- "aws-cdk-lib": "^2.28.1",
52
- "aws-sdk": "^2.1158.0",
53
- "constructs": "^10.1.42",
51
+ "aws-cdk-lib": "^2.33.0",
52
+ "aws-sdk": "^2.1182.0",
53
+ "constructs": "^10.1.58",
54
54
  "lodash": "^4.17.21",
55
- "moment": "^2.29.3",
55
+ "moment": "^2.29.4",
56
56
  "nconf": "^0.12.0",
57
57
  "pluralize": "^8.0.0",
58
- "ts-node": "^10.8.1"
58
+ "ts-node": "^10.9.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@babel/plugin-proposal-class-properties": "^7.17.12",
62
- "@types/jest": "^28.1.2",
63
- "@typescript-eslint/eslint-plugin": "^5.29.0",
64
- "@typescript-eslint/parser": "^5.29.0",
61
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
62
+ "@types/jest": "^28.1.6",
63
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
64
+ "@typescript-eslint/parser": "^5.31.0",
65
65
  "aws-cdk": "*",
66
66
  "babel-eslint": "^10.1.0",
67
67
  "better-docs": "^2.7.2",
68
68
  "codecov": "^3.8.3",
69
- "commitizen": "^4.2.4",
69
+ "commitizen": "^4.2.5",
70
70
  "dotenv": "^16.0.1",
71
- "eslint": "^8.18.0",
71
+ "eslint": "^8.20.0",
72
72
  "eslint-config-prettier": "^8.5.0",
73
73
  "eslint-plugin-import": "^2.26.0",
74
74
  "husky": "^8.0.1",
75
- "jest": "^28.1.1",
76
- "jest-extended": "^2.0.0",
77
- "jest-junit": "^13.2.0",
78
- "jsdoc": "^3.6.10",
75
+ "jest": "^28.1.3",
76
+ "jest-extended": "^3.0.1",
77
+ "jest-junit": "^14.0.0",
78
+ "jsdoc": "^3.6.11",
79
79
  "jsdoc-babel": "^0.5.0",
80
80
  "jsdoc-mermaid": "^1.0.0",
81
- "lerna": "^5.1.4",
81
+ "lerna": "^5.3.0",
82
82
  "prettier": "^2.7.1",
83
83
  "prettier-plugin-organize-imports": "^3.0.0",
84
84
  "rimraf": "^3.0.2",
85
85
  "semantic-release": "^19.0.3",
86
- "ts-jest": "^28.0.5",
87
- "ts-node": "^10.8.1",
86
+ "ts-jest": "^28.0.7",
87
+ "ts-node": "^10.9.1",
88
88
  "typescript": "4.7.4"
89
89
  },
90
90
  "optionalDependencies": {
91
- "@babel/core": "^7.18.5",
91
+ "@babel/core": "^7.18.9",
92
92
  "prop-types": "^15.8.1",
93
- "react": "^17.0.2",
94
- "react-dom": "^17.0.2"
93
+ "react": "^18.2.0",
94
+ "react-dom": "^18.2.0"
95
95
  },
96
96
  "config": {
97
97
  "commitizen": {
@@ -343,6 +343,18 @@ export class IamManager {
343
343
  })
344
344
  }
345
345
 
346
+ /**
347
+ * @summary Method to create iam statement to write items from dynamodb table
348
+ * @param {string[]} resourceArns list of ARNs to allow access to
349
+ */
350
+ public statementForWriteTableItems(resourceArns?: string[]) {
351
+ return new iam.PolicyStatement({
352
+ effect: iam.Effect.ALLOW,
353
+ actions: ['dynamodb:BatchWriteItem', 'dynamodb:DeleteItem', 'dynamodb:PutItem', 'dynamodb:UpdateItem'],
354
+ resources: resourceArns ?? ['*'],
355
+ })
356
+ }
357
+
346
358
  /**
347
359
  * @summary Method to create iam statement for cloud trail
348
360
  * @param {string} id scoped id of the resource
@@ -35,12 +35,18 @@ export class SqsManager {
35
35
  public createQueue(id: string, scope: common.CommonConstruct, props: types.QueueProps, deadLetterQueue?: sqs.IQueue) {
36
36
  if (!props) throw `Queue props undefined`
37
37
 
38
+ console.log(props)
39
+
38
40
  const queue = new sqs.Queue(scope, id, {
39
41
  queueName: props.queueName,
40
- visibilityTimeout: cdk.Duration.seconds(props.visibilityTimeoutInSecs),
41
- receiveMessageWaitTime: cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs),
42
+ visibilityTimeout: props.visibilityTimeoutInSecs
43
+ ? cdk.Duration.seconds(props.visibilityTimeoutInSecs)
44
+ : undefined,
45
+ receiveMessageWaitTime: props.receiveMessageWaitTimeInSecs
46
+ ? cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs)
47
+ : undefined,
42
48
  contentBasedDeduplication: props.contentBasedDeduplication,
43
- dataKeyReuse: cdk.Duration.seconds(props.dataKeyReuseInSecs),
49
+ dataKeyReuse: props.dataKeyReuseInSecs ? cdk.Duration.seconds(props.dataKeyReuseInSecs) : undefined,
44
50
  deadLetterQueue: !deadLetterQueue
45
51
  ? undefined
46
52
  : {
@@ -48,7 +54,7 @@ export class SqsManager {
48
54
  maxReceiveCount: props.maxReceiveCount,
49
55
  },
50
56
  deduplicationScope: props.deduplicationScope,
51
- deliveryDelay: cdk.Duration.seconds(props.deliveryDelayInSecs),
57
+ deliveryDelay: props.deliveryDelayInSecs ? cdk.Duration.seconds(props.deliveryDelayInSecs) : undefined,
52
58
  encryption: props.encryption,
53
59
  encryptionMasterKey: props.encryptionMasterKey,
54
60
  fifo: props.fifo,
@@ -72,10 +78,9 @@ export class SqsManager {
72
78
  * @param {types.LambdaProps} props the lambda properties
73
79
  */
74
80
  public createRedriveQueueForLambda(id: string, scope: common.CommonConstruct, props: types.LambdaProps) {
75
- if (!props.dlq || !props.redriveq) throw `Redrive queue props for Lambda undefined`
81
+ if (!props.redriveq) throw `Redrive queue props for Lambda undefined`
76
82
 
77
83
  return this.createQueue(`${id}`, scope, {
78
- ...props.dlq,
79
84
  ...props.redriveq,
80
85
  ...{
81
86
  queueName: `${props.functionName}-redriveq-${scope.props.stage}`,