@gradientedge/cdk-utils 8.121.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/README.md +2 -1
- package/dist/src/lib/aws/common/construct.d.ts +0 -1
- package/dist/src/lib/aws/common/construct.js +6 -13
- package/dist/src/lib/aws/common/stack.js +7 -9
- package/dist/src/lib/aws/common/types.d.ts +2 -8
- 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/aws/types/index.d.ts +6 -1
- package/dist/src/lib/aws/types/index.js +0 -15
- package/dist/src/lib/aws/utils/index.d.ts +13 -23
- package/dist/src/lib/aws/utils/index.js +37 -46
- package/dist/src/lib/azure/common/construct.d.ts +35 -0
- package/dist/src/lib/azure/common/construct.js +49 -0
- package/dist/src/lib/azure/common/index.d.ts +3 -0
- package/dist/src/lib/azure/common/index.js +19 -0
- package/dist/src/lib/azure/common/stack.d.ts +52 -0
- package/dist/src/lib/azure/common/stack.js +134 -0
- package/dist/src/lib/azure/common/types.d.ts +7 -0
- package/dist/src/lib/azure/index.d.ts +4 -0
- package/dist/src/lib/azure/index.js +20 -0
- package/dist/src/lib/azure/services/index.d.ts +1 -0
- package/dist/src/lib/azure/services/index.js +17 -0
- package/dist/src/lib/azure/services/storage/index.d.ts +2 -0
- package/dist/src/lib/azure/services/storage/index.js +18 -0
- package/dist/src/lib/azure/services/storage/main.d.ts +43 -0
- package/dist/src/lib/azure/services/storage/main.js +124 -0
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -0
- package/dist/src/lib/azure/services/storage/types.js +2 -0
- package/dist/src/lib/azure/types/index.d.ts +3 -0
- package/dist/src/lib/azure/types/index.js +2 -0
- package/dist/src/lib/azure/utils/index.d.ts +3 -0
- package/dist/src/lib/azure/utils/index.js +20 -0
- package/dist/src/lib/common/construct.d.ts +29 -0
- package/dist/src/lib/common/construct.js +8 -0
- package/dist/src/lib/common/index.d.ts +5 -0
- package/dist/src/lib/common/index.js +33 -0
- package/dist/src/lib/common/stack.d.ts +21 -0
- package/dist/src/lib/common/stack.js +8 -0
- package/dist/src/lib/common/types.d.ts +9 -0
- package/dist/src/lib/common/types.js +2 -0
- package/dist/src/lib/common/utils.d.ts +26 -0
- package/dist/src/lib/common/utils.js +34 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.js +2 -0
- package/package.json +9 -7
- package/setup.js +2 -0
- package/src/lib/aws/common/construct.ts +2 -13
- package/src/lib/aws/common/stack.ts +6 -8
- package/src/lib/aws/common/types.ts +2 -8
- 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/aws/types/index.ts +6 -1
- package/src/lib/aws/utils/index.ts +41 -29
- package/src/lib/azure/common/construct.ts +57 -0
- package/src/lib/azure/common/index.ts +3 -0
- package/src/lib/azure/common/stack.ts +143 -0
- package/src/lib/azure/common/types.ts +8 -0
- package/src/lib/azure/index.ts +4 -0
- package/src/lib/azure/services/index.ts +1 -0
- package/src/lib/azure/services/storage/index.ts +2 -0
- package/src/lib/azure/services/storage/main.ts +134 -0
- package/src/lib/azure/services/storage/types.ts +10 -0
- package/src/lib/azure/types/index.ts +3 -0
- package/src/lib/azure/utils/index.ts +23 -0
- package/src/lib/common/construct.ts +35 -0
- package/src/lib/common/index.ts +18 -0
- package/src/lib/common/stack.ts +26 -0
- package/src/lib/common/types.ts +9 -0
- package/src/lib/common/utils.ts +27 -0
- package/src/lib/index.ts +2 -0
- package/dist/src/lib/aws/types/aws/index.d.ts +0 -6
- package/dist/src/lib/aws/utils/aws/index.d.ts +0 -17
- package/dist/src/lib/aws/utils/aws/index.js +0 -40
- package/src/lib/aws/types/aws/index.ts +0 -6
- package/src/lib/aws/utils/aws/index.ts +0 -41
- /package/dist/src/lib/{aws/types/aws/index.js → azure/common/types.js} +0 -0
|
@@ -5,6 +5,7 @@ import { AssetCode, IFunction, ILayerVersion, LayerVersion } from 'aws-cdk-lib/a
|
|
|
5
5
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53'
|
|
6
6
|
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager'
|
|
7
7
|
import { Construct } from 'constructs'
|
|
8
|
+
import _ from 'lodash'
|
|
8
9
|
import { CommonConstruct } from '../../common'
|
|
9
10
|
import { GraphQlApiLambdaEnvironment, GraphQlApiLambdaProps } from './types'
|
|
10
11
|
|
|
@@ -151,7 +152,7 @@ export class GraphQLApiLambda extends CommonConstruct {
|
|
|
151
152
|
|
|
152
153
|
if (!this.props.graphqlApiLambdaLayerSources) return
|
|
153
154
|
|
|
154
|
-
this.props.graphqlApiLambdaLayerSources
|
|
155
|
+
_.forEach(this.props.graphqlApiLambdaLayerSources, (source: AssetCode, index: number) => {
|
|
155
156
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
|
|
156
157
|
})
|
|
157
158
|
|
|
@@ -205,8 +206,8 @@ export class GraphQLApiLambda extends CommonConstruct {
|
|
|
205
206
|
*/
|
|
206
207
|
protected createApiBasePathMapping() {
|
|
207
208
|
const apiRootPaths = this.props.apiRootPaths
|
|
208
|
-
if (apiRootPaths && apiRootPaths
|
|
209
|
-
|
|
209
|
+
if (apiRootPaths && !_.isEmpty(apiRootPaths)) {
|
|
210
|
+
_.forEach(apiRootPaths, (apiRootPath: string) => {
|
|
210
211
|
this.graphQLApiBasePathMappings.push(
|
|
211
212
|
new BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
|
|
212
213
|
basePath: apiRootPath,
|
|
@@ -3,6 +3,7 @@ import { ISecurityGroup, IVpc, Peer, Port, SecurityGroup } from 'aws-cdk-lib/aws
|
|
|
3
3
|
import { CfnReplicationGroup } from 'aws-cdk-lib/aws-elasticache'
|
|
4
4
|
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam'
|
|
5
5
|
import { Construct } from 'constructs'
|
|
6
|
+
import _ from 'lodash'
|
|
6
7
|
import { GraphQLApiLambda } from '..'
|
|
7
8
|
import * as utils from '../../utils'
|
|
8
9
|
import { GraphQlApiLambdaWithCacheProps } from './types'
|
|
@@ -91,7 +92,7 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
91
92
|
`${this.id}-elasticache`,
|
|
92
93
|
this,
|
|
93
94
|
this.props.graphQLElastiCache,
|
|
94
|
-
this.graphQLVpc.privateSubnets
|
|
95
|
+
_.map(this.graphQLVpc.privateSubnets, subnet => subnet.subnetId),
|
|
95
96
|
[this.graphQLSecurityGroup.securityGroupId]
|
|
96
97
|
)
|
|
97
98
|
}
|
|
@@ -4,6 +4,7 @@ import { CfnAccessKey, Policy, PolicyDocument, PolicyStatement, Role, User } fro
|
|
|
4
4
|
import { AssetCode, IFunction, ILayerVersion, LayerVersion } from 'aws-cdk-lib/aws-lambda'
|
|
5
5
|
import { CfnSecret, Secret } from 'aws-cdk-lib/aws-secretsmanager'
|
|
6
6
|
import { Construct } from 'constructs'
|
|
7
|
+
import _ from 'lodash'
|
|
7
8
|
import { CommonConstruct } from '../../common'
|
|
8
9
|
import { LambdaWithIamAccessEnvironment, LambdaWithIamAccessProps } from './types'
|
|
9
10
|
|
|
@@ -112,7 +113,7 @@ export class LambdaWithIamAccess extends CommonConstruct {
|
|
|
112
113
|
|
|
113
114
|
if (!this.props.lambdaLayerSources) return
|
|
114
115
|
|
|
115
|
-
this.props.lambdaLayerSources
|
|
116
|
+
_.forEach(this.props.lambdaLayerSources, (source: AssetCode, index: number) => {
|
|
116
117
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
|
|
117
118
|
})
|
|
118
119
|
|
|
@@ -5,6 +5,7 @@ import { AssetCode, IFunction, ILayerVersion, LayerVersion } from 'aws-cdk-lib/a
|
|
|
5
5
|
import { IHostedZone } from 'aws-cdk-lib/aws-route53'
|
|
6
6
|
import { ISecret } from 'aws-cdk-lib/aws-secretsmanager'
|
|
7
7
|
import { Construct } from 'constructs'
|
|
8
|
+
import _ from 'lodash'
|
|
8
9
|
import { CommonConstruct } from '../../common'
|
|
9
10
|
import { RestApiLambdaEnvironment, RestApiLambdaProps } from './types'
|
|
10
11
|
|
|
@@ -152,7 +153,7 @@ export abstract class RestApiLambda extends CommonConstruct {
|
|
|
152
153
|
|
|
153
154
|
if (!this.props.restApiLambdaLayerSources) return
|
|
154
155
|
|
|
155
|
-
this.props.restApiLambdaLayerSources
|
|
156
|
+
_.forEach(this.props.restApiLambdaLayerSources, (source: AssetCode, index: number) => {
|
|
156
157
|
layers.push(this.lambdaManager.createLambdaLayer(`${this.id}-layer-${index}`, this, source))
|
|
157
158
|
})
|
|
158
159
|
|
|
@@ -208,8 +209,8 @@ export abstract class RestApiLambda extends CommonConstruct {
|
|
|
208
209
|
*/
|
|
209
210
|
protected createApiBasePathMapping() {
|
|
210
211
|
const apiRootPaths = this.props.apiRootPaths
|
|
211
|
-
if (apiRootPaths && apiRootPaths
|
|
212
|
-
|
|
212
|
+
if (apiRootPaths && !_.isEmpty(apiRootPaths)) {
|
|
213
|
+
_.forEach(apiRootPaths, (apiRootPath: string) => {
|
|
213
214
|
this.restApiBasePathMappings.push(
|
|
214
215
|
new BasePathMapping(this, `${this.id}-base-bath-mapping-${apiRootPath}`, {
|
|
215
216
|
basePath: apiRootPath,
|
|
@@ -3,6 +3,7 @@ import { ISecurityGroup, IVpc, Peer, Port, SecurityGroup } from 'aws-cdk-lib/aws
|
|
|
3
3
|
import { CfnReplicationGroup } from 'aws-cdk-lib/aws-elasticache'
|
|
4
4
|
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam'
|
|
5
5
|
import { Construct } from 'constructs'
|
|
6
|
+
import _ from 'lodash'
|
|
6
7
|
import { RestApiLambda } from '..'
|
|
7
8
|
import { createCfnOutput } from '../../utils'
|
|
8
9
|
import { RestApiLambdaWithCacheProps } from './types'
|
|
@@ -94,7 +95,7 @@ export abstract class RestApiLambdaWithCache extends RestApiLambda {
|
|
|
94
95
|
`${this.id}-elasticache`,
|
|
95
96
|
this,
|
|
96
97
|
this.props.restApiCache,
|
|
97
|
-
this.restApivpc.privateSubnets
|
|
98
|
+
_.map(this.restApivpc.privateSubnets, subnet => subnet.subnetId),
|
|
98
99
|
[this.restApiSecurityGroup.securityGroupId]
|
|
99
100
|
)
|
|
100
101
|
|
|
@@ -405,15 +405,14 @@ export class SiteWithEcsBackend extends CommonConstruct {
|
|
|
405
405
|
name: `${this.id}-fs`,
|
|
406
406
|
})
|
|
407
407
|
|
|
408
|
-
if (this.props.siteTask.mountPoints && this.props.siteTask.mountPoints
|
|
409
|
-
this.props.siteTask.mountPoints
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
)
|
|
408
|
+
if (this.props.siteTask.mountPoints && !_.isEmpty(this.props.siteTask.mountPoints)) {
|
|
409
|
+
_.forEach(this.props.siteTask.mountPoints, mountPoint => {
|
|
410
|
+
this.siteEcsTaskDefinition.defaultContainer?.addMountPoints({
|
|
411
|
+
containerPath: mountPoint.containerPath,
|
|
412
|
+
readOnly: mountPoint.readOnly,
|
|
413
|
+
sourceVolume: `${this.id}-fs`,
|
|
414
|
+
})
|
|
415
|
+
})
|
|
417
416
|
}
|
|
418
417
|
}
|
|
419
418
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IBucket } from 'aws-cdk-lib/aws-s3'
|
|
2
2
|
import { BucketDeployment } from 'aws-cdk-lib/aws-s3-deployment'
|
|
3
3
|
import { Construct } from 'constructs'
|
|
4
|
+
import _ from 'lodash'
|
|
4
5
|
import { CommonConstruct } from '../../common'
|
|
5
6
|
import { StaticAssetDeploymentProps } from './types'
|
|
6
7
|
|
|
@@ -62,7 +63,7 @@ export class StaticAssetDeployment extends CommonConstruct {
|
|
|
62
63
|
if (!staticAssetsForExport) return
|
|
63
64
|
|
|
64
65
|
/* optional additional exports needed for asset urls */
|
|
65
|
-
|
|
66
|
+
_.forEach(staticAssetsForExport, asset => {
|
|
66
67
|
this.addCfnOutput(asset.key, this.staticAssetBucket.s3UrlForObject(asset.value))
|
|
67
68
|
})
|
|
68
69
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
} from 'aws-cdk-lib/aws-apigateway'
|
|
14
14
|
import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager'
|
|
15
15
|
import { IFunction } from 'aws-cdk-lib/aws-lambda'
|
|
16
|
+
import _ from 'lodash'
|
|
16
17
|
import { CommonConstruct } from '../../common'
|
|
17
18
|
import { createCfnOutput } from '../../utils'
|
|
18
19
|
import { LambdaRestApiProps } from './types'
|
|
@@ -83,8 +84,8 @@ export class ApiManager {
|
|
|
83
84
|
retainDeployments: props.retainDeployments,
|
|
84
85
|
})
|
|
85
86
|
|
|
86
|
-
if (props.tags && props.tags
|
|
87
|
-
props.tags
|
|
87
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
88
|
+
_.forEach(props.tags, tag => {
|
|
88
89
|
Tags.of(api).add(tag.key, tag.value)
|
|
89
90
|
})
|
|
90
91
|
}
|
|
@@ -153,12 +154,13 @@ export class ApiManager {
|
|
|
153
154
|
allowOrigins: allowedOrigins ?? Cors.ALL_ORIGINS,
|
|
154
155
|
},
|
|
155
156
|
})
|
|
156
|
-
|
|
157
|
+
|
|
158
|
+
_.forEach(methods, method => {
|
|
157
159
|
resource.addMethod(method, integration, {
|
|
158
160
|
authorizer,
|
|
159
161
|
requestParameters: methodRequestParameters,
|
|
160
162
|
})
|
|
161
|
-
)
|
|
163
|
+
})
|
|
162
164
|
createCfnOutput(`${id}-${path}ResourceId`, scope, resource.resourceId)
|
|
163
165
|
|
|
164
166
|
if (addProxy) {
|
|
@@ -170,12 +172,13 @@ export class ApiManager {
|
|
|
170
172
|
allowOrigins: allowedOrigins ?? Cors.ALL_ORIGINS,
|
|
171
173
|
},
|
|
172
174
|
})
|
|
173
|
-
|
|
175
|
+
|
|
176
|
+
_.forEach(methods, method => {
|
|
174
177
|
resourceProxy.addMethod(method, proxyIntegration ?? integration, {
|
|
175
178
|
authorizer,
|
|
176
179
|
requestParameters: methodRequestParameters,
|
|
177
180
|
})
|
|
178
|
-
)
|
|
181
|
+
})
|
|
179
182
|
createCfnOutput(`${id}-${path}ProxyResourceId`, scope, resourceProxy.resourceId)
|
|
180
183
|
}
|
|
181
184
|
|
|
@@ -26,6 +26,7 @@ import { CommonConstruct, CommonStack } from '../../common'
|
|
|
26
26
|
import { createCfnOutput } from '../../utils'
|
|
27
27
|
import { LambdaEdgeProps } from '../lambda'
|
|
28
28
|
import { CloudFrontProps, CloudfrontFunctionProps, DistributionProps } from './types'
|
|
29
|
+
import _ from 'lodash'
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* @classdesc Provides operations on AWS
|
|
@@ -115,8 +116,8 @@ export class CloudFrontManager {
|
|
|
115
116
|
webACLId: props.webACLId,
|
|
116
117
|
})
|
|
117
118
|
|
|
118
|
-
if (props.tags && props.tags
|
|
119
|
-
props.tags
|
|
119
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
120
|
+
_.forEach(props.tags, tag => {
|
|
120
121
|
Tags.of(distribution).add(tag.key, tag.value)
|
|
121
122
|
})
|
|
122
123
|
}
|
|
@@ -180,8 +181,8 @@ export class CloudFrontManager {
|
|
|
180
181
|
webAclId: props.webAclId,
|
|
181
182
|
})
|
|
182
183
|
|
|
183
|
-
if (props.tags && props.tags
|
|
184
|
-
props.tags
|
|
184
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
185
|
+
_.forEach(props.tags, tag => {
|
|
185
186
|
Tags.of(distribution).add(tag.key, tag.value)
|
|
186
187
|
})
|
|
187
188
|
}
|
|
@@ -244,8 +245,8 @@ export class CloudFrontManager {
|
|
|
244
245
|
webAclId: props.webAclId,
|
|
245
246
|
})
|
|
246
247
|
|
|
247
|
-
if (props.tags && props.tags
|
|
248
|
-
props.tags
|
|
248
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
249
|
+
_.forEach(props.tags, tag => {
|
|
249
250
|
Tags.of(distribution).add(tag.key, tag.value)
|
|
250
251
|
})
|
|
251
252
|
}
|
|
@@ -306,7 +307,7 @@ export class CloudFrontManager {
|
|
|
306
307
|
vpc: vpc,
|
|
307
308
|
})
|
|
308
309
|
|
|
309
|
-
if (props.tags && props.tags
|
|
310
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
310
311
|
props.tags.forEach(tag => {
|
|
311
312
|
Tags.of(edgeFunction).add(tag.key, tag.value)
|
|
312
313
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib'
|
|
2
2
|
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
3
|
-
import
|
|
3
|
+
import _ from 'lodash'
|
|
4
4
|
import { CommonConstruct } from '../../common'
|
|
5
|
+
import * as utils from '../../utils'
|
|
5
6
|
import { LogProps, MetricFilterProps } from './types'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -66,8 +67,8 @@ export class LogManager {
|
|
|
66
67
|
retentionInDays: props.retention,
|
|
67
68
|
})
|
|
68
69
|
|
|
69
|
-
if (props.tags && props.tags
|
|
70
|
-
props.tags
|
|
70
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
71
|
+
_.forEach(props.tags, tag => {
|
|
71
72
|
cdk.Tags.of(logGroup).add(tag.key, tag.value)
|
|
72
73
|
})
|
|
73
74
|
}
|
|
@@ -93,8 +94,8 @@ export class LogManager {
|
|
|
93
94
|
retention: props.retention,
|
|
94
95
|
})
|
|
95
96
|
|
|
96
|
-
if (props.tags && props.tags
|
|
97
|
-
props.tags
|
|
97
|
+
if (props.tags && !_.isEmpty(props.tags)) {
|
|
98
|
+
_.forEach(props.tags, tag => {
|
|
98
99
|
cdk.Tags.of(logGroup).add(tag.key, tag.value)
|
|
99
100
|
})
|
|
100
101
|
}
|
|
@@ -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
|
}
|