@gradientedge/cdk-utils 8.122.0 → 8.123.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.
- package/dist/src/lib/aws/common/stack.js +5 -7
- package/dist/src/lib/aws/construct/api-to-any-target/main.js +24 -26
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +85 -103
- package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +94 -120
- package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +8 -10
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +5 -1
- package/dist/src/lib/aws/construct/rest-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +8 -6
- package/dist/src/lib/aws/construct/static-asset-deployment/main.js +5 -1
- package/dist/src/lib/aws/services/api-gateway/main.js +18 -10
- package/dist/src/lib/aws/services/cloudfront/main.js +11 -7
- package/dist/src/lib/aws/services/cloudwatch/logs.js +8 -4
- package/dist/src/lib/aws/services/cloudwatch/main.js +36 -78
- package/dist/src/lib/aws/services/dynamodb/main.js +6 -2
- package/dist/src/lib/aws/services/elastic-container-service/main.js +8 -4
- package/dist/src/lib/aws/services/elastic-file-system/main.js +5 -1
- package/dist/src/lib/aws/services/elasticache/main.js +6 -2
- package/dist/src/lib/aws/services/eventbridge/main.js +8 -4
- package/dist/src/lib/aws/services/lambda/main.js +7 -3
- package/dist/src/lib/aws/services/simple-notification-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-queue-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-storage-service/main.js +8 -4
- package/dist/src/lib/aws/services/step-function/main.js +52 -32
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -4
- package/dist/src/lib/azure/common/stack.js +5 -7
- package/dist/src/lib/common/index.js +7 -3
- package/package.json +8 -8
- package/src/lib/aws/common/stack.ts +5 -7
- package/src/lib/aws/construct/api-to-any-target/main.ts +25 -27
- package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +85 -103
- package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +94 -120
- package/src/lib/aws/construct/api-to-lambda-target/main.ts +8 -10
- package/src/lib/aws/construct/graphql-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/lambda-with-iam-access/main.ts +2 -1
- package/src/lib/aws/construct/rest-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +8 -9
- package/src/lib/aws/construct/static-asset-deployment/main.ts +2 -1
- package/src/lib/aws/services/api-gateway/main.ts +9 -6
- package/src/lib/aws/services/cloudfront/main.ts +8 -7
- package/src/lib/aws/services/cloudwatch/logs.ts +6 -5
- package/src/lib/aws/services/cloudwatch/main.ts +35 -81
- package/src/lib/aws/services/dynamodb/main.ts +3 -2
- package/src/lib/aws/services/elastic-container-service/main.ts +5 -4
- package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
- package/src/lib/aws/services/elasticache/main.ts +3 -2
- package/src/lib/aws/services/eventbridge/main.ts +5 -4
- package/src/lib/aws/services/lambda/main.ts +4 -3
- package/src/lib/aws/services/simple-notification-service/main.ts +3 -2
- package/src/lib/aws/services/simple-queue-service/main.ts +3 -2
- package/src/lib/aws/services/simple-storage-service/main.ts +5 -4
- package/src/lib/aws/services/step-function/main.ts +17 -16
- package/src/lib/aws/services/virtual-private-cloud/main.ts +5 -4
- package/src/lib/azure/common/stack.ts +7 -9
- package/src/lib/common/index.ts +5 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib'
|
|
2
2
|
import * as watch from 'aws-cdk-lib/aws-cloudwatch'
|
|
3
3
|
import { IMetric } from 'aws-cdk-lib/aws-cloudwatch'
|
|
4
|
-
import
|
|
4
|
+
import _ from 'lodash'
|
|
5
5
|
import { CommonConstruct } from '../../common'
|
|
6
|
+
import * as utils from '../../utils'
|
|
6
7
|
import {
|
|
7
8
|
AlarmProps,
|
|
8
9
|
AlarmStatusWidgetProps,
|
|
@@ -56,9 +57,10 @@ export class CloudWatchManager {
|
|
|
56
57
|
if (!props.metricProps) throw `Could not find metricProps for Alarm props for id:${id}`
|
|
57
58
|
|
|
58
59
|
const metrics: any = {}
|
|
59
|
-
this.determineMetrics(scope, props.metricProps).
|
|
60
|
-
|
|
61
|
-
)
|
|
60
|
+
_.map(this.determineMetrics(scope, props.metricProps), (metric: watch.IMetric, index: number) => {
|
|
61
|
+
metrics[`m${index}`] = metric
|
|
62
|
+
})
|
|
63
|
+
|
|
62
64
|
const expression = new watch.MathExpression({
|
|
63
65
|
expression: props.expression,
|
|
64
66
|
period: props.periodInSecs ? cdk.Duration.seconds(props.periodInSecs) : cdk.Duration.minutes(5),
|
|
@@ -139,7 +141,9 @@ export class CloudWatchManager {
|
|
|
139
141
|
if (!props || props.length == 0) throw `Widget props undefined`
|
|
140
142
|
|
|
141
143
|
const widgets: any = []
|
|
142
|
-
|
|
144
|
+
_.forEach(props, (widgetProps: any) => {
|
|
145
|
+
widgets.push(this.createWidget(widgetProps.id, scope, widgetProps))
|
|
146
|
+
})
|
|
143
147
|
|
|
144
148
|
return widgets
|
|
145
149
|
}
|
|
@@ -188,9 +192,7 @@ export class CloudWatchManager {
|
|
|
188
192
|
const metricProps: any[] = props.metricProps
|
|
189
193
|
return this.createWidget(id, scope, {
|
|
190
194
|
...props,
|
|
191
|
-
...
|
|
192
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ distributionId: distributionId } })),
|
|
193
|
-
},
|
|
195
|
+
metricProps: _.map(metricProps, { ..._, distributionId }),
|
|
194
196
|
})
|
|
195
197
|
}
|
|
196
198
|
|
|
@@ -206,9 +208,7 @@ export class CloudWatchManager {
|
|
|
206
208
|
const metricProps: any[] = props.metricProps
|
|
207
209
|
return this.createWidget(id, scope, {
|
|
208
210
|
...props,
|
|
209
|
-
...
|
|
210
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ stateMachineArn: stateMachineArn } })),
|
|
211
|
-
},
|
|
211
|
+
metricProps: _.map(metricProps, { ..._, stateMachineArn }),
|
|
212
212
|
})
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -225,12 +225,7 @@ export class CloudWatchManager {
|
|
|
225
225
|
const metricProps: any[] = props.metricProps
|
|
226
226
|
return this.createWidget(id, scope, {
|
|
227
227
|
...props,
|
|
228
|
-
...
|
|
229
|
-
metricProps: metricProps.map(metricProp => ({
|
|
230
|
-
...metricProp,
|
|
231
|
-
...{ eventBusName: eventBusName, ruleName: ruleName },
|
|
232
|
-
})),
|
|
233
|
-
},
|
|
228
|
+
metricProps: _.map(metricProps, { ..._, eventBusName, ruleName }),
|
|
234
229
|
})
|
|
235
230
|
}
|
|
236
231
|
|
|
@@ -246,9 +241,7 @@ export class CloudWatchManager {
|
|
|
246
241
|
const metricProps: any[] = props.metricProps
|
|
247
242
|
return this.createWidget(id, scope, {
|
|
248
243
|
...props,
|
|
249
|
-
...
|
|
250
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ apiName: apiName } })),
|
|
251
|
-
},
|
|
244
|
+
metricProps: _.map(metricProps, { ..._, apiName }),
|
|
252
245
|
})
|
|
253
246
|
}
|
|
254
247
|
|
|
@@ -264,9 +257,7 @@ export class CloudWatchManager {
|
|
|
264
257
|
const metricProps: any[] = props.metricProps
|
|
265
258
|
return this.createWidget(id, scope, {
|
|
266
259
|
...props,
|
|
267
|
-
...
|
|
268
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ functionName: functionName } })),
|
|
269
|
-
},
|
|
260
|
+
metricProps: _.map(metricProps, { ..._, functionName }),
|
|
270
261
|
})
|
|
271
262
|
}
|
|
272
263
|
|
|
@@ -282,9 +273,7 @@ export class CloudWatchManager {
|
|
|
282
273
|
const metricProps: any[] = props.metricProps
|
|
283
274
|
return this.createWidget(id, scope, {
|
|
284
275
|
...props,
|
|
285
|
-
...
|
|
286
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ service: service } })),
|
|
287
|
-
},
|
|
276
|
+
metricProps: _.map(metricProps, { ..._, service }),
|
|
288
277
|
})
|
|
289
278
|
}
|
|
290
279
|
|
|
@@ -300,9 +289,7 @@ export class CloudWatchManager {
|
|
|
300
289
|
const metricProps: any[] = props.metricProps
|
|
301
290
|
return this.createWidget(id, scope, {
|
|
302
291
|
...props,
|
|
303
|
-
...
|
|
304
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ clusterName: clusterName } })),
|
|
305
|
-
},
|
|
292
|
+
metricProps: _.map(metricProps, { ..._, clusterName }),
|
|
306
293
|
})
|
|
307
294
|
}
|
|
308
295
|
|
|
@@ -325,12 +312,7 @@ export class CloudWatchManager {
|
|
|
325
312
|
const metricProps: any[] = props.metricProps
|
|
326
313
|
return this.createWidget(id, scope, {
|
|
327
314
|
...props,
|
|
328
|
-
...
|
|
329
|
-
metricProps: metricProps.map(metricProp => ({
|
|
330
|
-
...metricProp,
|
|
331
|
-
...{ clusterName: clusterName, serviceName: serviceName },
|
|
332
|
-
})),
|
|
333
|
-
},
|
|
315
|
+
metricProps: _.map(metricProps, { ..._, clusterName, serviceName }),
|
|
334
316
|
})
|
|
335
317
|
}
|
|
336
318
|
|
|
@@ -346,9 +328,7 @@ export class CloudWatchManager {
|
|
|
346
328
|
const metricProps: any[] = props.metricProps
|
|
347
329
|
return this.createWidget(id, scope, {
|
|
348
330
|
...props,
|
|
349
|
-
...
|
|
350
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ loadBalancer: loadBalancer } })),
|
|
351
|
-
},
|
|
331
|
+
metricProps: _.map(metricProps, { ..._, loadBalancer }),
|
|
352
332
|
})
|
|
353
333
|
}
|
|
354
334
|
|
|
@@ -364,9 +344,7 @@ export class CloudWatchManager {
|
|
|
364
344
|
const metricProps: any[] = props.metricProps
|
|
365
345
|
return this.createWidget(id, scope, {
|
|
366
346
|
...props,
|
|
367
|
-
...
|
|
368
|
-
metricProps: metricProps.map(metricProp => ({ ...metricProp, ...{ cacheClusterId: cacheClusterId } })),
|
|
369
|
-
},
|
|
347
|
+
metricProps: _.map(metricProps, { ..._, cacheClusterId }),
|
|
370
348
|
})
|
|
371
349
|
}
|
|
372
350
|
|
|
@@ -541,101 +519,77 @@ export class CloudWatchManager {
|
|
|
541
519
|
if (metricProp.functionName) {
|
|
542
520
|
metricDimensions = {
|
|
543
521
|
...metricProp.dimensionsMap,
|
|
544
|
-
|
|
545
|
-
FunctionName: `${metricProp.functionName}`,
|
|
546
|
-
},
|
|
522
|
+
FunctionName: `${metricProp.functionName}`,
|
|
547
523
|
}
|
|
548
524
|
}
|
|
549
525
|
if (metricProp.serviceName && metricProp.clusterName) {
|
|
550
526
|
metricDimensions = {
|
|
551
527
|
...metricProp.dimensionsMap,
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
ServiceName: `${metricProp.serviceName}`,
|
|
555
|
-
},
|
|
528
|
+
ClusterName: `${metricProp.clusterName}`,
|
|
529
|
+
ServiceName: `${metricProp.serviceName}`,
|
|
556
530
|
}
|
|
557
531
|
}
|
|
558
532
|
if (!metricProp.serviceName && metricProp.clusterName) {
|
|
559
533
|
metricDimensions = {
|
|
560
534
|
...metricProp.dimensionsMap,
|
|
561
|
-
|
|
562
|
-
ClusterName: `${metricProp.clusterName}`,
|
|
563
|
-
},
|
|
535
|
+
ClusterName: `${metricProp.clusterName}`,
|
|
564
536
|
}
|
|
565
537
|
}
|
|
566
538
|
if (metricProp.serviceName && !metricProp.clusterName) {
|
|
567
539
|
metricDimensions = {
|
|
568
540
|
...metricProp.dimensionsMap,
|
|
569
|
-
|
|
570
|
-
ServiceName: `${metricProp.serviceName}`,
|
|
571
|
-
},
|
|
541
|
+
ServiceName: `${metricProp.serviceName}`,
|
|
572
542
|
}
|
|
573
543
|
}
|
|
574
544
|
if (metricProp.loadBalancer) {
|
|
575
545
|
metricDimensions = {
|
|
576
546
|
...metricProp.dimensionsMap,
|
|
577
|
-
|
|
578
|
-
LoadBalancer: `${metricProp.loadBalancer}`,
|
|
579
|
-
},
|
|
547
|
+
LoadBalancer: `${metricProp.loadBalancer}`,
|
|
580
548
|
}
|
|
581
549
|
}
|
|
582
550
|
if (metricProp.service) {
|
|
583
551
|
metricDimensions = {
|
|
584
552
|
...metricProp.dimensionsMap,
|
|
585
|
-
|
|
586
|
-
service: `${metricProp.service}`,
|
|
587
|
-
},
|
|
553
|
+
service: `${metricProp.service}`,
|
|
588
554
|
}
|
|
589
555
|
}
|
|
590
556
|
if (metricProp.distributionId) {
|
|
591
557
|
metricDimensions = {
|
|
592
558
|
...metricProp.dimensionsMap,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
Region: `Global`,
|
|
596
|
-
},
|
|
559
|
+
DistributionId: `${metricProp.distributionId}`,
|
|
560
|
+
Region: `Global`,
|
|
597
561
|
}
|
|
598
562
|
}
|
|
599
563
|
if (metricProp.apiName) {
|
|
600
564
|
metricDimensions = {
|
|
601
565
|
...metricProp.dimensionsMap,
|
|
602
|
-
|
|
603
|
-
ApiName: `${metricProp.apiName}`,
|
|
604
|
-
},
|
|
566
|
+
ApiName: `${metricProp.apiName}`,
|
|
605
567
|
}
|
|
606
568
|
}
|
|
607
569
|
if (metricProp.cacheClusterId) {
|
|
608
570
|
metricDimensions = {
|
|
609
571
|
...metricProp.dimensionsMap,
|
|
610
|
-
|
|
611
|
-
CacheClusterId: `${metricProp.cacheClusterId}`,
|
|
612
|
-
},
|
|
572
|
+
CacheClusterId: `${metricProp.cacheClusterId}`,
|
|
613
573
|
}
|
|
614
574
|
}
|
|
615
575
|
if (metricProp.dbClusterIdentifier) {
|
|
616
576
|
metricDimensions = {
|
|
617
577
|
...metricProp.dimensionsMap,
|
|
618
|
-
|
|
619
|
-
DBClusterIdentifier: `${metricProp.dbClusterIdentifier}`,
|
|
620
|
-
},
|
|
578
|
+
DBClusterIdentifier: `${metricProp.dbClusterIdentifier}`,
|
|
621
579
|
}
|
|
622
580
|
}
|
|
623
581
|
if (metricProp.stateMachineArn) {
|
|
624
582
|
metricDimensions = {
|
|
625
583
|
...metricProp.dimensionsMap,
|
|
626
|
-
|
|
627
|
-
StateMachineArn: `${metricProp.stateMachineArn}`,
|
|
628
|
-
},
|
|
584
|
+
StateMachineArn: `${metricProp.stateMachineArn}`,
|
|
629
585
|
}
|
|
630
586
|
}
|
|
631
587
|
|
|
632
588
|
if (metricProp.eventBusName && metricProp.ruleName) {
|
|
633
589
|
metricDimensions = {
|
|
634
590
|
...metricProp.dimensionsMap,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
RuleName: `${metricProp.ruleName}`,
|
|
638
|
-
},
|
|
591
|
+
EventBusName: `${metricProp.eventBusName}`,
|
|
592
|
+
RuleName: `${metricProp.ruleName}`,
|
|
639
593
|
}
|
|
640
594
|
}
|
|
641
595
|
const metric = new watch.Metric({
|
|
@@ -679,7 +633,7 @@ export class CloudWatchManager {
|
|
|
679
633
|
private determineAlarms(id: string, scope: CommonConstruct, alarmProps: watch.AlarmProps[]) {
|
|
680
634
|
const alarms: watch.IAlarm[] = []
|
|
681
635
|
if (alarmProps) {
|
|
682
|
-
|
|
636
|
+
_.forEach(alarmProps, (alarmProp: watch.AlarmProps) => {
|
|
683
637
|
if (!alarmProp.alarmName) throw `Alarm name undefined for ${id}`
|
|
684
638
|
const alarmArn = `arn:aws:cloudwatch:${cdk.Stack.of(scope).region}:${cdk.Stack.of(scope).account}:alarm:${
|
|
685
639
|
alarmProp.alarmName
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tags } from 'aws-cdk-lib'
|
|
2
2
|
import { Table } from 'aws-cdk-lib/aws-dynamodb'
|
|
3
|
+
import _ from 'lodash'
|
|
3
4
|
import { CommonConstruct } from '../../common'
|
|
4
5
|
import { createCfnOutput } from '../../utils'
|
|
5
6
|
import { TableProps } from './types'
|
|
@@ -50,8 +51,8 @@ export class DynamodbManager {
|
|
|
50
51
|
writeCapacity: props.writeCapacity,
|
|
51
52
|
})
|
|
52
53
|
|
|
53
|
-
if (props.tags && props.tags
|
|
54
|
-
props.tags
|
|
54
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
55
|
+
_.forEach(props.tags, tag => {
|
|
55
56
|
Tags.of(table).add(tag.key, tag.value)
|
|
56
57
|
})
|
|
57
58
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { ApplicationLoadBalancedFargateService } from 'aws-cdk-lib/aws-ecs-patterns'
|
|
15
15
|
import { Role } from 'aws-cdk-lib/aws-iam'
|
|
16
16
|
import { ILogGroup } from 'aws-cdk-lib/aws-logs'
|
|
17
|
+
import _ from 'lodash'
|
|
17
18
|
import { CommonConstruct } from '../../common'
|
|
18
19
|
import { createCfnOutput } from '../../utils'
|
|
19
20
|
import { EcsApplicationLoadBalancedFargateServiceProps, EcsClusterProps, EcsTaskProps } from './types'
|
|
@@ -55,8 +56,8 @@ export class EcsManager {
|
|
|
55
56
|
vpc: vpc,
|
|
56
57
|
})
|
|
57
58
|
|
|
58
|
-
if (props.tags && props.tags
|
|
59
|
-
props.tags
|
|
59
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
60
|
+
_.forEach(props.tags, tag => {
|
|
60
61
|
Tags.of(ecsCluster).add(tag.key, tag.value)
|
|
61
62
|
})
|
|
62
63
|
}
|
|
@@ -132,8 +133,8 @@ export class EcsManager {
|
|
|
132
133
|
secrets: secrets,
|
|
133
134
|
})
|
|
134
135
|
|
|
135
|
-
if (props.tags && props.tags
|
|
136
|
-
props.tags
|
|
136
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
137
|
+
_.forEach(props.tags, tag => {
|
|
137
138
|
Tags.of(ecsTask).add(tag.key, tag.value)
|
|
138
139
|
})
|
|
139
140
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RemovalPolicy } from 'aws-cdk-lib'
|
|
2
2
|
import { ISecurityGroup, IVpc, SubnetSelection } from 'aws-cdk-lib/aws-ec2'
|
|
3
3
|
import { FileSystem, LifecyclePolicy, OutOfInfrequentAccessPolicy, PerformanceMode } from 'aws-cdk-lib/aws-efs'
|
|
4
|
+
import _ from 'lodash'
|
|
4
5
|
import { CommonConstruct } from '../../common'
|
|
5
6
|
import { createCfnOutput } from '../../utils'
|
|
6
7
|
import { EfsAccessPointOptions, EfsFileSystemProps } from './types'
|
|
@@ -71,7 +72,7 @@ export class EfsManager {
|
|
|
71
72
|
createCfnOutput(`${id}-fileSystemId`, scope, fileSystem.fileSystemId)
|
|
72
73
|
|
|
73
74
|
/* provision access points if specified */
|
|
74
|
-
if (accessPointOptions && accessPointOptions
|
|
75
|
+
if (accessPointOptions && !_.isEmpty(accessPointOptions)) {
|
|
75
76
|
for (const [index, accessPointOption] of accessPointOptions.entries()) {
|
|
76
77
|
if (!accessPointOption.path) throw `Undefined access point path for option: [${accessPointOption}], id: [${id}]`
|
|
77
78
|
const accessPoint = fileSystem.addAccessPoint(`${id}-ap-${index}`, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tags } from 'aws-cdk-lib'
|
|
2
2
|
import { CfnCacheCluster, CfnReplicationGroup, CfnSubnetGroup } from 'aws-cdk-lib/aws-elasticache'
|
|
3
|
+
import _ from 'lodash'
|
|
3
4
|
import { CommonConstruct } from '../../common'
|
|
4
5
|
import { createCfnOutput } from '../../utils'
|
|
5
6
|
import { ElastiCacheProps, ReplicatedElastiCacheProps } from './types'
|
|
@@ -80,8 +81,8 @@ export class ElastiCacheManager {
|
|
|
80
81
|
|
|
81
82
|
elasticacheCluster.addDependency(subnetGroup)
|
|
82
83
|
|
|
83
|
-
if (props.tags && props.tags
|
|
84
|
-
props.tags
|
|
84
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
85
|
+
_.forEach(props.tags, tag => {
|
|
85
86
|
Tags.of(elasticacheCluster).add(tag.key, tag.value)
|
|
86
87
|
})
|
|
87
88
|
}
|
|
@@ -6,6 +6,7 @@ import { CfnPermission, IFunction } from 'aws-cdk-lib/aws-lambda'
|
|
|
6
6
|
import { CfnPipe } from 'aws-cdk-lib/aws-pipes'
|
|
7
7
|
import { IQueue } from 'aws-cdk-lib/aws-sqs'
|
|
8
8
|
import { IStateMachine } from 'aws-cdk-lib/aws-stepfunctions'
|
|
9
|
+
import _ from 'lodash'
|
|
9
10
|
import { CommonConstruct } from '../../common'
|
|
10
11
|
import { createCfnOutput } from '../../utils'
|
|
11
12
|
import { EventBusProps, EventRuleProps, RuleProps, SqsToSfnPipeProps } from './types'
|
|
@@ -72,14 +73,14 @@ export class EventManager {
|
|
|
72
73
|
schedule: props.schedule,
|
|
73
74
|
})
|
|
74
75
|
|
|
75
|
-
if (targets && targets
|
|
76
|
-
|
|
76
|
+
if (targets && !_.isEmpty(targets)) {
|
|
77
|
+
_.forEach(targets, target => {
|
|
77
78
|
rule.addTarget(target)
|
|
78
79
|
})
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
if (props.tags && props.tags
|
|
82
|
-
props.tags
|
|
82
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
83
|
+
_.forEach(props.tags, tag => {
|
|
83
84
|
Tags.of(rule).add(tag.key, tag.value)
|
|
84
85
|
})
|
|
85
86
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
LayerVersion,
|
|
16
16
|
} from 'aws-cdk-lib/aws-lambda'
|
|
17
17
|
import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'
|
|
18
|
+
import _ from 'lodash'
|
|
18
19
|
import { CommonConstruct, CommonStack } from '../../common'
|
|
19
20
|
import { createCfnOutput } from '../../utils'
|
|
20
21
|
import { CloudFrontManager } from '../cloudfront'
|
|
@@ -144,7 +145,7 @@ export class LambdaManager {
|
|
|
144
145
|
)
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
if (props.lambdaAliases && props.lambdaAliases
|
|
148
|
+
if (props.lambdaAliases && !_.isEmpty(props.lambdaAliases)) {
|
|
148
149
|
props.lambdaAliases.forEach(alias => {
|
|
149
150
|
const aliasId = alias.id ?? `${id}-${alias.aliasName}`
|
|
150
151
|
const functionAlias = this.createLambdaFunctionAlias(`${aliasId}`, scope, alias, lambdaFunction.currentVersion)
|
|
@@ -160,8 +161,8 @@ export class LambdaManager {
|
|
|
160
161
|
})
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
if (props.tags && props.tags
|
|
164
|
-
props.tags
|
|
164
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
165
|
+
_.forEach(props.tags, tag => {
|
|
165
166
|
Tags.of(lambdaFunction).add(tag.key, tag.value)
|
|
166
167
|
})
|
|
167
168
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IFunction } from 'aws-cdk-lib/aws-lambda'
|
|
2
2
|
import { Topic } from 'aws-cdk-lib/aws-sns'
|
|
3
3
|
import { EmailSubscription, LambdaSubscription } from 'aws-cdk-lib/aws-sns-subscriptions'
|
|
4
|
+
import _ from 'lodash'
|
|
4
5
|
import { CommonConstruct } from '../../common'
|
|
5
6
|
import { createCfnOutput } from '../../utils'
|
|
6
7
|
import { SubscriptionProps } from './types'
|
|
@@ -43,8 +44,8 @@ export class SnsManager {
|
|
|
43
44
|
topicName: `${props.topicName}-${scope.props.stage}`,
|
|
44
45
|
})
|
|
45
46
|
|
|
46
|
-
if (emails && emails
|
|
47
|
-
|
|
47
|
+
if (emails && !_.isEmpty(emails)) {
|
|
48
|
+
_.forEach(emails, (email: string) => topic.addSubscription(new EmailSubscription(email)))
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
createCfnOutput(`${id}-subscriptionArn`, scope, topic.topicArn)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Duration, RemovalPolicy, Tags } from 'aws-cdk-lib'
|
|
2
2
|
import { IQueue, Queue } from 'aws-cdk-lib/aws-sqs'
|
|
3
|
+
import _ from 'lodash'
|
|
3
4
|
import { CommonConstruct } from '../../common'
|
|
4
5
|
import { createCfnOutput } from '../../utils'
|
|
5
6
|
import { LambdaProps } from '../lambda'
|
|
@@ -59,8 +60,8 @@ export class SqsManager {
|
|
|
59
60
|
: props.visibilityTimeout,
|
|
60
61
|
})
|
|
61
62
|
|
|
62
|
-
if (props.tags && props.tags
|
|
63
|
-
props.tags
|
|
63
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
64
|
+
_.forEach(props.tags, tag => {
|
|
64
65
|
Tags.of(queue).add(tag.key, tag.value)
|
|
65
66
|
})
|
|
66
67
|
}
|
|
@@ -3,6 +3,7 @@ import { IDistribution } from 'aws-cdk-lib/aws-cloudfront'
|
|
|
3
3
|
import { Effect, PolicyDocument, PolicyStatement, ServicePrincipal } from 'aws-cdk-lib/aws-iam'
|
|
4
4
|
import { BlockPublicAccess, Bucket, BucketEncryption, CfnBucket, CfnBucketPolicy, IBucket } from 'aws-cdk-lib/aws-s3'
|
|
5
5
|
import { BucketDeployment, ISource, ServerSideEncryption, Source } from 'aws-cdk-lib/aws-s3-deployment'
|
|
6
|
+
import _ from 'lodash'
|
|
6
7
|
import { CommonConstruct } from '../../common'
|
|
7
8
|
import { createCfnOutput } from '../../utils'
|
|
8
9
|
import { LifecycleRule, S3BucketProps } from './types'
|
|
@@ -32,7 +33,7 @@ export class S3Manager {
|
|
|
32
33
|
if (!props.lifecycleRules) return undefined
|
|
33
34
|
|
|
34
35
|
const bucketLifecycleRules: LifecycleRule[] = []
|
|
35
|
-
props.lifecycleRules
|
|
36
|
+
_.forEach(props.lifecycleRules, lifecycleRule => {
|
|
36
37
|
bucketLifecycleRules.push({
|
|
37
38
|
abortIncompleteMultipartUploadAfter: lifecycleRule.abortIncompleteMultipartUploadAfter,
|
|
38
39
|
enabled: lifecycleRule.enabled,
|
|
@@ -135,8 +136,8 @@ export class S3Manager {
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
if (props.tags && props.tags
|
|
139
|
-
props.tags
|
|
139
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
140
|
+
_.forEach(props.tags, tag => {
|
|
140
141
|
Tags.of(bucket).add(tag.key, tag.value)
|
|
141
142
|
})
|
|
142
143
|
}
|
|
@@ -222,7 +223,7 @@ export class S3Manager {
|
|
|
222
223
|
throw `Folder unspecified for ${id}`
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
|
|
226
|
+
_.forEach(folders, folder => {
|
|
226
227
|
new BucketDeployment(scope, `${id}-${folder}`, {
|
|
227
228
|
destinationBucket: bucket,
|
|
228
229
|
destinationKeyPrefix: folder,
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
SqsSendMessage,
|
|
31
31
|
StepFunctionsStartExecution,
|
|
32
32
|
} from 'aws-cdk-lib/aws-stepfunctions-tasks'
|
|
33
|
+
import _ from 'lodash'
|
|
33
34
|
import { v4 as uuidv4 } from 'uuid'
|
|
34
35
|
import { CommonConstruct } from '../../common'
|
|
35
36
|
import { createCfnOutput } from '../../utils'
|
|
@@ -214,12 +215,12 @@ export class SfnManager {
|
|
|
214
215
|
retries = DEFAULT_RETRY_CONFIG
|
|
215
216
|
}
|
|
216
217
|
|
|
217
|
-
|
|
218
|
+
_.forEach(retries, retry => {
|
|
218
219
|
step.addRetry({
|
|
219
220
|
...retry,
|
|
220
221
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
221
222
|
})
|
|
222
|
-
)
|
|
223
|
+
})
|
|
223
224
|
|
|
224
225
|
return step
|
|
225
226
|
}
|
|
@@ -267,12 +268,12 @@ export class SfnManager {
|
|
|
267
268
|
retries = DEFAULT_RETRY_CONFIG
|
|
268
269
|
}
|
|
269
270
|
|
|
270
|
-
|
|
271
|
+
_.forEach(retries, retry => {
|
|
271
272
|
step.addRetry({
|
|
272
273
|
...retry,
|
|
273
274
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
274
275
|
})
|
|
275
|
-
)
|
|
276
|
+
})
|
|
276
277
|
|
|
277
278
|
return step
|
|
278
279
|
}
|
|
@@ -320,12 +321,12 @@ export class SfnManager {
|
|
|
320
321
|
retries = DEFAULT_RETRY_CONFIG
|
|
321
322
|
}
|
|
322
323
|
|
|
323
|
-
|
|
324
|
+
_.forEach(retries, retry => {
|
|
324
325
|
step.addRetry({
|
|
325
326
|
...retry,
|
|
326
327
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
327
328
|
})
|
|
328
|
-
)
|
|
329
|
+
})
|
|
329
330
|
|
|
330
331
|
return step
|
|
331
332
|
}
|
|
@@ -364,12 +365,12 @@ export class SfnManager {
|
|
|
364
365
|
retries = DEFAULT_RETRY_CONFIG
|
|
365
366
|
}
|
|
366
367
|
|
|
367
|
-
|
|
368
|
+
_.forEach(retries, retry => {
|
|
368
369
|
step.addRetry({
|
|
369
370
|
...retry,
|
|
370
371
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
371
372
|
})
|
|
372
|
-
)
|
|
373
|
+
})
|
|
373
374
|
|
|
374
375
|
return step
|
|
375
376
|
}
|
|
@@ -396,12 +397,12 @@ export class SfnManager {
|
|
|
396
397
|
retries = DEFAULT_RETRY_CONFIG
|
|
397
398
|
}
|
|
398
399
|
|
|
399
|
-
|
|
400
|
+
_.forEach(retries, retry => {
|
|
400
401
|
step.addRetry({
|
|
401
402
|
...retry,
|
|
402
403
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
403
404
|
})
|
|
404
|
-
)
|
|
405
|
+
})
|
|
405
406
|
|
|
406
407
|
return step
|
|
407
408
|
}
|
|
@@ -436,12 +437,12 @@ export class SfnManager {
|
|
|
436
437
|
retries = DEFAULT_RETRY_CONFIG
|
|
437
438
|
}
|
|
438
439
|
|
|
439
|
-
|
|
440
|
+
_.forEach(retries, retry => {
|
|
440
441
|
step.addRetry({
|
|
441
442
|
...retry,
|
|
442
443
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
443
444
|
})
|
|
444
|
-
)
|
|
445
|
+
})
|
|
445
446
|
|
|
446
447
|
return step
|
|
447
448
|
}
|
|
@@ -474,12 +475,12 @@ export class SfnManager {
|
|
|
474
475
|
retries = DEFAULT_RETRY_CONFIG
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
|
|
478
|
+
_.forEach(retries, retry => {
|
|
478
479
|
step.addRetry({
|
|
479
480
|
...retry,
|
|
480
481
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
481
482
|
})
|
|
482
|
-
)
|
|
483
|
+
})
|
|
483
484
|
|
|
484
485
|
return step
|
|
485
486
|
}
|
|
@@ -510,12 +511,12 @@ export class SfnManager {
|
|
|
510
511
|
retries = DEFAULT_RETRY_CONFIG
|
|
511
512
|
}
|
|
512
513
|
|
|
513
|
-
|
|
514
|
+
_.forEach(retries, retry => {
|
|
514
515
|
step.addRetry({
|
|
515
516
|
...retry,
|
|
516
517
|
...{ interval: retry.intervalInSecs ? Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
517
518
|
})
|
|
518
|
-
)
|
|
519
|
+
})
|
|
519
520
|
|
|
520
521
|
return step
|
|
521
522
|
}
|
|
@@ -2,6 +2,7 @@ import { Tags } from 'aws-cdk-lib'
|
|
|
2
2
|
import { Vpc, VpcProps } from 'aws-cdk-lib/aws-ec2'
|
|
3
3
|
import { CommonConstruct } from '../../common'
|
|
4
4
|
import { createCfnOutput } from '../../utils'
|
|
5
|
+
import _ from 'lodash'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
@@ -38,17 +39,17 @@ export class VpcManager {
|
|
|
38
39
|
})
|
|
39
40
|
|
|
40
41
|
createCfnOutput(`${id}Id`, scope, vpc.vpcId)
|
|
41
|
-
createCfnOutput(`${id}PublicSubnetIds`, scope, vpc.publicSubnets
|
|
42
|
-
createCfnOutput(`${id}PrivateSubnetIds`, scope, vpc.privateSubnets
|
|
42
|
+
createCfnOutput(`${id}PublicSubnetIds`, scope, _.map(vpc.publicSubnets, subnet => subnet.subnetId).toString())
|
|
43
|
+
createCfnOutput(`${id}PrivateSubnetIds`, scope, _.map(vpc.privateSubnets, subnet => subnet.subnetId).toString())
|
|
43
44
|
createCfnOutput(
|
|
44
45
|
`${id}PublicSubnetRouteTableIds`,
|
|
45
46
|
scope,
|
|
46
|
-
vpc.publicSubnets
|
|
47
|
+
_.map(vpc.publicSubnets, subnet => subnet.routeTable.routeTableId).toString()
|
|
47
48
|
)
|
|
48
49
|
createCfnOutput(
|
|
49
50
|
`${id}PrivateSubnetRouteTableIds`,
|
|
50
51
|
scope,
|
|
51
|
-
vpc.privateSubnets
|
|
52
|
+
_.map(vpc.privateSubnets, subnet => subnet.routeTable.routeTableId).toString()
|
|
52
53
|
)
|
|
53
54
|
createCfnOutput(`${id}AvailabilityZones`, scope, vpc.availabilityZones.toString())
|
|
54
55
|
createCfnOutput(`${id}DefaultSecurityGroup`, scope, vpc.vpcDefaultSecurityGroup.toString())
|