@gradientedge/cdk-utils 4.9.6 → 4.11.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.
Files changed (59) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/src/lib/common/construct.d.ts +3 -1
  3. package/dist/src/lib/common/construct.js +11 -3
  4. package/dist/src/lib/common/index.js +5 -1
  5. package/dist/src/lib/common/stack.js +5 -1
  6. package/dist/src/lib/construct/api-to-eventbridge-target/index.js +5 -1
  7. package/dist/src/lib/construct/api-to-eventbridge-target/main.js +5 -1
  8. package/dist/src/lib/construct/graphql-api-lambda/index.js +5 -1
  9. package/dist/src/lib/construct/graphql-api-lambda/main.js +5 -1
  10. package/dist/src/lib/construct/graphql-api-lambda-with-cache/index.js +5 -1
  11. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +5 -1
  12. package/dist/src/lib/construct/index.js +5 -1
  13. package/dist/src/lib/construct/site-with-ecs-backend/index.js +5 -1
  14. package/dist/src/lib/construct/site-with-ecs-backend/main.js +5 -1
  15. package/dist/src/lib/construct/static-site/index.js +5 -1
  16. package/dist/src/lib/construct/static-site/main.js +5 -1
  17. package/dist/src/lib/manager/aws/acm-manager.js +5 -1
  18. package/dist/src/lib/manager/aws/api-manager.js +5 -1
  19. package/dist/src/lib/manager/aws/app-config-manager.js +5 -1
  20. package/dist/src/lib/manager/aws/cloudfront-manager.js +5 -1
  21. package/dist/src/lib/manager/aws/cloudtrail-manager.js +5 -1
  22. package/dist/src/lib/manager/aws/cloudwatch-manager.js +5 -1
  23. package/dist/src/lib/manager/aws/codebuild-manager.js +5 -1
  24. package/dist/src/lib/manager/aws/dynamodb-manager.js +5 -1
  25. package/dist/src/lib/manager/aws/ecr-manager.js +5 -1
  26. package/dist/src/lib/manager/aws/ecs-manager.js +5 -1
  27. package/dist/src/lib/manager/aws/eks-manager.js +5 -1
  28. package/dist/src/lib/manager/aws/elasticache-manager.js +5 -1
  29. package/dist/src/lib/manager/aws/event-manager.js +5 -1
  30. package/dist/src/lib/manager/aws/iam-manager.d.ts +9 -0
  31. package/dist/src/lib/manager/aws/iam-manager.js +29 -1
  32. package/dist/src/lib/manager/aws/index.d.ts +2 -0
  33. package/dist/src/lib/manager/aws/index.js +7 -1
  34. package/dist/src/lib/manager/aws/kms-manager.d.ts +32 -0
  35. package/dist/src/lib/manager/aws/kms-manager.js +76 -0
  36. package/dist/src/lib/manager/aws/lambda-manager.js +5 -1
  37. package/dist/src/lib/manager/aws/log-manager.js +5 -1
  38. package/dist/src/lib/manager/aws/route53-manager.js +5 -1
  39. package/dist/src/lib/manager/aws/s3-manager.js +5 -1
  40. package/dist/src/lib/manager/aws/secrets-manager.js +5 -1
  41. package/dist/src/lib/manager/aws/sns-manager.js +5 -1
  42. package/dist/src/lib/manager/aws/sqs-manager.d.ts +34 -0
  43. package/dist/src/lib/manager/aws/sqs-manager.js +84 -0
  44. package/dist/src/lib/manager/aws/ssm-manager.js +5 -1
  45. package/dist/src/lib/manager/aws/vpc-manager.js +5 -1
  46. package/dist/src/lib/manager/aws/waf-manager.js +5 -1
  47. package/dist/src/lib/manager/index.js +5 -1
  48. package/dist/src/lib/types/aws/index.d.ts +18 -0
  49. package/dist/src/lib/types/index.js +5 -1
  50. package/dist/src/lib/utils/aws/index.js +5 -1
  51. package/dist/src/lib/utils/index.js +5 -1
  52. package/package.json +15 -15
  53. package/src/lib/common/construct.ts +7 -2
  54. package/src/lib/manager/aws/event-manager.ts +1 -0
  55. package/src/lib/manager/aws/iam-manager.ts +34 -0
  56. package/src/lib/manager/aws/index.ts +2 -0
  57. package/src/lib/manager/aws/kms-manager.ts +54 -0
  58. package/src/lib/manager/aws/sqs-manager.ts +67 -0
  59. package/src/lib/types/aws/index.ts +19 -0
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.KmsManager = void 0;
27
+ const kms = __importStar(require("aws-cdk-lib/aws-kms"));
28
+ const utils = __importStar(require("../../utils"));
29
+ /**
30
+ * @stability stable
31
+ * @category cdk-utils.kms-manager
32
+ * @subcategory Construct
33
+ * @classdesc Provides operations on AWS KMS.
34
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
35
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
36
+ * @example
37
+ * import { CommonConstruct } from '@gradientedge/cdk-utils'
38
+ *
39
+ * class CustomConstruct extends CommonConstruct {
40
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
41
+ * super(parent, id, props)
42
+ * this.props = props
43
+ * this.kms.createKey('MyKey', this)
44
+ * }
45
+ * }
46
+ *
47
+ * @see [CDK KMS Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms-readme.html}
48
+ */
49
+ class KmsManager {
50
+ /**
51
+ * @summary Method to create a KMS key
52
+ * @param {string} id scoped id of the resource
53
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
54
+ * @param {types.AcmProps} props KMS key props
55
+ */
56
+ createKey(id, scope, props) {
57
+ if (!props)
58
+ throw `KMS Key props undefined`;
59
+ const key = new kms.Key(scope, `${id}`, {
60
+ description: props.description,
61
+ alias: `${props.alias}-${scope.props.stage}`,
62
+ enableKeyRotation: props.enableKeyRotation,
63
+ enabled: props.enabled,
64
+ keySpec: props.keySpec,
65
+ keyUsage: props.keyUsage,
66
+ policy: props.policy,
67
+ admins: props.admins,
68
+ removalPolicy: props.removalPolicy,
69
+ pendingWindow: props.pendingWindow,
70
+ });
71
+ utils.createCfnOutput(`${id}-keyId`, scope, key.keyId);
72
+ utils.createCfnOutput(`${id}-keyArn`, scope, key.keyArn);
73
+ return key;
74
+ }
75
+ }
76
+ exports.KmsManager = KmsManager;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -0,0 +1,34 @@
1
+ import * as cdk from 'aws-cdk-lib';
2
+ import * as sqs from 'aws-cdk-lib/aws-sqs';
3
+ import * as common from '../../common';
4
+ import * as types from '../../types';
5
+ /**
6
+ * @stability stable
7
+ * @category cdk-utils.sqs-manager
8
+ * @subcategory Construct
9
+ * @classdesc Provides operations on AWS Simple Queue Service.
10
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
11
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
12
+ * @example
13
+ * import * as common from '@gradientedge/cdk-utils'
14
+ *
15
+ * class CustomConstruct extends common.common.CommonConstruct {
16
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
17
+ * super(parent, id, props)
18
+ * this.props = props
19
+ * this.sqsManager.createSqsQueue('MySqs', this)
20
+ * }
21
+ * }
22
+ *
23
+ * @see [CDK Simple Queue Service Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs-readme.html}
24
+ */
25
+ export declare class SqsManager {
26
+ /**
27
+ * @summary Method to create a lambda queue service
28
+ * @param {string} id scoped id of the resource
29
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
30
+ * @param {types.QueueProps} props
31
+ * @param {sqs.deadLetterQueue} deadLetterQueue
32
+ */
33
+ createQueueService(id: string, scope: common.CommonConstruct, props: types.QueueProps, deadLetterQueue?: sqs.DeadLetterQueue): cdk.aws_sqs.Queue;
34
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SqsManager = void 0;
27
+ const cdk = __importStar(require("aws-cdk-lib"));
28
+ const sqs = __importStar(require("aws-cdk-lib/aws-sqs"));
29
+ const utils = __importStar(require("../../utils"));
30
+ /**
31
+ * @stability stable
32
+ * @category cdk-utils.sqs-manager
33
+ * @subcategory Construct
34
+ * @classdesc Provides operations on AWS Simple Queue Service.
35
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
36
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
37
+ * @example
38
+ * import * as common from '@gradientedge/cdk-utils'
39
+ *
40
+ * class CustomConstruct extends common.common.CommonConstruct {
41
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
42
+ * super(parent, id, props)
43
+ * this.props = props
44
+ * this.sqsManager.createSqsQueue('MySqs', this)
45
+ * }
46
+ * }
47
+ *
48
+ * @see [CDK Simple Queue Service Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sqs-readme.html}
49
+ */
50
+ class SqsManager {
51
+ /**
52
+ * @summary Method to create a lambda queue service
53
+ * @param {string} id scoped id of the resource
54
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
55
+ * @param {types.QueueProps} props
56
+ * @param {sqs.deadLetterQueue} deadLetterQueue
57
+ */
58
+ createQueueService(id, scope, props, deadLetterQueue) {
59
+ if (!props)
60
+ throw `Queue props undefined`;
61
+ const queue = new sqs.Queue(scope, id, {
62
+ queueName: props.queueName,
63
+ visibilityTimeout: cdk.Duration.seconds(props.visibilityTimeoutInSecs),
64
+ receiveMessageWaitTime: cdk.Duration.seconds(props.receiveMessageWaitTimeInSecs),
65
+ contentBasedDeduplication: props.contentBasedDeduplication,
66
+ dataKeyReuse: cdk.Duration.seconds(props.dataKeyReuseInSecs),
67
+ deadLetterQueue: deadLetterQueue,
68
+ deduplicationScope: props.deduplicationScope,
69
+ deliveryDelay: cdk.Duration.seconds(props.deliveryDelayInSecs),
70
+ encryption: props.encryption,
71
+ encryptionMasterKey: props.encryptionMasterKey,
72
+ fifo: props.fifo,
73
+ fifoThroughputLimit: props.fifoThroughputLimit,
74
+ maxMessageSizeBytes: props.maxMessageSizeBytes,
75
+ removalPolicy: props.removalPolicy,
76
+ retentionPeriod: props.retentionPeriod,
77
+ });
78
+ utils.createCfnOutput(`${id}-queueArn`, scope, queue.queueArn);
79
+ utils.createCfnOutput(`${id}-queueName`, scope, queue.queueName);
80
+ utils.createCfnOutput(`${id}-queueUrl`, scope, queue.queueUrl);
81
+ return queue;
82
+ }
83
+ }
84
+ exports.SqsManager = SqsManager;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -14,6 +14,7 @@ import * as elasticache from 'aws-cdk-lib/aws-elasticache';
14
14
  import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2';
15
15
  import * as events from 'aws-cdk-lib/aws-events';
16
16
  import * as iam from 'aws-cdk-lib/aws-iam';
17
+ import * as kms from 'aws-cdk-lib/aws-kms';
17
18
  import * as lambda from 'aws-cdk-lib/aws-lambda';
18
19
  import * as destinations from 'aws-cdk-lib/aws-lambda-destinations';
19
20
  import * as logs from 'aws-cdk-lib/aws-logs';
@@ -21,6 +22,7 @@ import * as route53 from 'aws-cdk-lib/aws-route53';
21
22
  import * as s3 from 'aws-cdk-lib/aws-s3';
22
23
  import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
23
24
  import * as sns from 'aws-cdk-lib/aws-sns';
25
+ import * as sqs from 'aws-cdk-lib/aws-sqs';
24
26
  import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
25
27
  import * as types from '../index';
26
28
  /**
@@ -102,6 +104,12 @@ export interface HealthCheck extends elb.HealthCheck {
102
104
  intervalInSecs: number;
103
105
  timeoutInSecs: number;
104
106
  }
107
+ /**
108
+ * @category cdk-utils.kms-manager
109
+ * @subcategory Properties
110
+ */
111
+ export interface KmsKeyProps extends kms.KeyProps {
112
+ }
105
113
  /**
106
114
  * @category cdk-utils.lambda-manager
107
115
  * @subcategory Types
@@ -503,4 +511,14 @@ export interface WafWebACLProps extends wafv2.CfnWebACLProps {
503
511
  */
504
512
  export interface ElastiCacheProps extends elasticache.CfnCacheClusterProps {
505
513
  }
514
+ /**
515
+ * @category cdk-utils.sqs-manager
516
+ * @subcategory Properties
517
+ */
518
+ export interface QueueProps extends sqs.QueueProps {
519
+ visibilityTimeoutInSecs: number;
520
+ receiveMessageWaitTimeInSecs: number;
521
+ dataKeyReuseInSecs: number;
522
+ deliveryDelayInSecs: number;
523
+ }
506
524
  export {};
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "4.9.6",
3
+ "version": "4.11.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -45,32 +45,32 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@aws-cdk/aws-lambda-python-alpha": "2.13.0-alpha.0",
49
- "@types/lodash": "^4.14.178",
50
- "@types/node": "^17.0.18",
48
+ "@aws-cdk/aws-lambda-python-alpha": "2.15.0-alpha.0",
49
+ "@types/lodash": "^4.14.179",
50
+ "@types/node": "^17.0.21",
51
51
  "app-root-path": "^3.0.0",
52
- "aws-cdk-lib": "^2.13.0",
53
- "aws-sdk": "^2.1077.0",
54
- "constructs": "^10.0.66",
52
+ "aws-cdk-lib": "^2.15.0",
53
+ "aws-sdk": "^2.1085.0",
54
+ "constructs": "^10.0.77",
55
55
  "lodash": "^4.17.21",
56
56
  "moment": "^2.29.1",
57
57
  "nconf": "^0.11.3",
58
58
  "pluralize": "^8.0.0",
59
- "ts-node": "^10.5.0"
59
+ "ts-node": "^10.6.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@babel/plugin-proposal-class-properties": "^7.16.7",
63
- "@types/jest": "^27.4.0",
64
- "@typescript-eslint/eslint-plugin": "^5.12.0",
65
- "@typescript-eslint/parser": "^5.12.0",
63
+ "@types/jest": "^27.4.1",
64
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
65
+ "@typescript-eslint/parser": "^5.13.0",
66
66
  "aws-cdk": "*",
67
67
  "babel-eslint": "^10.1.0",
68
68
  "better-docs": "^2.7.2",
69
69
  "codecov": "^3.8.3",
70
70
  "commitizen": "^4.2.4",
71
71
  "dotenv": "^16.0.0",
72
- "eslint": "^8.9.0",
73
- "eslint-config-prettier": "^8.3.0",
72
+ "eslint": "^8.10.0",
73
+ "eslint-config-prettier": "^8.5.0",
74
74
  "eslint-plugin-import": "^2.25.4",
75
75
  "husky": "^7.0.4",
76
76
  "jest": "^27.5.1",
@@ -85,8 +85,8 @@
85
85
  "rimraf": "^3.0.2",
86
86
  "semantic-release": "^19.0.2",
87
87
  "ts-jest": "^27.1.3",
88
- "ts-node": "^10.5.0",
89
- "typescript": "4.5.5"
88
+ "ts-node": "^10.6.0",
89
+ "typescript": "4.6.2"
90
90
  },
91
91
  "optionalDependencies": {
92
92
  "@babel/core": "^7.17.5",
@@ -33,8 +33,10 @@ export class CommonConstruct extends Construct {
33
33
  ecrManager: aws.EcrManager
34
34
  ecsManager: aws.EcsManager
35
35
  eksManager: aws.EksManager
36
+ elasticacheManager: aws.ElastiCacheManager
36
37
  eventManager: aws.EventManager
37
38
  iamManager: aws.IamManager
39
+ kmsManager: aws.KmsManager
38
40
  lambdaManager: aws.LambdaManager
39
41
  logManager: aws.LogManager
40
42
  route53Manager: aws.Route53Manager
@@ -44,7 +46,8 @@ export class CommonConstruct extends Construct {
44
46
  ssMManager: aws.SsmManager
45
47
  vpcManager: aws.VpcManager
46
48
  wafManager: aws.WafManager
47
- elasticacheManager: aws.ElastiCacheManager
49
+ sqsManager: aws.SqsManager
50
+
48
51
  fullyQualifiedDomainName: string
49
52
 
50
53
  constructor(parent: Construct, id: string, props: types.CommonStackProps) {
@@ -61,8 +64,10 @@ export class CommonConstruct extends Construct {
61
64
  this.ecrManager = new aws.EcrManager()
62
65
  this.ecsManager = new aws.EcsManager()
63
66
  this.eksManager = new aws.EksManager()
67
+ this.elasticacheManager = new aws.ElastiCacheManager()
64
68
  this.eventManager = new aws.EventManager()
65
69
  this.iamManager = new aws.IamManager()
70
+ this.kmsManager = new aws.KmsManager()
66
71
  this.lambdaManager = new aws.LambdaManager()
67
72
  this.logManager = new aws.LogManager()
68
73
  this.route53Manager = new aws.Route53Manager()
@@ -72,7 +77,7 @@ export class CommonConstruct extends Construct {
72
77
  this.ssMManager = new aws.SsmManager()
73
78
  this.vpcManager = new aws.VpcManager()
74
79
  this.wafManager = new aws.WafManager()
75
- this.elasticacheManager = new aws.ElastiCacheManager()
80
+ this.sqsManager = new aws.SqsManager()
76
81
 
77
82
  this.determineFullyQualifiedDomain()
78
83
  }
@@ -81,6 +81,7 @@ export class EventManager {
81
81
 
82
82
  return rule
83
83
  }
84
+
84
85
  /**
85
86
  * @summary Method to create an eventbridge rule with lambda target
86
87
  * @param {string} id scoped id of the resource
@@ -1,8 +1,10 @@
1
1
  import * as cdk from 'aws-cdk-lib'
2
2
  import * as ecs from 'aws-cdk-lib/aws-ecs'
3
+ import * as events from 'aws-cdk-lib/aws-events'
3
4
  import * as iam from 'aws-cdk-lib/aws-iam'
4
5
  import * as logs from 'aws-cdk-lib/aws-logs'
5
6
  import * as s3 from 'aws-cdk-lib/aws-s3'
7
+ import * as sqs from 'aws-cdk-lib/aws-sqs'
6
8
  import * as common from '../../common'
7
9
  import * as utils from '../../utils'
8
10
 
@@ -412,4 +414,36 @@ export class IamManager {
412
414
 
413
415
  return role
414
416
  }
417
+
418
+ /**
419
+ * @summary Method to create iam policy for sqs
420
+ * @param {string} id scoped id of the resource
421
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
422
+ * @param {iam.ServicePrincipal} servicePrinicpal
423
+ */
424
+ public createPolicyForSqsEvent(
425
+ id: string,
426
+ scope: common.CommonConstruct,
427
+ sqsQueue: sqs.Queue,
428
+ eventBridgeRule: events.IRule,
429
+ servicePrincipals?: iam.ServicePrincipal[]
430
+ ) {
431
+ const policy = new iam.PolicyDocument({
432
+ statements: [
433
+ new iam.PolicyStatement({
434
+ actions: ['sqs:*'],
435
+ effect: iam.Effect.ALLOW,
436
+ conditions: {
437
+ ArnEquals: {
438
+ 'aws:SourceArn': eventBridgeRule,
439
+ },
440
+ },
441
+ principals: servicePrincipals ?? [new iam.ServicePrincipal('events.amazonaws.com')],
442
+ resources: [sqsQueue.queueArn],
443
+ }),
444
+ ],
445
+ })
446
+
447
+ return policy
448
+ }
415
449
  }
@@ -12,12 +12,14 @@ export * from './eks-manager'
12
12
  export * from './elasticache-manager'
13
13
  export * from './event-manager'
14
14
  export * from './iam-manager'
15
+ export * from './kms-manager'
15
16
  export * from './lambda-manager'
16
17
  export * from './log-manager'
17
18
  export * from './route53-manager'
18
19
  export * from './s3-manager'
19
20
  export * from './secrets-manager'
20
21
  export * from './sns-manager'
22
+ export * from './sqs-manager'
21
23
  export * from './ssm-manager'
22
24
  export * from './vpc-manager'
23
25
  export * from './waf-manager'
@@ -0,0 +1,54 @@
1
+ import * as kms from 'aws-cdk-lib/aws-kms'
2
+ import * as common from '../../common'
3
+ import * as types from '../../types/aws'
4
+ import * as utils from '../../utils'
5
+
6
+ /**
7
+ * @stability stable
8
+ * @category cdk-utils.kms-manager
9
+ * @subcategory Construct
10
+ * @classdesc Provides operations on AWS KMS.
11
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
12
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
13
+ * @example
14
+ * import { CommonConstruct } from '@gradientedge/cdk-utils'
15
+ *
16
+ * class CustomConstruct extends CommonConstruct {
17
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
18
+ * super(parent, id, props)
19
+ * this.props = props
20
+ * this.kms.createKey('MyKey', this)
21
+ * }
22
+ * }
23
+ *
24
+ * @see [CDK KMS Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms-readme.html}
25
+ */
26
+ export class KmsManager {
27
+ /**
28
+ * @summary Method to create a KMS key
29
+ * @param {string} id scoped id of the resource
30
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
31
+ * @param {types.AcmProps} props KMS key props
32
+ */
33
+ public createKey(id: string, scope: common.CommonConstruct, props: types.KmsKeyProps) {
34
+ if (!props) throw `KMS Key props undefined`
35
+
36
+ const key = new kms.Key(scope, `${id}`, {
37
+ description: props.description,
38
+ alias: `${props.alias}-${scope.props.stage}`,
39
+ enableKeyRotation: props.enableKeyRotation,
40
+ enabled: props.enabled,
41
+ keySpec: props.keySpec,
42
+ keyUsage: props.keyUsage,
43
+ policy: props.policy,
44
+ admins: props.admins,
45
+ removalPolicy: props.removalPolicy,
46
+ pendingWindow: props.pendingWindow,
47
+ })
48
+
49
+ utils.createCfnOutput(`${id}-keyId`, scope, key.keyId)
50
+ utils.createCfnOutput(`${id}-keyArn`, scope, key.keyArn)
51
+
52
+ return key
53
+ }
54
+ }