@gradientedge/cdk-utils 4.1.0 → 4.2.1
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 +37 -9
- package/dist/index.d.ts +3 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -25
- package/dist/index.js.map +1 -1
- package/dist/src/lib/common/commonConstruct.d.ts +30 -50
- package/dist/src/lib/common/commonConstruct.d.ts.map +1 -1
- package/dist/src/lib/common/commonConstruct.js +53 -54
- package/dist/src/lib/common/commonConstruct.js.map +1 -1
- package/dist/src/lib/common/commonStack.d.ts +3 -2
- package/dist/src/lib/common/commonStack.d.ts.map +1 -1
- package/dist/src/lib/common/commonStack.js +2 -1
- package/dist/src/lib/common/commonStack.js.map +1 -1
- package/dist/src/lib/common/index.d.ts +3 -0
- package/dist/src/lib/common/index.d.ts.map +1 -0
- package/dist/src/lib/common/index.js +15 -0
- package/dist/src/lib/common/index.js.map +1 -0
- package/dist/src/lib/construct/graphQLApiLambda.d.ts +6 -5
- package/dist/src/lib/construct/graphQLApiLambda.d.ts.map +1 -1
- package/dist/src/lib/construct/graphQLApiLambda.js +3 -2
- package/dist/src/lib/construct/graphQLApiLambda.js.map +1 -1
- package/dist/src/lib/construct/index.d.ts +4 -0
- package/dist/src/lib/construct/index.d.ts.map +1 -0
- package/dist/src/lib/construct/index.js +16 -0
- package/dist/src/lib/construct/index.js.map +1 -0
- package/dist/src/lib/construct/siteWithEcsBackend.d.ts +21 -8
- package/dist/src/lib/construct/siteWithEcsBackend.d.ts.map +1 -1
- package/dist/src/lib/construct/siteWithEcsBackend.js +33 -5
- package/dist/src/lib/construct/siteWithEcsBackend.js.map +1 -1
- package/dist/src/lib/construct/staticSite.d.ts +18 -5
- package/dist/src/lib/construct/staticSite.d.ts.map +1 -1
- package/dist/src/lib/construct/staticSite.js +31 -2
- package/dist/src/lib/construct/staticSite.js.map +1 -1
- package/dist/src/lib/manager/{acmManager.d.ts → aws/acmManager.d.ts} +9 -8
- package/dist/src/lib/manager/aws/acmManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{acmManager.js → aws/acmManager.js} +9 -8
- package/dist/src/lib/manager/aws/acmManager.js.map +1 -0
- package/dist/src/lib/manager/{apiManager.d.ts → aws/apiManager.d.ts} +12 -11
- package/dist/src/lib/manager/aws/apiManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{apiManager.js → aws/apiManager.js} +12 -11
- package/dist/src/lib/manager/aws/apiManager.js.map +1 -0
- package/dist/src/lib/manager/{appConfigManager.d.ts → aws/appConfigManager.d.ts} +18 -17
- package/dist/src/lib/manager/aws/appConfigManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{appConfigManager.js → aws/appConfigManager.js} +20 -19
- package/dist/src/lib/manager/aws/appConfigManager.js.map +1 -0
- package/dist/src/lib/manager/aws/cloudFrontManager.d.ts +112 -0
- package/dist/src/lib/manager/aws/cloudFrontManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudFrontManager.js → aws/cloudFrontManager.js} +49 -25
- package/dist/src/lib/manager/aws/cloudFrontManager.js.map +1 -0
- package/dist/src/lib/manager/{cloudTrailManager.d.ts → aws/cloudTrailManager.d.ts} +10 -9
- package/dist/src/lib/manager/aws/cloudTrailManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudTrailManager.js → aws/cloudTrailManager.js} +10 -9
- package/dist/src/lib/manager/aws/cloudTrailManager.js.map +1 -0
- package/dist/src/lib/manager/aws/cloudWatchManager.d.ts +121 -0
- package/dist/src/lib/manager/aws/cloudWatchManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{cloudWatchManager.js → aws/cloudWatchManager.js} +48 -36
- package/dist/src/lib/manager/aws/cloudWatchManager.js.map +1 -0
- package/dist/src/lib/manager/aws/codeBuildManager.d.ts +40 -0
- package/dist/src/lib/manager/aws/codeBuildManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{codeBuildManager.js → aws/codeBuildManager.js} +17 -1
- package/dist/src/lib/manager/aws/codeBuildManager.js.map +1 -0
- package/dist/src/lib/manager/{ecrManager.d.ts → aws/ecrManager.d.ts} +8 -7
- package/dist/src/lib/manager/aws/ecrManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ecrManager.js → aws/ecrManager.js} +8 -7
- package/dist/src/lib/manager/aws/ecrManager.js.map +1 -0
- package/dist/src/lib/manager/{ecsManager.d.ts → aws/ecsManager.d.ts} +13 -12
- package/dist/src/lib/manager/aws/ecsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ecsManager.js → aws/ecsManager.js} +13 -12
- package/dist/src/lib/manager/aws/ecsManager.js.map +1 -0
- package/dist/src/lib/manager/{eksManager.d.ts → aws/eksManager.d.ts} +10 -9
- package/dist/src/lib/manager/aws/eksManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{eksManager.js → aws/eksManager.js} +10 -9
- package/dist/src/lib/manager/aws/eksManager.js.map +1 -0
- package/dist/src/lib/manager/{eventManager.d.ts → aws/eventManager.d.ts} +13 -12
- package/dist/src/lib/manager/aws/eventManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{eventManager.js → aws/eventManager.js} +14 -13
- package/dist/src/lib/manager/aws/eventManager.js.map +1 -0
- package/dist/src/lib/manager/aws/iamManager.d.ts +156 -0
- package/dist/src/lib/manager/aws/iamManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{iamManager.js → aws/iamManager.js} +37 -35
- package/dist/src/lib/manager/aws/iamManager.js.map +1 -0
- package/dist/src/lib/manager/aws/index.d.ts +22 -0
- package/dist/src/lib/manager/aws/index.d.ts.map +1 -0
- package/dist/src/lib/manager/aws/index.js +34 -0
- package/dist/src/lib/manager/aws/index.js.map +1 -0
- package/dist/src/lib/manager/{lambdaManager.d.ts → aws/lambdaManager.d.ts} +21 -20
- package/dist/src/lib/manager/aws/lambdaManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{lambdaManager.js → aws/lambdaManager.js} +21 -20
- package/dist/src/lib/manager/aws/lambdaManager.js.map +1 -0
- package/dist/src/lib/manager/aws/logManager.d.ts +51 -0
- package/dist/src/lib/manager/aws/logManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{logManager.js → aws/logManager.js} +14 -13
- package/dist/src/lib/manager/aws/logManager.js.map +1 -0
- package/dist/src/lib/manager/{route53Manager.d.ts → aws/route53Manager.d.ts} +18 -17
- package/dist/src/lib/manager/aws/route53Manager.d.ts.map +1 -0
- package/dist/src/lib/manager/{route53Manager.js → aws/route53Manager.js} +19 -18
- package/dist/src/lib/manager/aws/route53Manager.js.map +1 -0
- package/dist/src/lib/manager/aws/s3Manager.d.ts +73 -0
- package/dist/src/lib/manager/aws/s3Manager.d.ts.map +1 -0
- package/dist/src/lib/manager/{s3Manager.js → aws/s3Manager.js} +17 -16
- package/dist/src/lib/manager/aws/s3Manager.js.map +1 -0
- package/dist/src/lib/manager/{secretsManager.d.ts → aws/secretsManager.d.ts} +8 -7
- package/dist/src/lib/manager/aws/secretsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{secretsManager.js → aws/secretsManager.js} +6 -5
- package/dist/src/lib/manager/aws/secretsManager.js.map +1 -0
- package/dist/src/lib/manager/aws/snsManager.d.ts +42 -0
- package/dist/src/lib/manager/aws/snsManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{snsManager.js → aws/snsManager.js} +14 -13
- package/dist/src/lib/manager/aws/snsManager.js.map +1 -0
- package/dist/src/lib/manager/aws/ssmManager.d.ts +64 -0
- package/dist/src/lib/manager/aws/ssmManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{ssmManager.js → aws/ssmManager.js} +15 -14
- package/dist/src/lib/manager/aws/ssmManager.js.map +1 -0
- package/dist/src/lib/manager/{vpcManager.d.ts → aws/vpcManager.d.ts} +12 -11
- package/dist/src/lib/manager/aws/vpcManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{vpcManager.js → aws/vpcManager.js} +15 -14
- package/dist/src/lib/manager/aws/vpcManager.js.map +1 -0
- package/dist/src/lib/manager/aws/wafManager.d.ts +39 -0
- package/dist/src/lib/manager/aws/wafManager.d.ts.map +1 -0
- package/dist/src/lib/manager/{wafManager.js → aws/wafManager.js} +14 -13
- package/dist/src/lib/manager/aws/wafManager.js.map +1 -0
- package/dist/src/lib/manager/index.d.ts +2 -0
- package/dist/src/lib/manager/index.d.ts.map +1 -0
- package/dist/src/lib/manager/index.js +14 -0
- package/dist/src/lib/manager/index.js.map +1 -0
- package/dist/src/lib/{types.d.ts → types/aws/index.d.ts} +27 -16
- package/dist/src/lib/types/aws/index.d.ts.map +1 -0
- package/dist/src/lib/{types.js → types/aws/index.js} +1 -1
- package/dist/src/lib/types/aws/index.js.map +1 -0
- package/dist/src/lib/types/index.d.ts +2 -0
- package/dist/src/lib/types/index.d.ts.map +1 -0
- package/dist/src/lib/types/index.js +14 -0
- package/dist/src/lib/types/index.js.map +1 -0
- package/dist/src/lib/utils/aws/index.d.ts +16 -0
- package/dist/src/lib/utils/aws/index.d.ts.map +1 -0
- package/dist/src/lib/utils/aws/index.js +50 -0
- package/dist/src/lib/utils/aws/index.js.map +1 -0
- package/dist/src/lib/{utils.d.ts → utils/index.d.ts} +2 -26
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +85 -0
- package/dist/src/lib/utils/index.js.map +1 -0
- package/index.ts +3 -25
- package/package.json +28 -19
- package/src/lib/common/commonConstruct.ts +58 -78
- package/src/lib/common/commonStack.ts +3 -2
- package/src/lib/common/index.ts +2 -0
- package/src/lib/construct/graphQLApiLambda.ts +6 -5
- package/src/lib/construct/index.ts +3 -0
- package/src/lib/construct/siteWithEcsBackend.ts +45 -10
- package/src/lib/construct/staticSite.ts +41 -6
- package/src/lib/manager/{acmManager.ts → aws/acmManager.ts} +13 -12
- package/src/lib/manager/{apiManager.ts → aws/apiManager.ts} +16 -15
- package/src/lib/manager/{appConfigManager.ts → aws/appConfigManager.ts} +32 -27
- package/src/lib/manager/{cloudFrontManager.ts → aws/cloudFrontManager.ts} +69 -40
- package/src/lib/manager/{cloudTrailManager.ts → aws/cloudTrailManager.ts} +14 -13
- package/src/lib/manager/{cloudWatchManager.ts → aws/cloudWatchManager.ts} +80 -57
- package/src/lib/manager/{codeBuildManager.ts → aws/codeBuildManager.ts} +20 -4
- package/src/lib/manager/{ecrManager.ts → aws/ecrManager.ts} +10 -9
- package/src/lib/manager/{ecsManager.ts → aws/ecsManager.ts} +18 -17
- package/src/lib/manager/{eksManager.ts → aws/eksManager.ts} +14 -13
- package/src/lib/manager/{eventManager.ts → aws/eventManager.ts} +20 -19
- package/src/lib/manager/{iamManager.ts → aws/iamManager.ts} +67 -55
- package/src/lib/manager/aws/index.ts +21 -0
- package/src/lib/manager/{lambdaManager.ts → aws/lambdaManager.ts} +31 -30
- package/src/lib/manager/{logManager.ts → aws/logManager.ts} +24 -18
- package/src/lib/manager/{route53Manager.ts → aws/route53Manager.ts} +26 -25
- package/src/lib/manager/{s3Manager.ts → aws/s3Manager.ts} +26 -25
- package/src/lib/manager/{secretsManager.ts → aws/secretsManager.ts} +13 -7
- package/src/lib/manager/{snsManager.ts → aws/snsManager.ts} +20 -19
- package/src/lib/manager/{ssmManager.ts → aws/ssmManager.ts} +26 -20
- package/src/lib/manager/{vpcManager.ts → aws/vpcManager.ts} +19 -18
- package/src/lib/manager/{wafManager.ts → aws/wafManager.ts} +18 -17
- package/src/lib/manager/index.ts +1 -0
- package/src/lib/{types.ts → types/aws/index.ts} +27 -15
- package/src/lib/types/index.ts +1 -0
- package/src/lib/utils/aws/index.ts +34 -0
- package/src/lib/{utils.ts → utils/index.ts} +1 -45
- package/dist/src/lib/manager/acmManager.d.ts.map +0 -1
- package/dist/src/lib/manager/acmManager.js.map +0 -1
- package/dist/src/lib/manager/apiManager.d.ts.map +0 -1
- package/dist/src/lib/manager/apiManager.js.map +0 -1
- package/dist/src/lib/manager/appConfigManager.d.ts.map +0 -1
- package/dist/src/lib/manager/appConfigManager.js.map +0 -1
- package/dist/src/lib/manager/cloudFrontManager.d.ts +0 -100
- package/dist/src/lib/manager/cloudFrontManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudFrontManager.js.map +0 -1
- package/dist/src/lib/manager/cloudTrailManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudTrailManager.js.map +0 -1
- package/dist/src/lib/manager/cloudWatchManager.d.ts +0 -120
- package/dist/src/lib/manager/cloudWatchManager.d.ts.map +0 -1
- package/dist/src/lib/manager/cloudWatchManager.js.map +0 -1
- package/dist/src/lib/manager/codeBuildManager.d.ts +0 -25
- package/dist/src/lib/manager/codeBuildManager.d.ts.map +0 -1
- package/dist/src/lib/manager/codeBuildManager.js.map +0 -1
- package/dist/src/lib/manager/ecrManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ecrManager.js.map +0 -1
- package/dist/src/lib/manager/ecsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ecsManager.js.map +0 -1
- package/dist/src/lib/manager/eksManager.d.ts.map +0 -1
- package/dist/src/lib/manager/eksManager.js.map +0 -1
- package/dist/src/lib/manager/eventManager.d.ts.map +0 -1
- package/dist/src/lib/manager/eventManager.js.map +0 -1
- package/dist/src/lib/manager/iamManager.d.ts +0 -154
- package/dist/src/lib/manager/iamManager.d.ts.map +0 -1
- package/dist/src/lib/manager/iamManager.js.map +0 -1
- package/dist/src/lib/manager/lambdaManager.d.ts.map +0 -1
- package/dist/src/lib/manager/lambdaManager.js.map +0 -1
- package/dist/src/lib/manager/logManager.d.ts +0 -50
- package/dist/src/lib/manager/logManager.d.ts.map +0 -1
- package/dist/src/lib/manager/logManager.js.map +0 -1
- package/dist/src/lib/manager/route53Manager.d.ts.map +0 -1
- package/dist/src/lib/manager/route53Manager.js.map +0 -1
- package/dist/src/lib/manager/s3Manager.d.ts +0 -72
- package/dist/src/lib/manager/s3Manager.d.ts.map +0 -1
- package/dist/src/lib/manager/s3Manager.js.map +0 -1
- package/dist/src/lib/manager/secretsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/secretsManager.js.map +0 -1
- package/dist/src/lib/manager/snsManager.d.ts +0 -41
- package/dist/src/lib/manager/snsManager.d.ts.map +0 -1
- package/dist/src/lib/manager/snsManager.js.map +0 -1
- package/dist/src/lib/manager/ssmManager.d.ts +0 -63
- package/dist/src/lib/manager/ssmManager.d.ts.map +0 -1
- package/dist/src/lib/manager/ssmManager.js.map +0 -1
- package/dist/src/lib/manager/vpcManager.d.ts.map +0 -1
- package/dist/src/lib/manager/vpcManager.js.map +0 -1
- package/dist/src/lib/manager/wafManager.d.ts +0 -38
- package/dist/src/lib/manager/wafManager.d.ts.map +0 -1
- package/dist/src/lib/manager/wafManager.js.map +0 -1
- package/dist/src/lib/types.d.ts.map +0 -1
- package/dist/src/lib/types.js.map +0 -1
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/lib/utils.js +0 -131
- package/dist/src/lib/utils.js.map +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib'
|
|
1
2
|
import * as acm from 'aws-cdk-lib/aws-certificatemanager'
|
|
2
3
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
|
|
3
|
-
import * as
|
|
4
|
-
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
5
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
6
|
-
import { CloudFrontProps, DistributionProps, LambdaEdgeProps } from '../types'
|
|
7
|
-
import { createCfnOutput } from '../utils'
|
|
8
|
-
import * as cdk from 'aws-cdk-lib'
|
|
4
|
+
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins'
|
|
9
5
|
import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
10
6
|
import * as efs from 'aws-cdk-lib/aws-efs'
|
|
11
|
-
import * as
|
|
7
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda'
|
|
8
|
+
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
12
9
|
import * as cr from 'aws-cdk-lib/custom-resources'
|
|
10
|
+
import * as common from '../../common'
|
|
11
|
+
import * as types from '../../types'
|
|
12
|
+
import * as utils from '../../utils'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @stability stable
|
|
16
16
|
* @category Networking & Content Delivery
|
|
17
17
|
* @summary Provides operations on AWS CloudFront.
|
|
18
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
19
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
18
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
19
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
20
20
|
* @example
|
|
21
21
|
* import * as common from '@gradientedge/cdk-utils'
|
|
22
22
|
*
|
|
23
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
23
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
24
24
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
25
25
|
* super(parent, id, props)
|
|
26
26
|
* this.props = props
|
|
@@ -32,12 +32,13 @@ import * as cr from 'aws-cdk-lib/custom-resources'
|
|
|
32
32
|
* originAccessIdentity,
|
|
33
33
|
* certificate
|
|
34
34
|
* )
|
|
35
|
+
* }
|
|
35
36
|
* }
|
|
36
37
|
*
|
|
37
|
-
* @see [CDK CloudFront Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
38
|
+
* @see [CDK CloudFront Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront-readme.html}
|
|
38
39
|
*/
|
|
39
40
|
export class CloudFrontManager {
|
|
40
|
-
public createOriginAccessIdentity(id: string, scope: CommonConstruct, accessBucket?: s3.IBucket) {
|
|
41
|
+
public createOriginAccessIdentity(id: string, scope: common.CommonConstruct, accessBucket?: s3.IBucket) {
|
|
41
42
|
const oai = new cloudfront.OriginAccessIdentity(scope, `${id}`, {
|
|
42
43
|
comment: `${id} - ${scope.props.stage} stage`,
|
|
43
44
|
})
|
|
@@ -51,8 +52,8 @@ export class CloudFrontManager {
|
|
|
51
52
|
*
|
|
52
53
|
* @summary Method to create a cloudfront distribution
|
|
53
54
|
* @param {string} id scoped id of the resource
|
|
54
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
55
|
-
* @param {CloudFrontProps} props distribution properties
|
|
55
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
56
|
+
* @param {types.CloudFrontProps} props distribution properties
|
|
56
57
|
* @param {s3.IBucket?} siteBucket
|
|
57
58
|
* @param {s3.IBucket?} logBucket
|
|
58
59
|
* @param {cloudfront.OriginAccessIdentity?} oai
|
|
@@ -61,8 +62,8 @@ export class CloudFrontManager {
|
|
|
61
62
|
*/
|
|
62
63
|
public createCloudFrontDistribution(
|
|
63
64
|
id: string,
|
|
64
|
-
scope: CommonConstruct,
|
|
65
|
-
props: CloudFrontProps,
|
|
65
|
+
scope: common.CommonConstruct,
|
|
66
|
+
props: types.CloudFrontProps,
|
|
66
67
|
siteBucket?: s3.IBucket,
|
|
67
68
|
logBucket?: s3.IBucket,
|
|
68
69
|
oai?: cloudfront.OriginAccessIdentity,
|
|
@@ -103,8 +104,8 @@ export class CloudFrontManager {
|
|
|
103
104
|
webACLId: props.webACLId,
|
|
104
105
|
})
|
|
105
106
|
|
|
106
|
-
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
107
|
-
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
107
|
+
utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
108
|
+
utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
108
109
|
|
|
109
110
|
return distribution
|
|
110
111
|
}
|
|
@@ -112,25 +113,27 @@ export class CloudFrontManager {
|
|
|
112
113
|
/**
|
|
113
114
|
* Method to create a CloudFront distribution with S3 Origin
|
|
114
115
|
* @param {string} id scoped id of the resource
|
|
115
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
116
|
-
* @param {
|
|
116
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
117
|
+
* @param {types.DistributionProps} props distribution properties
|
|
117
118
|
* @param {origins.S3Origin} origin
|
|
118
119
|
* @param {s3.IBucket} siteBucket
|
|
119
120
|
* @param {s3.IBucket?} logBucket
|
|
120
121
|
* @param {cloudfront.OriginAccessIdentity?} oai
|
|
121
122
|
* @param {acm.ICertificate?} certificate
|
|
122
123
|
* @param {string[]?} aliases
|
|
124
|
+
* @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
|
|
123
125
|
*/
|
|
124
126
|
public createDistributionWithS3Origin(
|
|
125
127
|
id: string,
|
|
126
|
-
scope: CommonConstruct,
|
|
127
|
-
props: DistributionProps,
|
|
128
|
+
scope: common.CommonConstruct,
|
|
129
|
+
props: types.DistributionProps,
|
|
128
130
|
origin: origins.S3Origin,
|
|
129
131
|
siteBucket: s3.IBucket,
|
|
130
132
|
logBucket?: s3.IBucket,
|
|
131
133
|
oai?: cloudfront.OriginAccessIdentity,
|
|
132
134
|
certificate?: acm.ICertificate,
|
|
133
|
-
aliases?: string[]
|
|
135
|
+
aliases?: string[],
|
|
136
|
+
defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
|
|
134
137
|
) {
|
|
135
138
|
const distribution = new cloudfront.Distribution(scope, `${id}`, {
|
|
136
139
|
certificate: certificate,
|
|
@@ -139,6 +142,7 @@ export class CloudFrontManager {
|
|
|
139
142
|
cachePolicy: props.defaultBehavior ? props.defaultBehavior.cachePolicy : undefined,
|
|
140
143
|
origin: origin,
|
|
141
144
|
originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
|
|
145
|
+
functionAssociations: defaultFunctionAssociations ?? undefined,
|
|
142
146
|
},
|
|
143
147
|
additionalBehaviors: props.additionalBehaviors,
|
|
144
148
|
defaultRootObject: props.defaultRootObject,
|
|
@@ -157,8 +161,8 @@ export class CloudFrontManager {
|
|
|
157
161
|
webAclId: props.webAclId,
|
|
158
162
|
})
|
|
159
163
|
|
|
160
|
-
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
161
|
-
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
164
|
+
utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
165
|
+
utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
162
166
|
|
|
163
167
|
return distribution
|
|
164
168
|
}
|
|
@@ -166,21 +170,23 @@ export class CloudFrontManager {
|
|
|
166
170
|
/**
|
|
167
171
|
* Method to create a CloudFront distribution with HTTP Origin
|
|
168
172
|
* @param {string} id scoped id of the resource
|
|
169
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
170
|
-
* @param {
|
|
173
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
174
|
+
* @param {types.DistributionProps} props distribution properties
|
|
171
175
|
* @param {origins.S3Origin} origin
|
|
172
176
|
* @param {string[]} domainNames
|
|
173
177
|
* @param {s3.IBucket?} logBucket
|
|
174
178
|
* @param {acm.ICertificate?} certificate
|
|
179
|
+
* @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
|
|
175
180
|
*/
|
|
176
181
|
public createDistributionWithHttpOrigin(
|
|
177
182
|
id: string,
|
|
178
|
-
scope: CommonConstruct,
|
|
179
|
-
props: DistributionProps,
|
|
183
|
+
scope: common.CommonConstruct,
|
|
184
|
+
props: types.DistributionProps,
|
|
180
185
|
origin: origins.HttpOrigin,
|
|
181
186
|
domainNames: string[],
|
|
182
187
|
logBucket?: s3.IBucket,
|
|
183
|
-
certificate?: acm.ICertificate
|
|
188
|
+
certificate?: acm.ICertificate,
|
|
189
|
+
defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
|
|
184
190
|
) {
|
|
185
191
|
const distribution = new cloudfront.Distribution(scope, `${id}`, {
|
|
186
192
|
certificate: certificate,
|
|
@@ -189,6 +195,7 @@ export class CloudFrontManager {
|
|
|
189
195
|
cachePolicy: props.defaultBehavior ? props.defaultBehavior.cachePolicy : undefined,
|
|
190
196
|
origin: origin,
|
|
191
197
|
originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
|
|
198
|
+
functionAssociations: defaultFunctionAssociations ?? undefined,
|
|
192
199
|
},
|
|
193
200
|
additionalBehaviors: props.additionalBehaviors,
|
|
194
201
|
defaultRootObject: props.defaultRootObject,
|
|
@@ -207,8 +214,8 @@ export class CloudFrontManager {
|
|
|
207
214
|
webAclId: props.webAclId,
|
|
208
215
|
})
|
|
209
216
|
|
|
210
|
-
createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
211
|
-
createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
217
|
+
utils.createCfnOutput(`${id}-distributionId`, scope, distribution.distributionId)
|
|
218
|
+
utils.createCfnOutput(`${id}-distributionDomainName`, scope, distribution.distributionDomainName)
|
|
212
219
|
|
|
213
220
|
return distribution
|
|
214
221
|
}
|
|
@@ -217,8 +224,8 @@ export class CloudFrontManager {
|
|
|
217
224
|
* @summary Method to provision a Lambda@Edge function
|
|
218
225
|
*
|
|
219
226
|
* @param {string} id scoped id of the resource
|
|
220
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
221
|
-
* @param {LambdaEdgeProps} props lambda@edge properties
|
|
227
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
228
|
+
* @param {types.LambdaEdgeProps} props lambda@edge properties
|
|
222
229
|
* @param {lambda.ILayerVersion[]} layers
|
|
223
230
|
* @param {lambda.AssetCode} code
|
|
224
231
|
* @param {Map<string, string>} environment
|
|
@@ -229,8 +236,8 @@ export class CloudFrontManager {
|
|
|
229
236
|
*/
|
|
230
237
|
public createEdgeFunction(
|
|
231
238
|
id: string,
|
|
232
|
-
scope: CommonConstruct,
|
|
233
|
-
props: LambdaEdgeProps,
|
|
239
|
+
scope: common.CommonConstruct,
|
|
240
|
+
props: types.LambdaEdgeProps,
|
|
234
241
|
layers: lambda.ILayerVersion[],
|
|
235
242
|
code: lambda.AssetCode,
|
|
236
243
|
environment?: any,
|
|
@@ -260,9 +267,9 @@ export class CloudFrontManager {
|
|
|
260
267
|
vpc: vpc,
|
|
261
268
|
})
|
|
262
269
|
|
|
263
|
-
createCfnOutput(`${id}-edgeArn`, scope, edgeFunction.edgeArn)
|
|
264
|
-
createCfnOutput(`${id}-edgeFunctionArn`, scope, edgeFunction.functionArn)
|
|
265
|
-
createCfnOutput(`${id}-edgeFunctionName`, scope, edgeFunction.functionName)
|
|
270
|
+
utils.createCfnOutput(`${id}-edgeArn`, scope, edgeFunction.edgeArn)
|
|
271
|
+
utils.createCfnOutput(`${id}-edgeFunctionArn`, scope, edgeFunction.functionArn)
|
|
272
|
+
utils.createCfnOutput(`${id}-edgeFunctionName`, scope, edgeFunction.functionName)
|
|
266
273
|
|
|
267
274
|
return edgeFunction
|
|
268
275
|
}
|
|
@@ -277,7 +284,7 @@ export class CloudFrontManager {
|
|
|
277
284
|
*/
|
|
278
285
|
public invalidateCache(
|
|
279
286
|
id: string,
|
|
280
|
-
scope: CommonConstruct,
|
|
287
|
+
scope: common.CommonConstruct,
|
|
281
288
|
dockerFilePath: string,
|
|
282
289
|
distributionId: string,
|
|
283
290
|
paths?: string
|
|
@@ -300,4 +307,26 @@ export class CloudFrontManager {
|
|
|
300
307
|
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({ resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE }),
|
|
301
308
|
})
|
|
302
309
|
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @summary Method to provision a Cloudfront function
|
|
313
|
+
*
|
|
314
|
+
* @param {string} id scoped id of the resource
|
|
315
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
316
|
+
* @param {types.CloudfrontFunctionProps} props
|
|
317
|
+
*/
|
|
318
|
+
public createCloudfrontFunction(id: string, scope: common.CommonConstruct, props: types.CloudfrontFunctionProps) {
|
|
319
|
+
const cloudfrontFunction = new cloudfront.Function(scope, `${id}`, {
|
|
320
|
+
code: cloudfront.FunctionCode.fromFile({
|
|
321
|
+
filePath: props.functionFilePath,
|
|
322
|
+
}),
|
|
323
|
+
comment: props.comment,
|
|
324
|
+
functionName: `${props.functionName}-${scope.props.stage}`,
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
utils.createCfnOutput(`${id}-functionArn`, scope, cloudfrontFunction.functionArn)
|
|
328
|
+
utils.createCfnOutput(`${id}-functionName`, scope, cloudfrontFunction.functionName)
|
|
329
|
+
|
|
330
|
+
return cloudfrontFunction
|
|
331
|
+
}
|
|
303
332
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as cloudtrail from 'aws-cdk-lib/aws-cloudtrail'
|
|
2
2
|
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
3
3
|
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import * as common from '../../common'
|
|
5
|
+
import * as types from '../../types'
|
|
6
|
+
import * as utils from '../../utils'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @stability stable
|
|
10
10
|
* @category Management & Governance
|
|
11
11
|
* @summary Provides operations on AWS CloudTrail.
|
|
12
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
13
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
12
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
13
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
14
14
|
* @example
|
|
15
15
|
* import * as common from '@gradientedge/cdk-utils'
|
|
16
16
|
*
|
|
17
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
17
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
18
18
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
19
19
|
* super(parent, id, props)
|
|
20
20
|
* this.props = props
|
|
@@ -26,16 +26,17 @@ import { createCfnOutput } from '../utils'
|
|
|
26
26
|
* logBucket,
|
|
27
27
|
* logBucketPolicy
|
|
28
28
|
* )
|
|
29
|
+
* }
|
|
29
30
|
* }
|
|
30
31
|
*
|
|
31
|
-
* @see [CDK CloudTrail Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
32
|
+
* @see [CDK CloudTrail Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudtrail-readme.html}
|
|
32
33
|
*/
|
|
33
34
|
export class CloudTrailManager {
|
|
34
35
|
/**
|
|
35
36
|
* @summary Method to create a cloud trail
|
|
36
37
|
* @param {string} id scoped id of the resource
|
|
37
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
38
|
-
* @param {CloudTrailProps} props
|
|
38
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
39
|
+
* @param {types.CloudTrailProps} props
|
|
39
40
|
* @param {logs.CfnLogGroup} logGroup
|
|
40
41
|
* @param {s3.IBucket} dataBucket
|
|
41
42
|
* @param {s3.IBucket} logBucket
|
|
@@ -43,8 +44,8 @@ export class CloudTrailManager {
|
|
|
43
44
|
*/
|
|
44
45
|
public createCloudTrail(
|
|
45
46
|
id: string,
|
|
46
|
-
scope: CommonConstruct,
|
|
47
|
-
props: CloudTrailProps,
|
|
47
|
+
scope: common.CommonConstruct,
|
|
48
|
+
props: types.CloudTrailProps,
|
|
48
49
|
logGroup: logs.CfnLogGroup,
|
|
49
50
|
dataBucket: s3.IBucket,
|
|
50
51
|
logBucket: s3.IBucket,
|
|
@@ -83,8 +84,8 @@ export class CloudTrailManager {
|
|
|
83
84
|
cloudTrail.addDependsOn(logGroup)
|
|
84
85
|
cloudTrail.addDependsOn(role)
|
|
85
86
|
|
|
86
|
-
createCfnOutput(`${id}-trailName`, scope, cloudTrail.trailName)
|
|
87
|
-
createCfnOutput(`${id}-trailArn`, scope, cloudTrail.attrArn)
|
|
87
|
+
utils.createCfnOutput(`${id}-trailName`, scope, cloudTrail.trailName)
|
|
88
|
+
utils.createCfnOutput(`${id}-trailArn`, scope, cloudTrail.attrArn)
|
|
88
89
|
|
|
89
90
|
return { cloudTrailRole: role, cloudTrail }
|
|
90
91
|
}
|
|
@@ -1,45 +1,48 @@
|
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
import * as common from '../../common'
|
|
5
|
+
import * as types from '../../types'
|
|
6
|
+
import * as utils from '../../utils'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @category Utils
|
|
10
|
+
*/
|
|
11
|
+
enum CloudWatchWidgetType {
|
|
12
|
+
Text = 'Text',
|
|
13
|
+
SingleValue = 'SingleValue',
|
|
14
|
+
Graph = 'Graph',
|
|
15
|
+
AlarmStatus = 'AlarmStatus',
|
|
16
|
+
LogQuery = 'LogQuery',
|
|
17
|
+
}
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* @stability stable
|
|
19
21
|
* @category Management & Governance
|
|
20
22
|
* @summary Provides operations on AWS CloudWatch.
|
|
21
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
22
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
23
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
24
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
23
25
|
* @example
|
|
24
26
|
* import * as common from '@gradientedge/cdk-utils'
|
|
25
27
|
*
|
|
26
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
28
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
27
29
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
28
30
|
* super(parent, id, props)
|
|
29
31
|
* this.props = props
|
|
30
32
|
* this.cloudWatchManager.createAlarmForMetric('MyAlarm', this, metric)
|
|
33
|
+
* }
|
|
31
34
|
* }
|
|
32
35
|
*
|
|
33
|
-
* @see [CDK CloudWatch Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
36
|
+
* @see [CDK CloudWatch Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch-readme.html}
|
|
34
37
|
*/
|
|
35
38
|
export class CloudWatchManager {
|
|
36
39
|
/**
|
|
37
40
|
* @summary Method to create a cloudwatch alarm for a given expression
|
|
38
41
|
* @param {string} id scoped id of the resource
|
|
39
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
40
|
-
* @param {AlarmProps} props
|
|
42
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
43
|
+
* @param {types.AlarmProps} props
|
|
41
44
|
*/
|
|
42
|
-
public createAlarmForExpression(id: string, scope: CommonConstruct, props: AlarmProps) {
|
|
45
|
+
public createAlarmForExpression(id: string, scope: common.CommonConstruct, props: types.AlarmProps) {
|
|
43
46
|
if (!props) throw `Alarm props undefined`
|
|
44
47
|
|
|
45
48
|
if (!props.expression) throw `Could not find expression for Alarm props for id:${id}`
|
|
@@ -65,8 +68,8 @@ export class CloudWatchManager {
|
|
|
65
68
|
datapointsToAlarm: props.datapointsToAlarm,
|
|
66
69
|
})
|
|
67
70
|
|
|
68
|
-
createCfnOutput(`${id}-alarmArn`, scope, alarm.alarmArn)
|
|
69
|
-
createCfnOutput(`${id}-alarmName`, scope, alarm.alarmName)
|
|
71
|
+
utils.createCfnOutput(`${id}-alarmArn`, scope, alarm.alarmArn)
|
|
72
|
+
utils.createCfnOutput(`${id}-alarmName`, scope, alarm.alarmName)
|
|
70
73
|
|
|
71
74
|
return alarm
|
|
72
75
|
}
|
|
@@ -74,11 +77,16 @@ export class CloudWatchManager {
|
|
|
74
77
|
/**
|
|
75
78
|
* @summary Method to create a cloudwatch alarm for a given metric
|
|
76
79
|
* @param {string} id scoped id of the resource
|
|
77
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
78
|
-
* @param {AlarmProps} props
|
|
80
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
81
|
+
* @param {types.AlarmProps} props
|
|
79
82
|
* @param metric
|
|
80
83
|
*/
|
|
81
|
-
public createAlarmForMetric(
|
|
84
|
+
public createAlarmForMetric(
|
|
85
|
+
id: string,
|
|
86
|
+
scope: common.CommonConstruct,
|
|
87
|
+
props: types.AlarmProps,
|
|
88
|
+
metric: watch.Metric
|
|
89
|
+
) {
|
|
82
90
|
if (!props) throw `Alarm props undefined`
|
|
83
91
|
|
|
84
92
|
const alarm = metric.createAlarm(scope, `${id}`, {
|
|
@@ -91,8 +99,8 @@ export class CloudWatchManager {
|
|
|
91
99
|
datapointsToAlarm: props.datapointsToAlarm,
|
|
92
100
|
})
|
|
93
101
|
|
|
94
|
-
createCfnOutput(`${id}-alarmArn`, scope, alarm.alarmArn)
|
|
95
|
-
createCfnOutput(`${id}-alarmName`, scope, alarm.alarmName)
|
|
102
|
+
utils.createCfnOutput(`${id}-alarmArn`, scope, alarm.alarmArn)
|
|
103
|
+
utils.createCfnOutput(`${id}-alarmName`, scope, alarm.alarmName)
|
|
96
104
|
|
|
97
105
|
return alarm
|
|
98
106
|
}
|
|
@@ -100,11 +108,16 @@ export class CloudWatchManager {
|
|
|
100
108
|
/**
|
|
101
109
|
* @summary Method to create a cloudwatch dashboard
|
|
102
110
|
* @param {string} id scoped id of the resource
|
|
103
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
104
|
-
* @param {DashboardProps} props
|
|
111
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
112
|
+
* @param {types.DashboardProps} props
|
|
105
113
|
* @param widgets
|
|
106
114
|
*/
|
|
107
|
-
public createDashboard(
|
|
115
|
+
public createDashboard(
|
|
116
|
+
id: string,
|
|
117
|
+
scope: common.CommonConstruct,
|
|
118
|
+
props: types.DashboardProps,
|
|
119
|
+
widgets?: watch.IWidget[][]
|
|
120
|
+
) {
|
|
108
121
|
if (!props) throw `Dashboard props undefined`
|
|
109
122
|
|
|
110
123
|
const dashboard = new watch.Dashboard(scope, `${id}`, {
|
|
@@ -115,17 +128,17 @@ export class CloudWatchManager {
|
|
|
115
128
|
widgets: widgets,
|
|
116
129
|
})
|
|
117
130
|
|
|
118
|
-
createCfnOutput(`${id}-dashboardName`, scope, props.dashboardName)
|
|
131
|
+
utils.createCfnOutput(`${id}-dashboardName`, scope, props.dashboardName)
|
|
119
132
|
|
|
120
133
|
return dashboard
|
|
121
134
|
}
|
|
122
135
|
|
|
123
136
|
/**
|
|
124
137
|
* @summary Method to create cloudwatch widgets
|
|
125
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
138
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
126
139
|
* @param props
|
|
127
140
|
*/
|
|
128
|
-
public createWidgets(scope: CommonConstruct, props: any[]) {
|
|
141
|
+
public createWidgets(scope: common.CommonConstruct, props: any[]) {
|
|
129
142
|
if (!props || props.length == 0) throw `Widget props undefined`
|
|
130
143
|
|
|
131
144
|
const widgets: any = []
|
|
@@ -137,10 +150,10 @@ export class CloudWatchManager {
|
|
|
137
150
|
/**
|
|
138
151
|
* @summary Method to create a cloudwatch widget
|
|
139
152
|
* @param {string} id scoped id of the resource
|
|
140
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
153
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
141
154
|
* @param props
|
|
142
155
|
*/
|
|
143
|
-
public createWidget(id: string, scope: CommonConstruct, props: any) {
|
|
156
|
+
public createWidget(id: string, scope: common.CommonConstruct, props: any) {
|
|
144
157
|
if (!props) throw `Widget props undefined`
|
|
145
158
|
|
|
146
159
|
const metrics = this.determineMetrics(scope, props.metricProps)
|
|
@@ -167,10 +180,10 @@ export class CloudWatchManager {
|
|
|
167
180
|
/**
|
|
168
181
|
* @summary Method to create a cloudwatch text widget
|
|
169
182
|
* @param {string} id scoped id of the resource
|
|
170
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
171
|
-
* @param {TextWidgetProps} props
|
|
183
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
184
|
+
* @param {types.TextWidgetProps} props
|
|
172
185
|
*/
|
|
173
|
-
public createTextWidget(id: string, scope: CommonConstruct, props: TextWidgetProps) {
|
|
186
|
+
public createTextWidget(id: string, scope: common.CommonConstruct, props: types.TextWidgetProps) {
|
|
174
187
|
const widget = new watch.TextWidget({
|
|
175
188
|
markdown: props.markdown,
|
|
176
189
|
width: props.width,
|
|
@@ -185,11 +198,16 @@ export class CloudWatchManager {
|
|
|
185
198
|
/**
|
|
186
199
|
* @summary Method to create a cloudwatch numeric widget
|
|
187
200
|
* @param {string} id scoped id of the resource
|
|
188
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
189
|
-
* @param {NumericWidgetProps} props
|
|
201
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
202
|
+
* @param {types.NumericWidgetProps} props
|
|
190
203
|
* @param metrics
|
|
191
204
|
*/
|
|
192
|
-
public createSingleValueWidget(
|
|
205
|
+
public createSingleValueWidget(
|
|
206
|
+
id: string,
|
|
207
|
+
scope: common.CommonConstruct,
|
|
208
|
+
props: types.NumericWidgetProps,
|
|
209
|
+
metrics: IMetric[]
|
|
210
|
+
) {
|
|
193
211
|
const widget = new watch.SingleValueWidget({
|
|
194
212
|
metrics: metrics,
|
|
195
213
|
setPeriodToTimeRange: props.setPeriodToTimeRange,
|
|
@@ -207,15 +225,15 @@ export class CloudWatchManager {
|
|
|
207
225
|
/**
|
|
208
226
|
* @summary Method to create a cloudwatch graph widget
|
|
209
227
|
* @param {string} id scoped id of the resource
|
|
210
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
211
|
-
* @param {GraphWidgetProps} props
|
|
228
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
229
|
+
* @param {types.GraphWidgetProps} props
|
|
212
230
|
* @param leftYMetrics
|
|
213
231
|
* @param rightYMetrics
|
|
214
232
|
*/
|
|
215
233
|
public createGraphWidget(
|
|
216
234
|
id: string,
|
|
217
|
-
scope: CommonConstruct,
|
|
218
|
-
props: GraphWidgetProps,
|
|
235
|
+
scope: common.CommonConstruct,
|
|
236
|
+
props: types.GraphWidgetProps,
|
|
219
237
|
leftYMetrics?: IMetric[],
|
|
220
238
|
rightYMetrics?: IMetric[]
|
|
221
239
|
) {
|
|
@@ -243,14 +261,14 @@ export class CloudWatchManager {
|
|
|
243
261
|
/**
|
|
244
262
|
* @summary Method to create a cloudwatch alarm status widget
|
|
245
263
|
* @param {string} id scoped id of the resource
|
|
246
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
247
|
-
* @param {AlarmStatusWidgetProps} props
|
|
264
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
265
|
+
* @param {types.AlarmStatusWidgetProps} props
|
|
248
266
|
* @param {watch.IAlarm[]} alarms
|
|
249
267
|
*/
|
|
250
268
|
public createAlarmStatusWidget(
|
|
251
269
|
id: string,
|
|
252
|
-
scope: CommonConstruct,
|
|
253
|
-
props: AlarmStatusWidgetProps,
|
|
270
|
+
scope: common.CommonConstruct,
|
|
271
|
+
props: types.AlarmStatusWidgetProps,
|
|
254
272
|
alarms: watch.IAlarm[]
|
|
255
273
|
) {
|
|
256
274
|
const widget = new watch.AlarmStatusWidget({
|
|
@@ -268,11 +286,16 @@ export class CloudWatchManager {
|
|
|
268
286
|
/**
|
|
269
287
|
* @summary Method to create a cloudwatch log query widget
|
|
270
288
|
* @param {string} id scoped id of the resource
|
|
271
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
272
|
-
* @param {LogQueryWidgetProps} props
|
|
289
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
290
|
+
* @param {types.LogQueryWidgetProps} props
|
|
273
291
|
* @param {string[]} logGroupNames
|
|
274
292
|
*/
|
|
275
|
-
public createLogQueryWidget(
|
|
293
|
+
public createLogQueryWidget(
|
|
294
|
+
id: string,
|
|
295
|
+
scope: common.CommonConstruct,
|
|
296
|
+
props: types.LogQueryWidgetProps,
|
|
297
|
+
logGroupNames: string[]
|
|
298
|
+
) {
|
|
276
299
|
const widget = new watch.LogQueryWidget({
|
|
277
300
|
logGroupNames: logGroupNames,
|
|
278
301
|
queryString: props.queryString,
|
|
@@ -290,13 +313,13 @@ export class CloudWatchManager {
|
|
|
290
313
|
|
|
291
314
|
/**
|
|
292
315
|
* @summary Utility method to determine the metrics and dimensions
|
|
293
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
294
|
-
* @param {MetricProps[]} metricProps
|
|
316
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
317
|
+
* @param {types.MetricProps[]} metricProps
|
|
295
318
|
*/
|
|
296
|
-
private determineMetrics(scope: CommonConstruct, metricProps: MetricProps[]) {
|
|
319
|
+
private determineMetrics(scope: common.CommonConstruct, metricProps: types.MetricProps[]) {
|
|
297
320
|
const metrics: watch.IMetric[] = []
|
|
298
321
|
if (metricProps) {
|
|
299
|
-
metricProps.forEach((metricProp: MetricProps) => {
|
|
322
|
+
metricProps.forEach((metricProp: types.MetricProps) => {
|
|
300
323
|
let metricDimensions: watch.DimensionHash = metricProp.dimensionsMap || {}
|
|
301
324
|
if (metricProp.functionName) {
|
|
302
325
|
metricDimensions = {
|
|
@@ -349,10 +372,10 @@ export class CloudWatchManager {
|
|
|
349
372
|
/**
|
|
350
373
|
* @summary Utility method to determine the configured alarms
|
|
351
374
|
* @param {string} id scoped id of the resource
|
|
352
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
375
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
353
376
|
* @param {watch.AlarmProps[]} alarmProps
|
|
354
377
|
*/
|
|
355
|
-
private determineAlarms(id: string, scope: CommonConstruct, alarmProps: watch.AlarmProps[]) {
|
|
378
|
+
private determineAlarms(id: string, scope: common.CommonConstruct, alarmProps: watch.AlarmProps[]) {
|
|
356
379
|
const alarms: watch.IAlarm[] = []
|
|
357
380
|
if (alarmProps) {
|
|
358
381
|
alarmProps.forEach((alarmProp: watch.AlarmProps) => {
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
2
|
-
import * as codebuild from 'aws-cdk-lib/aws-codebuild'
|
|
3
1
|
import * as cdk from 'aws-cdk-lib'
|
|
2
|
+
import * as codebuild from 'aws-cdk-lib/aws-codebuild'
|
|
3
|
+
import * as common from '../../common'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
+
* @stability stable
|
|
7
|
+
* @category Developer Tools
|
|
8
|
+
* @summary Provides operations on AWS Code Build.
|
|
9
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
10
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
11
|
+
* @example
|
|
12
|
+
* import { common.CommonConstruct } from '@gradientedge/cdk-utils'
|
|
13
|
+
*
|
|
14
|
+
* class CustomConstruct extends common.CommonConstruct {
|
|
15
|
+
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
16
|
+
* super(parent, id, props)
|
|
17
|
+
* this.props = props
|
|
18
|
+
* this.codeBuildManager.createImageForCloudfrontInvalidation('MyInvalidation', this, './docker ')
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
6
21
|
*
|
|
22
|
+
* @see [CDK Codebuild Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild-readme.html}
|
|
7
23
|
*/
|
|
8
24
|
export class CodeBuildManager {
|
|
9
25
|
/**
|
|
@@ -12,7 +28,7 @@ export class CodeBuildManager {
|
|
|
12
28
|
* @param scope
|
|
13
29
|
* @param dockerfilePath
|
|
14
30
|
*/
|
|
15
|
-
public createImageForCloudfrontInvalidation(id: string, scope: CommonConstruct, dockerfilePath: string) {
|
|
31
|
+
public createImageForCloudfrontInvalidation(id: string, scope: common.CommonConstruct, dockerfilePath: string) {
|
|
16
32
|
return scope.ecrManager.createDockerImage(`${id}-build-image`, scope, dockerfilePath)
|
|
17
33
|
}
|
|
18
34
|
|
|
@@ -26,7 +42,7 @@ export class CodeBuildManager {
|
|
|
26
42
|
*/
|
|
27
43
|
public createProjectForCloudfrontInvalidation(
|
|
28
44
|
id: string,
|
|
29
|
-
scope: CommonConstruct,
|
|
45
|
+
scope: common.CommonConstruct,
|
|
30
46
|
dockerFilepath: string,
|
|
31
47
|
distributionId: string,
|
|
32
48
|
paths?: string
|