@gradientedge/cdk-utils 8.118.0 → 8.119.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 (148) hide show
  1. package/app/api-destined-function/package.json +1 -1
  2. package/dist/src/lib/common/construct.d.ts +32 -32
  3. package/dist/src/lib/common/construct.js +36 -59
  4. package/dist/src/lib/common/stack.d.ts +8 -7
  5. package/dist/src/lib/common/stack.js +17 -37
  6. package/dist/src/lib/common/types.d.ts +2 -2
  7. package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
  8. package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
  9. package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
  10. package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
  11. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
  12. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
  13. package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
  14. package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
  15. package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
  16. package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
  17. package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
  18. package/dist/src/lib/construct/application-configuration/main.js +17 -41
  19. package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
  20. package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
  21. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
  22. package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
  23. package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
  24. package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
  25. package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
  26. package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
  27. package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
  28. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
  29. package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
  30. package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
  31. package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
  32. package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
  33. package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
  34. package/dist/src/lib/construct/static-site/main.d.ts +15 -15
  35. package/dist/src/lib/construct/static-site/main.js +4 -27
  36. package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
  37. package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
  38. package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
  39. package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
  40. package/dist/src/lib/services/aws/appconfig/main.js +14 -37
  41. package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
  42. package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
  43. package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
  44. package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
  45. package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
  46. package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
  47. package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
  48. package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
  49. package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
  50. package/dist/src/lib/services/aws/codebuild/main.js +7 -30
  51. package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
  52. package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
  53. package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
  54. package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
  55. package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
  56. package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
  57. package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
  58. package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
  59. package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
  60. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
  61. package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
  62. package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
  63. package/dist/src/lib/services/aws/elasticache/main.js +10 -33
  64. package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
  65. package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
  66. package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
  67. package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
  68. package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
  69. package/dist/src/lib/services/aws/evidently/main.js +18 -41
  70. package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
  71. package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
  72. package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
  73. package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
  74. package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
  75. package/dist/src/lib/services/aws/lambda/main.js +31 -58
  76. package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
  77. package/dist/src/lib/services/aws/route53/main.js +21 -44
  78. package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
  79. package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
  80. package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
  81. package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
  82. package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
  83. package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
  84. package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
  85. package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
  86. package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
  87. package/dist/src/lib/services/aws/step-function/main.js +33 -57
  88. package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
  89. package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
  90. package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
  91. package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
  92. package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
  93. package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
  94. package/dist/src/lib/utils/aws/index.d.ts +6 -3
  95. package/dist/src/lib/utils/aws/index.js +9 -26
  96. package/package.json +15 -15
  97. package/src/lib/common/construct.ts +97 -67
  98. package/src/lib/common/stack.ts +12 -12
  99. package/src/lib/common/types.ts +2 -2
  100. package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
  101. package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
  102. package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
  103. package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
  104. package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
  105. package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
  106. package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
  107. package/src/lib/construct/application-configuration/main.ts +31 -24
  108. package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
  109. package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
  110. package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
  111. package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
  112. package/src/lib/construct/rest-api-lambda/main.ts +21 -21
  113. package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
  114. package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
  115. package/src/lib/construct/static-asset-deployment/main.ts +6 -6
  116. package/src/lib/construct/static-site/main.ts +23 -17
  117. package/src/lib/services/aws/api-gateway/main.ts +42 -36
  118. package/src/lib/services/aws/api-gateway/types.ts +2 -2
  119. package/src/lib/services/aws/appconfig/main.ts +19 -19
  120. package/src/lib/services/aws/certificate-manager/main.ts +14 -14
  121. package/src/lib/services/aws/certificate-manager/types.ts +2 -2
  122. package/src/lib/services/aws/cloudfront/main.ts +88 -74
  123. package/src/lib/services/aws/cloudfront/types.ts +6 -3
  124. package/src/lib/services/aws/cloudtrail/main.ts +11 -11
  125. package/src/lib/services/aws/codebuild/main.ts +7 -7
  126. package/src/lib/services/aws/dynamodb/main.ts +8 -8
  127. package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
  128. package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
  129. package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
  130. package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
  131. package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
  132. package/src/lib/services/aws/elasticache/main.ts +10 -10
  133. package/src/lib/services/aws/eventbridge/main.ts +37 -37
  134. package/src/lib/services/aws/eventbridge/target.ts +14 -14
  135. package/src/lib/services/aws/evidently/main.ts +18 -18
  136. package/src/lib/services/aws/identity-access-management/main.ts +142 -134
  137. package/src/lib/services/aws/key-management-service/main.ts +5 -5
  138. package/src/lib/services/aws/lambda/main.ts +65 -59
  139. package/src/lib/services/aws/route53/main.ts +31 -31
  140. package/src/lib/services/aws/secrets-manager/main.ts +11 -15
  141. package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
  142. package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
  143. package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
  144. package/src/lib/services/aws/step-function/main.ts +77 -65
  145. package/src/lib/services/aws/systems-manager/main.ts +17 -12
  146. package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
  147. package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
  148. package/src/lib/utils/aws/index.ts +8 -5
@@ -1,11 +1,21 @@
1
- import * as cdk from 'aws-cdk-lib'
2
- import * as ec2 from 'aws-cdk-lib/aws-ec2'
3
- import * as ecs from 'aws-cdk-lib/aws-ecs'
4
- import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns'
5
- import * as iam from 'aws-cdk-lib/aws-iam'
6
- import * as logs from 'aws-cdk-lib/aws-logs'
7
- import * as utils from '../../../utils'
1
+ import { Duration, Tags } from 'aws-cdk-lib'
2
+ import { IVpc } from 'aws-cdk-lib/aws-ec2'
3
+ import {
4
+ Cluster,
5
+ Compatibility,
6
+ ContainerImage,
7
+ CpuArchitecture,
8
+ ICluster,
9
+ LogDriver,
10
+ NetworkMode,
11
+ OperatingSystemFamily,
12
+ TaskDefinition,
13
+ } from 'aws-cdk-lib/aws-ecs'
14
+ import { ApplicationLoadBalancedFargateService } from 'aws-cdk-lib/aws-ecs-patterns'
15
+ import { Role } from 'aws-cdk-lib/aws-iam'
16
+ import { ILogGroup } from 'aws-cdk-lib/aws-logs'
8
17
  import { CommonConstruct } from '../../../common'
18
+ import { createCfnOutput } from '../../../utils'
9
19
  import { EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EcsTaskProps } from './types'
10
20
 
11
21
  /**
@@ -16,7 +26,7 @@ import { EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EcsTask
16
26
  * import { CommonConstruct } from '@gradientedge/cdk-utils'
17
27
  *
18
28
  * class CustomConstruct extends CommonConstruct {
19
- * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
29
+ * constructor(parent: Construct, id: string, props: common.CommonStackProps) {
20
30
  * super(parent, id, props)
21
31
  * this.props = props
22
32
  * this.ecsManager.createEcsCluster('MyCluster', this, vpc)
@@ -32,10 +42,10 @@ export class EcsManager {
32
42
  * @param props
33
43
  * @param vpc
34
44
  */
35
- public createEcsCluster(id: string, scope: CommonConstruct, props: EcsClusterProps, vpc: ec2.IVpc) {
45
+ public createEcsCluster(id: string, scope: CommonConstruct, props: EcsClusterProps, vpc: IVpc) {
36
46
  if (!props) throw `Ecs Cluster props undefined for ${id}`
37
47
 
38
- const ecsCluster = new ecs.Cluster(scope, `${id}`, {
48
+ const ecsCluster = new Cluster(scope, `${id}`, {
39
49
  capacity: props.capacity,
40
50
  clusterName: `${props.clusterName}-${scope.props.stage}`,
41
51
  containerInsights: props.containerInsights,
@@ -47,12 +57,12 @@ export class EcsManager {
47
57
 
48
58
  if (props.tags && props.tags.length > 0) {
49
59
  props.tags.forEach(tag => {
50
- cdk.Tags.of(ecsCluster).add(tag.key, tag.value)
60
+ Tags.of(ecsCluster).add(tag.key, tag.value)
51
61
  })
52
62
  }
53
63
 
54
- utils.createCfnOutput(`${id}-clusterArn`, scope, ecsCluster.clusterArn)
55
- utils.createCfnOutput(`${id}-clusterName`, scope, ecsCluster.clusterName)
64
+ createCfnOutput(`${id}-clusterArn`, scope, ecsCluster.clusterArn)
65
+ createCfnOutput(`${id}-clusterName`, scope, ecsCluster.clusterName)
56
66
 
57
67
  return ecsCluster
58
68
  }
@@ -74,18 +84,18 @@ export class EcsManager {
74
84
  id: string,
75
85
  scope: CommonConstruct,
76
86
  props: EcsTaskProps,
77
- cluster: ecs.ICluster,
78
- role: iam.Role,
79
- logGroup: logs.ILogGroup,
80
- containerImage: ecs.ContainerImage,
87
+ cluster: ICluster,
88
+ role: Role,
89
+ logGroup: ILogGroup,
90
+ containerImage: ContainerImage,
81
91
  environment?: any,
82
92
  secrets?: any,
83
93
  command?: string[]
84
94
  ) {
85
95
  if (!props) throw `EcsTask props undefined for ${id}`
86
96
 
87
- const ecsTask = new ecs.TaskDefinition(scope, `${id}`, {
88
- compatibility: ecs.Compatibility.FARGATE,
97
+ const ecsTask = new TaskDefinition(scope, `${id}`, {
98
+ compatibility: Compatibility.FARGATE,
89
99
  cpu: props.cpu,
90
100
  ephemeralStorageGiB: props.ephemeralStorageGiB,
91
101
  executionRole: role,
@@ -93,13 +103,13 @@ export class EcsManager {
93
103
  inferenceAccelerators: props.inferenceAccelerators,
94
104
  ipcMode: props.ipcMode,
95
105
  memoryMiB: props.memoryMiB,
96
- networkMode: ecs.NetworkMode.AWS_VPC,
106
+ networkMode: NetworkMode.AWS_VPC,
97
107
  pidMode: props.pidMode,
98
108
  placementConstraints: props.placementConstraints,
99
109
  proxyConfiguration: props.proxyConfiguration,
100
110
  runtimePlatform: {
101
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
102
- operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
111
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? CpuArchitecture.X86_64,
112
+ operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? OperatingSystemFamily.LINUX,
103
113
  },
104
114
  taskRole: role,
105
115
  volumes: props.volumes,
@@ -111,7 +121,7 @@ export class EcsManager {
111
121
  disableNetworking: false,
112
122
  environment: environment,
113
123
  image: containerImage,
114
- logging: ecs.LogDriver.awsLogs({
124
+ logging: LogDriver.awsLogs({
115
125
  logGroup: logGroup,
116
126
  logRetention: props.logging?.logRetention,
117
127
  multilinePattern: props.logging?.multilinePattern,
@@ -124,17 +134,17 @@ export class EcsManager {
124
134
 
125
135
  if (props.tags && props.tags.length > 0) {
126
136
  props.tags.forEach(tag => {
127
- cdk.Tags.of(ecsTask).add(tag.key, tag.value)
137
+ Tags.of(ecsTask).add(tag.key, tag.value)
128
138
  })
129
139
  }
130
140
 
131
- utils.createCfnOutput(`${id}-taskArn`, scope, ecsTask.taskDefinitionArn)
141
+ createCfnOutput(`${id}-taskArn`, scope, ecsTask.taskDefinitionArn)
132
142
 
133
143
  return ecsTask
134
144
  }
135
145
 
136
146
  /**
137
- * @summary Method to create an application loadbalanced ecs fargate task
147
+ * @summary Method to create an application load balanced ecs fargate task
138
148
  * @param id scoped id of the resource
139
149
  * @param scope scope in which this resource is defined
140
150
  * @param props
@@ -145,13 +155,14 @@ export class EcsManager {
145
155
  id: string,
146
156
  scope: CommonConstruct,
147
157
  props: EcsApplicationLoadBalancedFargateServiceProps,
148
- cluster: ecs.ICluster,
149
- logGroup: logs.ILogGroup
158
+ cluster: ICluster,
159
+ logGroup: ILogGroup
150
160
  ) {
151
- if (!props) throw `EcsLoadbalanced Fargate Serivice props undefined for ${id}`
152
- if (!props.taskImageOptions) throw `TaskImageOptions for EcsLoadbalanced Fargate Serivice props undefined for ${id}`
161
+ if (!props) throw `Ecs Load balanced Fargate Service props undefined for ${id}`
162
+ if (!props.taskImageOptions)
163
+ throw `TaskImageOptions for Ecs Load balanced Fargate Service props undefined for ${id}`
153
164
 
154
- const fargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(scope, `${id}-ecs-service`, {
165
+ const fargateService = new ApplicationLoadBalancedFargateService(scope, `${id}-ecs-service`, {
155
166
  assignPublicIp: props.assignPublicIp ?? true,
156
167
  certificate: props.certificate,
157
168
  cluster: cluster,
@@ -160,13 +171,13 @@ export class EcsManager {
160
171
  domainName: props.domainName,
161
172
  domainZone: props.domainZone,
162
173
  enableECSManagedTags: true,
163
- healthCheckGracePeriod: props.healthCheckGracePeriod ?? cdk.Duration.seconds(60),
174
+ healthCheckGracePeriod: props.healthCheckGracePeriod ?? Duration.seconds(60),
164
175
  listenerPort: props.listenerPort,
165
176
  loadBalancerName: `${id}-${scope.props.stage}`,
166
177
  memoryLimitMiB: props.memoryLimitMiB,
167
178
  runtimePlatform: {
168
- cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? ecs.CpuArchitecture.X86_64,
169
- operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? ecs.OperatingSystemFamily.LINUX,
179
+ cpuArchitecture: props.runtimePlatform?.cpuArchitecture ?? CpuArchitecture.X86_64,
180
+ operatingSystemFamily: props.runtimePlatform?.operatingSystemFamily ?? OperatingSystemFamily.LINUX,
170
181
  },
171
182
  serviceName: `${id}-${scope.props.stage}`,
172
183
  taskImageOptions: {
@@ -177,7 +188,7 @@ export class EcsManager {
177
188
  image: props.taskImageOptions.image,
178
189
  logDriver:
179
190
  props.taskImageOptions?.logDriver ??
180
- ecs.LogDriver.awsLogs({
191
+ LogDriver.awsLogs({
181
192
  logGroup: logGroup,
182
193
  logRetention: props.logging?.logRetention,
183
194
  multilinePattern: props.logging?.multilinePattern,
@@ -194,11 +205,11 @@ export class EcsManager {
194
205
  healthyGrpcCodes: props.healthCheck.healthyGrpcCodes,
195
206
  healthyHttpCodes: props.healthCheck.healthyHttpCodes,
196
207
  healthyThresholdCount: props.healthCheck.healthyThresholdCount,
197
- interval: props.healthCheck.interval ?? cdk.Duration.seconds(props.healthCheck.intervalInSecs),
208
+ interval: props.healthCheck.interval ?? Duration.seconds(props.healthCheck.intervalInSecs),
198
209
  path: props.healthCheck.path ?? '/',
199
210
  port: props.healthCheck.port,
200
211
  protocol: props.healthCheck.protocol,
201
- timeout: props.healthCheck.timeout ?? cdk.Duration.seconds(props.healthCheck.timeoutInSecs),
212
+ timeout: props.healthCheck.timeout ?? Duration.seconds(props.healthCheck.timeoutInSecs),
202
213
  unhealthyThresholdCount: props.healthCheck.unhealthyThresholdCount,
203
214
  })
204
215
  }
@@ -1,8 +1,8 @@
1
- import { TagProps } from '../../../types'
2
- import { AwsLogDriverProps, ClusterProps, MountPoint, TaskDefinitionProps } from 'aws-cdk-lib/aws-ecs'
3
1
  import { ScalingSchedule } from 'aws-cdk-lib/aws-applicationautoscaling'
2
+ import { AwsLogDriverProps, ClusterProps, MountPoint, TaskDefinitionProps } from 'aws-cdk-lib/aws-ecs'
4
3
  import { ApplicationLoadBalancedFargateServiceProps } from 'aws-cdk-lib/aws-ecs-patterns'
5
- import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2'
4
+ import { HealthCheck as ElbHealthCheck } from 'aws-cdk-lib/aws-elasticloadbalancingv2'
5
+ import { TagProps } from '../../../types'
6
6
 
7
7
  /**
8
8
  */
@@ -28,7 +28,7 @@ export interface EcsScalingProps {
28
28
 
29
29
  /**
30
30
  */
31
- export interface HealthCheck extends elb.HealthCheck {
31
+ export interface HealthCheck extends ElbHealthCheck {
32
32
  intervalInSecs: number
33
33
  timeoutInSecs: number
34
34
  }
@@ -1,8 +1,8 @@
1
- import * as ec2 from 'aws-cdk-lib/aws-ec2'
2
- import * as efs from 'aws-cdk-lib/aws-efs'
3
- import * as cdk from 'aws-cdk-lib'
4
- import * as utils from '../../../utils'
1
+ import { RemovalPolicy } from 'aws-cdk-lib'
2
+ import { ISecurityGroup, IVpc, SubnetSelection } from 'aws-cdk-lib/aws-ec2'
3
+ import { FileSystem, LifecyclePolicy, OutOfInfrequentAccessPolicy, PerformanceMode } from 'aws-cdk-lib/aws-efs'
5
4
  import { CommonConstruct } from '../../../common'
5
+ import { createCfnOutput } from '../../../utils'
6
6
  import { EfsAccessPointOptions, EfsFileSystemProps } from './types'
7
7
 
8
8
  export const DEFAULT_CREATE_ACL = {
@@ -47,28 +47,28 @@ export class EfsManager {
47
47
  id: string,
48
48
  scope: CommonConstruct,
49
49
  props: EfsFileSystemProps,
50
- vpc: ec2.IVpc,
50
+ vpc: IVpc,
51
51
  accessPointOptions?: EfsAccessPointOptions[],
52
- securityGroup?: ec2.ISecurityGroup,
53
- vpcSubnets?: ec2.SubnetSelection
52
+ securityGroup?: ISecurityGroup,
53
+ vpcSubnets?: SubnetSelection
54
54
  ) {
55
55
  if (!props) throw `EFS props undefined for ${id}`
56
56
 
57
57
  const fileSystemId = props.provisionNewOnDeployment ? `${id}-${new Date().getMilliseconds()}` : `${id}`
58
- const fileSystem = new efs.FileSystem(scope, `${fileSystemId}`, {
58
+ const fileSystem = new FileSystem(scope, `${fileSystemId}`, {
59
59
  ...props,
60
60
  fileSystemName: props.fileSystemName ? `${props.fileSystemName}-${scope.props.stage}` : undefined,
61
- lifecyclePolicy: props.lifecyclePolicy ?? efs.LifecyclePolicy.AFTER_7_DAYS,
62
- outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? efs.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
63
- performanceMode: props.performanceMode ?? efs.PerformanceMode.GENERAL_PURPOSE,
64
- removalPolicy: props.removalPolicy ?? cdk.RemovalPolicy.DESTROY,
61
+ lifecyclePolicy: props.lifecyclePolicy ?? LifecyclePolicy.AFTER_7_DAYS,
62
+ outOfInfrequentAccessPolicy: props.outOfInfrequentAccessPolicy ?? OutOfInfrequentAccessPolicy.AFTER_1_ACCESS,
63
+ performanceMode: props.performanceMode ?? PerformanceMode.GENERAL_PURPOSE,
64
+ removalPolicy: props.removalPolicy ?? RemovalPolicy.DESTROY,
65
65
  securityGroup,
66
66
  vpc,
67
67
  vpcSubnets,
68
68
  })
69
69
 
70
- utils.createCfnOutput(`${id}-fileSystemArn`, scope, fileSystem.fileSystemArn)
71
- utils.createCfnOutput(`${id}-fileSystemId`, scope, fileSystem.fileSystemId)
70
+ createCfnOutput(`${id}-fileSystemArn`, scope, fileSystem.fileSystemArn)
71
+ createCfnOutput(`${id}-fileSystemId`, scope, fileSystem.fileSystemId)
72
72
 
73
73
  /* provision access points if specified */
74
74
  if (accessPointOptions && accessPointOptions.length > 0) {
@@ -80,8 +80,8 @@ export class EfsManager {
80
80
  posixUser: accessPointOption.posixUser ?? DEFAULT_POSIX_USER,
81
81
  })
82
82
 
83
- utils.createCfnOutput(`${id}-accessPointArn-${index}`, scope, accessPoint.accessPointArn)
84
- utils.createCfnOutput(`${id}-accessPointId-${index}`, scope, accessPoint.accessPointId)
83
+ createCfnOutput(`${id}-accessPointArn-${index}`, scope, accessPoint.accessPointArn)
84
+ createCfnOutput(`${id}-accessPointId-${index}`, scope, accessPoint.accessPointId)
85
85
  }
86
86
  }
87
87
 
@@ -1,8 +1,8 @@
1
- import * as ec2 from 'aws-cdk-lib/aws-ec2'
2
- import * as ecr from 'aws-cdk-lib/aws-ecr-assets'
3
- import * as eks from 'aws-cdk-lib/aws-eks'
4
- import * as utils from '../../../utils'
1
+ import { IVpc, InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2'
2
+ import { DockerImageAsset } from 'aws-cdk-lib/aws-ecr-assets'
3
+ import { Cluster, KubernetesVersion } from 'aws-cdk-lib/aws-eks'
5
4
  import { CommonConstruct } from '../../../common'
5
+ import { createCfnOutput } from '../../../utils'
6
6
  import { EksClusterProps } from './types'
7
7
 
8
8
  /**
@@ -34,8 +34,8 @@ export class EksManager {
34
34
  id: string,
35
35
  scope: CommonConstruct,
36
36
  props: EksClusterProps,
37
- image: ecr.DockerImageAsset,
38
- vpc: ec2.IVpc
37
+ image: DockerImageAsset,
38
+ vpc: IVpc
39
39
  ) {
40
40
  if (!props) throw `EksCluster props undefined for ${id}`
41
41
 
@@ -80,18 +80,18 @@ export class EksManager {
80
80
  },
81
81
  }
82
82
 
83
- const cluster = new eks.Cluster(scope, `${id}Cluster`, {
83
+ const cluster = new Cluster(scope, `${id}Cluster`, {
84
84
  clusterName: `${id.toLowerCase()}-${scope.props.stage}`,
85
85
  defaultCapacity: props.appCapacity,
86
- defaultCapacityInstance: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.LARGE),
87
- version: eks.KubernetesVersion.V1_18,
86
+ defaultCapacityInstance: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE),
87
+ version: KubernetesVersion.V1_27,
88
88
  vpc,
89
89
  })
90
90
 
91
91
  cluster.addManifest(`${id}Pod`, service, deployment)
92
92
 
93
- utils.createCfnOutput(`${id}-clusterArn`, scope, cluster.clusterArn)
94
- utils.createCfnOutput(`${id}-clusterEndpoint`, scope, cluster.clusterEndpoint)
93
+ createCfnOutput(`${id}-clusterArn`, scope, cluster.clusterArn)
94
+ createCfnOutput(`${id}-clusterEndpoint`, scope, cluster.clusterEndpoint)
95
95
 
96
96
  return cluster
97
97
  }
@@ -1,7 +1,7 @@
1
- import * as elasticache from 'aws-cdk-lib/aws-elasticache'
2
- import * as utils from '../../../utils'
3
- import * as cdk from 'aws-cdk-lib'
1
+ import { Tags } from 'aws-cdk-lib'
2
+ import { CfnCacheCluster, CfnReplicationGroup, CfnSubnetGroup } from 'aws-cdk-lib/aws-elasticache'
4
3
  import { CommonConstruct } from '../../../common'
4
+ import { createCfnOutput } from '../../../utils'
5
5
  import { ElastiCacheProps, ReplicatedElastiCacheProps } from './types'
6
6
 
7
7
  /**
@@ -28,7 +28,7 @@ export class ElastiCacheManager {
28
28
  * @param subnetIds
29
29
  */
30
30
  public createElastiCacheSubnetGroup(id: string, scope: CommonConstruct, subnetIds: string[]) {
31
- return new elasticache.CfnSubnetGroup(scope, `${id}`, {
31
+ return new CfnSubnetGroup(scope, `${id}`, {
32
32
  cacheSubnetGroupName: `${id}-subnet-group-${scope.props.stage}`,
33
33
  description: `${id}-subnet-group-${scope.props.stage}`,
34
34
  subnetIds: subnetIds,
@@ -56,7 +56,7 @@ export class ElastiCacheManager {
56
56
 
57
57
  const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds)
58
58
 
59
- const elasticacheCluster = new elasticache.CfnCacheCluster(scope, `${id}`, {
59
+ const elasticacheCluster = new CfnCacheCluster(scope, `${id}`, {
60
60
  autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
61
61
  azMode: props.azMode,
62
62
  cacheNodeType: props.cacheNodeType,
@@ -82,13 +82,13 @@ export class ElastiCacheManager {
82
82
 
83
83
  if (props.tags && props.tags.length > 0) {
84
84
  props.tags.forEach(tag => {
85
- cdk.Tags.of(elasticacheCluster).add(tag.key, tag.value)
85
+ Tags.of(elasticacheCluster).add(tag.key, tag.value)
86
86
  })
87
87
  }
88
88
 
89
- utils.createCfnOutput(`${id}-clusterName`, scope, elasticacheCluster.clusterName)
90
- utils.createCfnOutput(`${id}-redisEndpointPort`, scope, elasticacheCluster.attrRedisEndpointPort)
91
- utils.createCfnOutput(`${id}-redisEndpointAddress`, scope, elasticacheCluster.attrRedisEndpointAddress)
89
+ createCfnOutput(`${id}-clusterName`, scope, elasticacheCluster.clusterName)
90
+ createCfnOutput(`${id}-redisEndpointPort`, scope, elasticacheCluster.attrRedisEndpointPort)
91
+ createCfnOutput(`${id}-redisEndpointAddress`, scope, elasticacheCluster.attrRedisEndpointAddress)
92
92
 
93
93
  return elasticacheCluster
94
94
  }
@@ -112,7 +112,7 @@ export class ElastiCacheManager {
112
112
 
113
113
  const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds)
114
114
 
115
- const elasticacheCluster = new elasticache.CfnReplicationGroup(scope, `${id}`, {
115
+ const elasticacheCluster = new CfnReplicationGroup(scope, `${id}`, {
116
116
  autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
117
117
  automaticFailoverEnabled: props.automaticFailoverEnabled,
118
118
  cacheNodeType: props.cacheNodeType,
@@ -1,13 +1,13 @@
1
- import * as ecs from 'aws-cdk-lib/aws-ecs'
2
- import * as events from 'aws-cdk-lib/aws-events'
3
- import * as iam from 'aws-cdk-lib/aws-iam'
4
- import * as lambda from 'aws-cdk-lib/aws-lambda'
5
- import * as utils from '../../../utils'
6
- import * as cdk from 'aws-cdk-lib'
7
- import * as pipes from 'aws-cdk-lib/aws-pipes'
8
- import * as sqs from 'aws-cdk-lib/aws-sqs'
9
- import * as sfn from 'aws-cdk-lib/aws-stepfunctions'
1
+ import { Tags } from 'aws-cdk-lib'
2
+ import { ICluster, ITaskDefinition } from 'aws-cdk-lib/aws-ecs'
3
+ import { CfnRule, EventBus, IEventBus, IRuleTarget, Rule } from 'aws-cdk-lib/aws-events'
4
+ import { CfnRole, Role } from 'aws-cdk-lib/aws-iam'
5
+ import { CfnPermission, IFunction } from 'aws-cdk-lib/aws-lambda'
6
+ import { CfnPipe } from 'aws-cdk-lib/aws-pipes'
7
+ import { IQueue } from 'aws-cdk-lib/aws-sqs'
8
+ import { IStateMachine } from 'aws-cdk-lib/aws-stepfunctions'
10
9
  import { CommonConstruct } from '../../../common'
10
+ import { createCfnOutput } from '../../../utils'
11
11
  import { EventBusProps, EventRuleProps, RuleProps, SqsToSfnPipeProps } from './types'
12
12
 
13
13
  /**
@@ -18,7 +18,7 @@ import { EventBusProps, EventRuleProps, RuleProps, SqsToSfnPipeProps } from './t
18
18
  * import { CommonConstruct } from '@gradientedge/cdk-utils'
19
19
  *
20
20
  * class CustomConstruct extends CommonConstruct {
21
- * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
21
+ * constructor(parent: Construct, id: string, props: common.CommonStackProps) {
22
22
  * super(parent, id, props)
23
23
  * this.props = props
24
24
  * this.eventManager.createLambdaRule('MyLambdaRule', this, lambdaFunction)
@@ -36,12 +36,12 @@ export class EventManager {
36
36
  public createEventBus(id: string, scope: CommonConstruct, props: EventBusProps) {
37
37
  if (!props) throw `EventBus props undefined for ${id}`
38
38
 
39
- const eventBus = new events.EventBus(scope, `${id}`, {
39
+ const eventBus = new EventBus(scope, `${id}`, {
40
40
  eventBusName: `${props.eventBusName}-${scope.props.stage}`,
41
41
  })
42
42
 
43
- utils.createCfnOutput(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`)
44
- utils.createCfnOutput(`${id}-eventBusArn`, scope, eventBus.eventBusArn)
43
+ createCfnOutput(`${id}-eventBusName`, scope, `${props.eventBusName}-${scope.props.stage}`)
44
+ createCfnOutput(`${id}-eventBusArn`, scope, eventBus.eventBusArn)
45
45
 
46
46
  return eventBus
47
47
  }
@@ -58,12 +58,12 @@ export class EventManager {
58
58
  id: string,
59
59
  scope: CommonConstruct,
60
60
  props: EventRuleProps,
61
- eventBus?: events.IEventBus,
62
- targets?: events.IRuleTarget[]
61
+ eventBus?: IEventBus,
62
+ targets?: IRuleTarget[]
63
63
  ) {
64
64
  if (!props) throw `EventRule props undefined for ${id}`
65
65
 
66
- const rule = new events.Rule(scope, `${id}`, {
66
+ const rule = new Rule(scope, `${id}`, {
67
67
  description: props.description,
68
68
  enabled: props.enabled,
69
69
  eventBus: eventBus,
@@ -80,12 +80,12 @@ export class EventManager {
80
80
 
81
81
  if (props.tags && props.tags.length > 0) {
82
82
  props.tags.forEach(tag => {
83
- cdk.Tags.of(rule).add(tag.key, tag.value)
83
+ Tags.of(rule).add(tag.key, tag.value)
84
84
  })
85
85
  }
86
86
 
87
- utils.createCfnOutput(`${id}-ruleArn`, scope, rule.ruleArn)
88
- utils.createCfnOutput(`${id}-ruleName`, scope, rule.ruleName)
87
+ createCfnOutput(`${id}-ruleArn`, scope, rule.ruleArn)
88
+ createCfnOutput(`${id}-ruleName`, scope, rule.ruleName)
89
89
 
90
90
  return rule
91
91
  }
@@ -104,14 +104,14 @@ export class EventManager {
104
104
  id: string,
105
105
  scope: CommonConstruct,
106
106
  props: RuleProps,
107
- lambdaFunction: lambda.Function,
107
+ lambdaFunction: IFunction,
108
108
  eventBusName?: string,
109
109
  eventPattern?: any,
110
110
  scheduleExpression?: string
111
111
  ) {
112
112
  if (!props) throw `EventRule props undefined for ${id}`
113
113
 
114
- const eventRule = new events.CfnRule(scope, `${id}`, {
114
+ const eventRule = new CfnRule(scope, `${id}`, {
115
115
  description: 'Rule to send notification to lambda function target',
116
116
  eventBusName: eventBusName,
117
117
  eventPattern: eventPattern,
@@ -127,15 +127,15 @@ export class EventManager {
127
127
  ],
128
128
  })
129
129
 
130
- new lambda.CfnPermission(scope, `${id}LambdaPermission`, {
130
+ new CfnPermission(scope, `${id}LambdaPermission`, {
131
131
  action: 'lambda:InvokeFunction',
132
132
  functionName: lambdaFunction.functionName,
133
- principal: 'events.amazonaws.com',
133
+ principal: 'amazonaws.com',
134
134
  sourceArn: eventRule.attrArn,
135
135
  })
136
136
 
137
- utils.createCfnOutput(`${id}-ruleArn`, scope, eventRule.attrArn)
138
- utils.createCfnOutput(`${id}-ruleName`, scope, eventRule.name)
137
+ createCfnOutput(`${id}-ruleArn`, scope, eventRule.attrArn)
138
+ createCfnOutput(`${id}-ruleName`, scope, eventRule.name)
139
139
 
140
140
  return eventRule
141
141
  }
@@ -155,15 +155,15 @@ export class EventManager {
155
155
  id: string,
156
156
  scope: CommonConstruct,
157
157
  props: RuleProps,
158
- cluster: ecs.ICluster,
159
- task: ecs.ITaskDefinition,
158
+ cluster: ICluster,
159
+ task: ITaskDefinition,
160
160
  subnetIds: string[],
161
- role: iam.Role | iam.CfnRole,
161
+ role: Role | CfnRole,
162
162
  eventPattern?: any
163
163
  ) {
164
164
  if (!props) throw `EventRule props undefined for ${id}`
165
165
 
166
- const eventRule = new events.CfnRule(scope, `${id}`, {
166
+ const eventRule = new CfnRule(scope, `${id}`, {
167
167
  description: 'Rule to send notification on new objects in data bucket to ecs task target',
168
168
  eventPattern: eventPattern,
169
169
  name: `${props.name}-${scope.props.stage}`,
@@ -180,13 +180,13 @@ export class EventManager {
180
180
  taskDefinitionArn: task.taskDefinitionArn,
181
181
  },
182
182
  id: `${id}-${scope.props.stage}`,
183
- roleArn: role instanceof iam.Role ? role.roleArn : role.attrArn,
183
+ roleArn: role instanceof Role ? role.roleArn : role.attrArn,
184
184
  },
185
185
  ],
186
186
  })
187
187
 
188
- utils.createCfnOutput(`${id}-ruleArn`, scope, eventRule.attrArn)
189
- utils.createCfnOutput(`${id}-ruleName`, scope, eventRule.name)
188
+ createCfnOutput(`${id}-ruleArn`, scope, eventRule.attrArn)
189
+ createCfnOutput(`${id}-ruleName`, scope, eventRule.name)
190
190
 
191
191
  return eventRule
192
192
  }
@@ -203,8 +203,8 @@ export class EventManager {
203
203
  id: string,
204
204
  scope: CommonConstruct,
205
205
  props: SqsToSfnPipeProps,
206
- sourceQueue: sqs.IQueue,
207
- targetStepFunction: sfn.IStateMachine
206
+ sourceQueue: IQueue,
207
+ targetStepFunction: IStateMachine
208
208
  ) {
209
209
  const pipeRole = scope.iamManager.createRoleForSqsToSfnPipe(
210
210
  `${id}-role`,
@@ -213,7 +213,7 @@ export class EventManager {
213
213
  targetStepFunction.stateMachineArn
214
214
  )
215
215
 
216
- const pipe = new pipes.CfnPipe(scope, `${id}`, {
216
+ const pipe = new CfnPipe(scope, `${id}`, {
217
217
  ...props,
218
218
  description: props.description,
219
219
  enrichment: props.enrichment,
@@ -245,8 +245,8 @@ export class EventManager {
245
245
  },
246
246
  })
247
247
 
248
- utils.createCfnOutput(`${id}-pipeArn`, scope, pipe.attrArn)
249
- utils.createCfnOutput(`${id}-pipeName`, scope, pipe.name)
248
+ createCfnOutput(`${id}-pipeArn`, scope, pipe.attrArn)
249
+ createCfnOutput(`${id}-pipeName`, scope, pipe.name)
250
250
 
251
251
  return pipe
252
252
  }
@@ -1,11 +1,11 @@
1
- import * as cdk from 'aws-cdk-lib'
2
- import * as events from 'aws-cdk-lib/aws-events'
3
- import * as targets from 'aws-cdk-lib/aws-events-targets'
4
- import * as logs from 'aws-cdk-lib/aws-logs'
1
+ import { ArnFormat, Stack } from 'aws-cdk-lib'
2
+ import { IRule, IRuleTarget, RuleTargetConfig, RuleTargetInput } from 'aws-cdk-lib/aws-events'
3
+ import { TargetBaseProps, bindBaseTargetConfig } from 'aws-cdk-lib/aws-events-targets'
4
+ import { ILogGroup } from 'aws-cdk-lib/aws-logs'
5
5
  import { CommonConstruct } from '../../../common'
6
6
 
7
7
  /**
8
- * @classdesc Provides operations on AWS EventBridge Targets.
8
+ * @classdesc Provides operations on AWS EventBridge Targets
9
9
  * - A new instance of this class is injected into {@link CommonConstruct} constructor.
10
10
  * - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
11
11
  * @example
@@ -32,7 +32,7 @@ export class EventTargetManager {
32
32
  public createCloudWatchLogGroupNoPolicy(
33
33
  id: string,
34
34
  scope: CommonConstruct,
35
- logGroup: logs.ILogGroup,
35
+ logGroup: ILogGroup,
36
36
  props?: LogGroupNoPolicyProps
37
37
  ) {
38
38
  return new CloudWatchLogGroupNoPolicy(logGroup, props)
@@ -42,22 +42,22 @@ export class EventTargetManager {
42
42
  /**
43
43
  * Customize the CloudWatch LogGroup Event Target
44
44
  */
45
- export interface LogGroupNoPolicyProps extends targets.TargetBaseProps {
45
+ export interface LogGroupNoPolicyProps extends TargetBaseProps {
46
46
  /**
47
47
  * The event to send to the CloudWatch LogGroup
48
48
  *
49
49
  * This will be the event logged into the CloudWatch LogGroup
50
50
  * @default - the entire EventBridge event
51
51
  */
52
- readonly event?: events.RuleTargetInput
52
+ readonly event?: RuleTargetInput
53
53
  }
54
54
 
55
55
  /**
56
56
  * Use an AWS CloudWatch LogGroup as an event rule target, but don't apply a policy.
57
57
  */
58
- export class CloudWatchLogGroupNoPolicy implements events.IRuleTarget {
58
+ export class CloudWatchLogGroupNoPolicy implements IRuleTarget {
59
59
  constructor(
60
- private readonly logGroup: logs.ILogGroup,
60
+ private readonly logGroup: ILogGroup,
61
61
  private readonly props: LogGroupNoPolicyProps = {}
62
62
  ) {}
63
63
 
@@ -66,13 +66,13 @@ export class CloudWatchLogGroupNoPolicy implements events.IRuleTarget {
66
66
  * @param _rule
67
67
  * @param _id
68
68
  */
69
- public bind(_rule: events.IRule, _id?: string): events.RuleTargetConfig {
70
- const logGroupStack = cdk.Stack.of(this.logGroup)
69
+ public bind(_rule: IRule, _id?: string): RuleTargetConfig {
70
+ const logGroupStack = Stack.of(this.logGroup)
71
71
 
72
72
  return {
73
- ...targets.bindBaseTargetConfig(this.props),
73
+ ...bindBaseTargetConfig(this.props),
74
74
  arn: logGroupStack.formatArn({
75
- arnFormat: cdk.ArnFormat.COLON_RESOURCE_NAME,
75
+ arnFormat: ArnFormat.COLON_RESOURCE_NAME,
76
76
  resource: 'log-group',
77
77
  resourceName: this.logGroup.logGroupName,
78
78
  service: 'logs',