@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,40 +1,41 @@
|
|
|
1
|
+
import * as pylambda from '@aws-cdk/aws-lambda-python-alpha'
|
|
1
2
|
import * as cdk from 'aws-cdk-lib'
|
|
2
3
|
import * as ec2 from 'aws-cdk-lib/aws-ec2'
|
|
3
4
|
import * as efs from 'aws-cdk-lib/aws-efs'
|
|
4
5
|
import * as iam from 'aws-cdk-lib/aws-iam'
|
|
5
6
|
import * as lambda from 'aws-cdk-lib/aws-lambda'
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { createCfnOutput } from '../utils'
|
|
7
|
+
import * as common from '../../common'
|
|
8
|
+
import * as types from '../../types'
|
|
9
|
+
import * as utils from '../../utils'
|
|
10
10
|
import { CloudFrontManager } from './cloudFrontManager'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @stability stable
|
|
14
14
|
* @category Compute
|
|
15
15
|
* @summary Provides operations on AWS Lambda.
|
|
16
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
17
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
16
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
17
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
18
18
|
* @example
|
|
19
19
|
* import * as common from '@gradientedge/cdk-utils'
|
|
20
20
|
*
|
|
21
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
21
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
22
22
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
23
23
|
* super(parent, id, props)
|
|
24
24
|
* this.props = props
|
|
25
25
|
* this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
26
|
+
* }
|
|
26
27
|
* }
|
|
27
28
|
*
|
|
28
|
-
* @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
29
|
+
* @see [CDK Lambda Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html}
|
|
29
30
|
*/
|
|
30
31
|
export class LambdaManager {
|
|
31
32
|
/**
|
|
32
33
|
* @summary Method to create a lambda layer (nodejs)
|
|
33
34
|
* @param {string} id scoped id of the resource
|
|
34
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
35
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
35
36
|
* @param {lambda.AssetCode} code
|
|
36
37
|
*/
|
|
37
|
-
public createLambdaLayer(id: string, scope: CommonConstruct, code: lambda.AssetCode) {
|
|
38
|
+
public createLambdaLayer(id: string, scope: common.CommonConstruct, code: lambda.AssetCode) {
|
|
38
39
|
const lambdaLayer = new lambda.LayerVersion(scope, `${id}`, {
|
|
39
40
|
compatibleRuntimes: [lambda.Runtime.NODEJS_14_X],
|
|
40
41
|
code: code,
|
|
@@ -42,7 +43,7 @@ export class LambdaManager {
|
|
|
42
43
|
layerVersionName: `${id}-${scope.props.stage}`,
|
|
43
44
|
})
|
|
44
45
|
|
|
45
|
-
createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn)
|
|
46
|
+
utils.createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn)
|
|
46
47
|
|
|
47
48
|
return lambdaLayer
|
|
48
49
|
}
|
|
@@ -50,10 +51,10 @@ export class LambdaManager {
|
|
|
50
51
|
/**
|
|
51
52
|
* @summary Method to create a lambda layer (python)
|
|
52
53
|
* @param {string} id scoped id of the resource
|
|
53
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
54
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
54
55
|
* @param {string} entry path to layer source
|
|
55
56
|
*/
|
|
56
|
-
public createPythonLambdaLayer(id: string, scope: CommonConstruct, entry: string) {
|
|
57
|
+
public createPythonLambdaLayer(id: string, scope: common.CommonConstruct, entry: string) {
|
|
57
58
|
const lambdaLayer = new pylambda.PythonLayerVersion(scope, `${id}`, {
|
|
58
59
|
compatibleRuntimes: [lambda.Runtime.PYTHON_3_8],
|
|
59
60
|
description: `${id}`,
|
|
@@ -61,7 +62,7 @@ export class LambdaManager {
|
|
|
61
62
|
layerVersionName: `${id}-${scope.props.stage}`,
|
|
62
63
|
})
|
|
63
64
|
|
|
64
|
-
createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn)
|
|
65
|
+
utils.createCfnOutput(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn)
|
|
65
66
|
|
|
66
67
|
return lambdaLayer
|
|
67
68
|
}
|
|
@@ -69,8 +70,8 @@ export class LambdaManager {
|
|
|
69
70
|
/**
|
|
70
71
|
* @summary Method to create a lambda function (nodejs)
|
|
71
72
|
* @param {string} id scoped id of the resource
|
|
72
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
73
|
-
* @param {LambdaProps} props
|
|
73
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
74
|
+
* @param {types.LambdaProps} props
|
|
74
75
|
* @param {iam.Role | iam.CfnRole} role
|
|
75
76
|
* @param {lambda.ILayerVersion[]} layers
|
|
76
77
|
* @param {lambda.AssetCode} code
|
|
@@ -83,8 +84,8 @@ export class LambdaManager {
|
|
|
83
84
|
*/
|
|
84
85
|
public createLambdaFunction(
|
|
85
86
|
id: string,
|
|
86
|
-
scope: CommonConstruct,
|
|
87
|
-
props: LambdaProps,
|
|
87
|
+
scope: common.CommonConstruct,
|
|
88
|
+
props: types.LambdaProps,
|
|
88
89
|
role: iam.Role | iam.CfnRole,
|
|
89
90
|
layers: lambda.ILayerVersion[],
|
|
90
91
|
code: lambda.AssetCode,
|
|
@@ -119,8 +120,8 @@ export class LambdaManager {
|
|
|
119
120
|
vpc: vpc,
|
|
120
121
|
})
|
|
121
122
|
|
|
122
|
-
createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
123
|
-
createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
123
|
+
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
124
|
+
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
124
125
|
|
|
125
126
|
return lambdaFunction
|
|
126
127
|
}
|
|
@@ -128,8 +129,8 @@ export class LambdaManager {
|
|
|
128
129
|
/**
|
|
129
130
|
* @summary Method to create a lambda function (python)
|
|
130
131
|
* @param {string} id scoped id of the resource
|
|
131
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
132
|
-
* @param {LambdaProps} props
|
|
132
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
133
|
+
* @param {types.LambdaProps} props
|
|
133
134
|
* @param {iam.Role | iam.CfnRole} role
|
|
134
135
|
* @param {lambda.ILayerVersion[]} layers
|
|
135
136
|
* @param {string} entry path to lambda source
|
|
@@ -144,8 +145,8 @@ export class LambdaManager {
|
|
|
144
145
|
|
|
145
146
|
public createPythonLambdaFunction(
|
|
146
147
|
id: string,
|
|
147
|
-
scope: CommonConstruct,
|
|
148
|
-
props: LambdaProps,
|
|
148
|
+
scope: common.CommonConstruct,
|
|
149
|
+
props: types.LambdaProps,
|
|
149
150
|
role: iam.Role | iam.CfnRole,
|
|
150
151
|
layers: lambda.ILayerVersion[],
|
|
151
152
|
entry: string,
|
|
@@ -182,8 +183,8 @@ export class LambdaManager {
|
|
|
182
183
|
vpc: vpc,
|
|
183
184
|
})
|
|
184
185
|
|
|
185
|
-
createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
186
|
-
createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
186
|
+
utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn)
|
|
187
|
+
utils.createCfnOutput(`${id}-lambdaName`, scope, lambdaFunction.functionName)
|
|
187
188
|
|
|
188
189
|
return lambdaFunction
|
|
189
190
|
}
|
|
@@ -192,8 +193,8 @@ export class LambdaManager {
|
|
|
192
193
|
* @summary Method to provision a Lambda@Edge function
|
|
193
194
|
*
|
|
194
195
|
* @param {string} id scoped id of the resource
|
|
195
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
196
|
-
* @param {LambdaEdgeProps} props lambda@edge properties
|
|
196
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
197
|
+
* @param {types.LambdaEdgeProps} props lambda@edge properties
|
|
197
198
|
* @param {lambda.ILayerVersion[]} layers
|
|
198
199
|
* @param {lambda.AssetCode} code
|
|
199
200
|
* @param {Map<string, string>} environment
|
|
@@ -204,8 +205,8 @@ export class LambdaManager {
|
|
|
204
205
|
*/
|
|
205
206
|
public createEdgeFunction(
|
|
206
207
|
id: string,
|
|
207
|
-
scope: CommonConstruct,
|
|
208
|
-
props: LambdaEdgeProps,
|
|
208
|
+
scope: common.CommonConstruct,
|
|
209
|
+
props: types.LambdaEdgeProps,
|
|
209
210
|
layers: lambda.ILayerVersion[],
|
|
210
211
|
code: lambda.AssetCode,
|
|
211
212
|
environment?: any,
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib'
|
|
2
2
|
import * as logs from 'aws-cdk-lib/aws-logs'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import * as common from '../../common'
|
|
4
|
+
import * as types from '../../types'
|
|
5
|
+
import * as utils from '../../utils'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @stability stable
|
|
9
9
|
* @category Management & Governance
|
|
10
10
|
* @summary Provides operations on AWS CloudWatch.
|
|
11
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
12
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
11
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
12
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
13
13
|
* @example
|
|
14
14
|
* import * as common from '@gradientedge/cdk-utils'
|
|
15
15
|
*
|
|
16
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
16
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
17
17
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
18
18
|
* super(parent, id, props)
|
|
19
19
|
* this.props = props
|
|
20
20
|
* this.logsManager.createMetricFilter('MyMetricFilter', this, logGroup)
|
|
21
|
+
* }
|
|
21
22
|
* }
|
|
22
23
|
*
|
|
23
|
-
* @see [CDK CloudWatch Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
24
|
+
* @see [CDK CloudWatch Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs-readme.html}
|
|
24
25
|
*/
|
|
25
26
|
export class LogManager {
|
|
26
27
|
/**
|
|
27
28
|
* @summary Method to create a cloudwatch metric filter
|
|
28
29
|
* @param {string} id scoped id of the resource
|
|
29
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
30
|
-
* @param {MetricFilterProps} props
|
|
30
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
31
|
+
* @param {types.MetricFilterProps} props
|
|
31
32
|
* @param {logs.ILogGroup} logGroup
|
|
32
33
|
*/
|
|
33
|
-
public createMetricFilter(
|
|
34
|
+
public createMetricFilter(
|
|
35
|
+
id: string,
|
|
36
|
+
scope: common.CommonConstruct,
|
|
37
|
+
props: types.MetricFilterProps,
|
|
38
|
+
logGroup: logs.ILogGroup
|
|
39
|
+
) {
|
|
34
40
|
if (!props) throw `MetricFilter props undefined`
|
|
35
41
|
|
|
36
42
|
const metricFilter = new logs.MetricFilter(scope, `${id}`, {
|
|
@@ -56,10 +62,10 @@ export class LogManager {
|
|
|
56
62
|
/**
|
|
57
63
|
* @summary Method to create a cloudwatch log group (cfn)
|
|
58
64
|
* @param {string} id scoped id of the resource
|
|
59
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
60
|
-
* @param {LogProps} props
|
|
65
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
66
|
+
* @param {types.LogProps} props
|
|
61
67
|
*/
|
|
62
|
-
public createCfnLogGroup(id: string, scope: CommonConstruct, props: LogProps) {
|
|
68
|
+
public createCfnLogGroup(id: string, scope: common.CommonConstruct, props: types.LogProps) {
|
|
63
69
|
if (!props) throw `Logs props undefined`
|
|
64
70
|
|
|
65
71
|
const logGroup = new logs.CfnLogGroup(scope, `${id}`, {
|
|
@@ -67,7 +73,7 @@ export class LogManager {
|
|
|
67
73
|
retentionInDays: props.retention,
|
|
68
74
|
})
|
|
69
75
|
|
|
70
|
-
createCfnOutput(`${id}-logGroupArn`, scope, logGroup.attrArn)
|
|
76
|
+
utils.createCfnOutput(`${id}-logGroupArn`, scope, logGroup.attrArn)
|
|
71
77
|
|
|
72
78
|
return logGroup
|
|
73
79
|
}
|
|
@@ -75,10 +81,10 @@ export class LogManager {
|
|
|
75
81
|
/**
|
|
76
82
|
* @summary Method to create a cloudwatch log group
|
|
77
83
|
* @param {string} id scoped id of the resource
|
|
78
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
79
|
-
* @param {LogProps} props
|
|
84
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
85
|
+
* @param {types.LogProps} props
|
|
80
86
|
*/
|
|
81
|
-
public createLogGroup(id: string, scope: CommonConstruct, props: LogProps) {
|
|
87
|
+
public createLogGroup(id: string, scope: common.CommonConstruct, props: types.LogProps) {
|
|
82
88
|
if (!props) throw `Logs props undefined`
|
|
83
89
|
|
|
84
90
|
const logGroup = new logs.LogGroup(scope, `${id}`, {
|
|
@@ -87,7 +93,7 @@ export class LogManager {
|
|
|
87
93
|
removalPolicy: props.removalPolicy ?? cdk.RemovalPolicy.DESTROY,
|
|
88
94
|
})
|
|
89
95
|
|
|
90
|
-
createCfnOutput(`${id}-logGroupArn`, scope, logGroup.logGroupArn)
|
|
96
|
+
utils.createCfnOutput(`${id}-logGroupArn`, scope, logGroup.logGroupArn)
|
|
91
97
|
|
|
92
98
|
return logGroup
|
|
93
99
|
}
|
|
@@ -2,36 +2,37 @@ import * as apig from 'aws-cdk-lib/aws-apigateway'
|
|
|
2
2
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
|
|
3
3
|
import * as route53 from 'aws-cdk-lib/aws-route53'
|
|
4
4
|
import * as route53Targets from 'aws-cdk-lib/aws-route53-targets'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import * as common from '../../common'
|
|
6
|
+
import * as types from '../../types'
|
|
7
|
+
import * as utils from '../../utils'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @stability stable
|
|
11
11
|
* @category Networking & Content Delivery
|
|
12
12
|
* @summary Provides operations on AWS Route53.
|
|
13
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
14
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
13
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
14
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
15
15
|
* @example
|
|
16
16
|
* import * as common from '@gradientedge/cdk-utils'
|
|
17
17
|
*
|
|
18
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
18
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
19
19
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
20
20
|
* super(parent, id, props)
|
|
21
21
|
* this.props = props
|
|
22
22
|
* this.route53Manager.createHostedZone('MyHostedZone', this)
|
|
23
|
+
* }
|
|
23
24
|
* }
|
|
24
25
|
*
|
|
25
|
-
* @see [CDK Route53 Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
26
|
+
* @see [CDK Route53 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_route53-readme.html}
|
|
26
27
|
*/
|
|
27
28
|
export class Route53Manager {
|
|
28
29
|
/**
|
|
29
30
|
* @summary Method to create a hosted zone
|
|
30
31
|
* @param {string} id scoped id of the resource
|
|
31
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
32
|
-
* @param {Route53Props} props
|
|
32
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
33
|
+
* @param {types.Route53Props} props
|
|
33
34
|
*/
|
|
34
|
-
public createHostedZone(id: string, scope: CommonConstruct, props: Route53Props) {
|
|
35
|
+
public createHostedZone(id: string, scope: common.CommonConstruct, props: types.Route53Props) {
|
|
35
36
|
let hostedZone: route53.IHostedZone
|
|
36
37
|
|
|
37
38
|
if (!props) throw `Route53 props undefined`
|
|
@@ -47,8 +48,8 @@ export class Route53Manager {
|
|
|
47
48
|
})
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
createCfnOutput(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId)
|
|
51
|
-
createCfnOutput(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn)
|
|
51
|
+
utils.createCfnOutput(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId)
|
|
52
|
+
utils.createCfnOutput(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn)
|
|
52
53
|
|
|
53
54
|
return hostedZone
|
|
54
55
|
}
|
|
@@ -56,12 +57,12 @@ export class Route53Manager {
|
|
|
56
57
|
/**
|
|
57
58
|
* @summary Method to create/lookup a hosted zone
|
|
58
59
|
* @param {string} id scoped id of the resource
|
|
59
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
60
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
60
61
|
* @param useExistingHostedZone Flag to indicate whether to lookup vs create new hosted zone
|
|
61
62
|
*/
|
|
62
63
|
public withHostedZoneFromFullyQualifiedDomainName(
|
|
63
64
|
id: string,
|
|
64
|
-
scope: CommonConstruct,
|
|
65
|
+
scope: common.CommonConstruct,
|
|
65
66
|
useExistingHostedZone: boolean
|
|
66
67
|
) {
|
|
67
68
|
let hostedZone: route53.IHostedZone
|
|
@@ -77,8 +78,8 @@ export class Route53Manager {
|
|
|
77
78
|
})
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
createCfnOutput(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId)
|
|
81
|
-
createCfnOutput(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn)
|
|
81
|
+
utils.createCfnOutput(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId)
|
|
82
|
+
utils.createCfnOutput(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn)
|
|
82
83
|
|
|
83
84
|
return hostedZone
|
|
84
85
|
}
|
|
@@ -86,14 +87,14 @@ export class Route53Manager {
|
|
|
86
87
|
/**
|
|
87
88
|
* @summary Method to create a-record for cloudfront target
|
|
88
89
|
* @param {string} id scoped id of the resource
|
|
89
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
90
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
90
91
|
* @param {cloudfront.IDistribution} distribution
|
|
91
92
|
* @param {route53.IHostedZone} hostedZone
|
|
92
93
|
* @param {string} recordName
|
|
93
94
|
*/
|
|
94
95
|
public createCloudFrontTargetARecord(
|
|
95
96
|
id: string,
|
|
96
|
-
scope: CommonConstruct,
|
|
97
|
+
scope: common.CommonConstruct,
|
|
97
98
|
distribution?: cloudfront.IDistribution,
|
|
98
99
|
hostedZone?: route53.IHostedZone,
|
|
99
100
|
recordName?: string
|
|
@@ -107,7 +108,7 @@ export class Route53Manager {
|
|
|
107
108
|
zone: hostedZone,
|
|
108
109
|
})
|
|
109
110
|
|
|
110
|
-
createCfnOutput(`${id}-aRecordDomainName`, scope, aRecord.domainName)
|
|
111
|
+
utils.createCfnOutput(`${id}-aRecordDomainName`, scope, aRecord.domainName)
|
|
111
112
|
|
|
112
113
|
return aRecord
|
|
113
114
|
}
|
|
@@ -115,14 +116,14 @@ export class Route53Manager {
|
|
|
115
116
|
/**
|
|
116
117
|
* @summary Method to create a-record for cloudfront target
|
|
117
118
|
* @param {string} id scoped id of the resource
|
|
118
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
119
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
119
120
|
* @param {cloudfront.IDistribution} distribution
|
|
120
121
|
* @param {route53.IHostedZone} hostedZone
|
|
121
122
|
* @param {string} recordName
|
|
122
123
|
*/
|
|
123
124
|
public createCloudFrontTargetARecordV2(
|
|
124
125
|
id: string,
|
|
125
|
-
scope: CommonConstruct,
|
|
126
|
+
scope: common.CommonConstruct,
|
|
126
127
|
distribution?: cloudfront.IDistribution,
|
|
127
128
|
hostedZone?: route53.IHostedZone,
|
|
128
129
|
recordName?: string
|
|
@@ -136,7 +137,7 @@ export class Route53Manager {
|
|
|
136
137
|
zone: hostedZone,
|
|
137
138
|
})
|
|
138
139
|
|
|
139
|
-
createCfnOutput(`${id}-aRecordDomainName`, scope, aRecord.domainName)
|
|
140
|
+
utils.createCfnOutput(`${id}-aRecordDomainName`, scope, aRecord.domainName)
|
|
140
141
|
|
|
141
142
|
return aRecord
|
|
142
143
|
}
|
|
@@ -144,14 +145,14 @@ export class Route53Manager {
|
|
|
144
145
|
/**
|
|
145
146
|
* @summary Method to create a-record for api gateway target
|
|
146
147
|
* @param {string} id scoped id of the resource
|
|
147
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
148
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
148
149
|
* @param recordName
|
|
149
150
|
* @param apiDomain
|
|
150
151
|
* @param hostedZone
|
|
151
152
|
*/
|
|
152
153
|
public createApiGatewayARecord(
|
|
153
154
|
id: string,
|
|
154
|
-
scope: CommonConstruct,
|
|
155
|
+
scope: common.CommonConstruct,
|
|
155
156
|
recordName: string,
|
|
156
157
|
apiDomain: apig.DomainName,
|
|
157
158
|
hostedZone: route53.IHostedZone
|
|
@@ -166,7 +167,7 @@ export class Route53Manager {
|
|
|
166
167
|
zone: hostedZone,
|
|
167
168
|
})
|
|
168
169
|
|
|
169
|
-
createCfnOutput(`${id}-a-record-domain-name`, scope, apiARecord.domainName)
|
|
170
|
+
utils.createCfnOutput(`${id}-a-record-domain-name`, scope, apiARecord.domainName)
|
|
170
171
|
|
|
171
172
|
return apiARecord
|
|
172
173
|
}
|
|
@@ -3,38 +3,39 @@ import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'
|
|
|
3
3
|
import * as iam from 'aws-cdk-lib/aws-iam'
|
|
4
4
|
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
5
5
|
import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment'
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import * as common from '../../common'
|
|
7
|
+
import * as types from '../../types'
|
|
8
|
+
import * as utils from '../../utils'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @stability stable
|
|
12
12
|
* @category Storage
|
|
13
13
|
* @summary Provides operations on AWS S3.
|
|
14
|
-
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
15
|
-
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
14
|
+
* - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
|
|
15
|
+
* - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
|
|
16
16
|
* @example
|
|
17
17
|
* import * as common from '@gradientedge/cdk-utils'
|
|
18
18
|
*
|
|
19
|
-
* class CustomConstruct extends common.CommonConstruct {
|
|
19
|
+
* class CustomConstruct extends common.common.CommonConstruct {
|
|
20
20
|
* constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
|
|
21
21
|
* super(parent, id, props)
|
|
22
22
|
* this.props = props
|
|
23
23
|
* this.s3Manager.createS3Bucket('MyBucket', this)
|
|
24
|
+
* }
|
|
24
25
|
* }
|
|
25
26
|
*
|
|
26
|
-
* @see [CDK S3 Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
27
|
+
* @see [CDK S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
|
|
27
28
|
*/
|
|
28
29
|
export class S3Manager {
|
|
29
30
|
/**
|
|
30
31
|
* @summary Method to determine S3 Bucket lifecycle properties
|
|
31
|
-
* @param {S3BucketProps} props bucket properties
|
|
32
|
+
* @param {types.S3BucketProps} props bucket properties
|
|
32
33
|
* @private
|
|
33
34
|
*/
|
|
34
|
-
protected determineBucketLifecycleRules(props: S3BucketProps) {
|
|
35
|
+
protected determineBucketLifecycleRules(props: types.S3BucketProps) {
|
|
35
36
|
if (!props.lifecycleRules) return undefined
|
|
36
37
|
|
|
37
|
-
const bucketLifecycleRules: LifecycleRule[] = []
|
|
38
|
+
const bucketLifecycleRules: types.LifecycleRule[] = []
|
|
38
39
|
props.lifecycleRules.forEach(lifecycleRule => {
|
|
39
40
|
bucketLifecycleRules.push({
|
|
40
41
|
id: lifecycleRule.id,
|
|
@@ -58,11 +59,11 @@ export class S3Manager {
|
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* @summary Method to determine the bucket name
|
|
61
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
62
|
-
* @param {S3BucketProps} props bucket properties
|
|
62
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
63
|
+
* @param {types.S3BucketProps} props bucket properties
|
|
63
64
|
* @private
|
|
64
65
|
*/
|
|
65
|
-
protected static determineBucketName(scope: CommonConstruct, props: S3BucketProps) {
|
|
66
|
+
protected static determineBucketName(scope: common.CommonConstruct, props: types.S3BucketProps) {
|
|
66
67
|
return scope.isProductionStage()
|
|
67
68
|
? `${props.bucketName}.${scope.fullyQualifiedDomainName}`
|
|
68
69
|
: `${props.bucketName}-${scope.props.stage}.${scope.fullyQualifiedDomainName}`
|
|
@@ -70,11 +71,11 @@ export class S3Manager {
|
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
73
|
* @summary Method to determine the log bucket name
|
|
73
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
74
|
-
* @param {S3BucketProps} props bucket properties
|
|
74
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
75
|
+
* @param {types.S3BucketProps} props bucket properties
|
|
75
76
|
* @private
|
|
76
77
|
*/
|
|
77
|
-
protected static determineLogBucketName(scope: CommonConstruct, props: S3BucketProps) {
|
|
78
|
+
protected static determineLogBucketName(scope: common.CommonConstruct, props: types.S3BucketProps) {
|
|
78
79
|
return scope.isProductionStage()
|
|
79
80
|
? `${props.logBucketName}.${scope.fullyQualifiedDomainName}`
|
|
80
81
|
: `${props.logBucketName}-${scope.props.stage}.${scope.fullyQualifiedDomainName}`
|
|
@@ -83,10 +84,10 @@ export class S3Manager {
|
|
|
83
84
|
/**
|
|
84
85
|
* @summary Method to create a s3 bucket
|
|
85
86
|
* @param {string} id scoped id of the resource
|
|
86
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
87
|
-
* @param {S3BucketProps} props bucket properties
|
|
87
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
88
|
+
* @param {types.S3BucketProps} props bucket properties
|
|
88
89
|
*/
|
|
89
|
-
public createS3Bucket(id: string, scope: CommonConstruct, props: S3BucketProps) {
|
|
90
|
+
public createS3Bucket(id: string, scope: common.CommonConstruct, props: types.S3BucketProps) {
|
|
90
91
|
if (!props) throw `S3 props undefined`
|
|
91
92
|
|
|
92
93
|
let bucket: s3.IBucket
|
|
@@ -130,8 +131,8 @@ export class S3Manager {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
createCfnOutput(`${id}-bucketName`, scope, bucket.bucketName)
|
|
134
|
-
createCfnOutput(`${id}-bucketArn`, scope, bucket.bucketArn)
|
|
134
|
+
utils.createCfnOutput(`${id}-bucketName`, scope, bucket.bucketName)
|
|
135
|
+
utils.createCfnOutput(`${id}-bucketArn`, scope, bucket.bucketArn)
|
|
135
136
|
|
|
136
137
|
return bucket
|
|
137
138
|
}
|
|
@@ -139,10 +140,10 @@ export class S3Manager {
|
|
|
139
140
|
/**
|
|
140
141
|
* @summary Method to create an iam bucket policy for cloudtrail
|
|
141
142
|
* @param {string} id scoped id of the resource
|
|
142
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
143
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
143
144
|
* @param {s3.IBucket} bucket
|
|
144
145
|
*/
|
|
145
|
-
public createBucketPolicyForCloudTrail(id: string, scope: CommonConstruct, bucket: s3.IBucket) {
|
|
146
|
+
public createBucketPolicyForCloudTrail(id: string, scope: common.CommonConstruct, bucket: s3.IBucket) {
|
|
146
147
|
const bucketPolicyDocument = new iam.PolicyDocument({
|
|
147
148
|
statements: [
|
|
148
149
|
new iam.PolicyStatement({
|
|
@@ -171,7 +172,7 @@ export class S3Manager {
|
|
|
171
172
|
/**
|
|
172
173
|
* @summary Method to create a s3 bucket deployment
|
|
173
174
|
* @param {string} id scoped id of the resource
|
|
174
|
-
* @param {CommonConstruct} scope scope in which this resource is defined
|
|
175
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
175
176
|
* @param {s3.IBucket} siteBucket
|
|
176
177
|
* @param {cloudfront.IDistribution} distribution
|
|
177
178
|
* @param {s3deploy.ISource[]} sources
|
|
@@ -180,7 +181,7 @@ export class S3Manager {
|
|
|
180
181
|
*/
|
|
181
182
|
public doBucketDeployment(
|
|
182
183
|
id: string,
|
|
183
|
-
scope: CommonConstruct,
|
|
184
|
+
scope: common.CommonConstruct,
|
|
184
185
|
siteBucket: s3.IBucket,
|
|
185
186
|
distribution: cloudfront.IDistribution,
|
|
186
187
|
sources: s3deploy.ISource[],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonConstruct } from '../common/commonConstruct'
|
|
2
1
|
import * as cdk from 'aws-cdk-lib'
|
|
3
2
|
import * as secretsManager from 'aws-cdk-lib/aws-secretsmanager'
|
|
3
|
+
import * as common from '../../common'
|
|
4
4
|
|
|
5
5
|
const AWS = require('aws-sdk')
|
|
6
6
|
const fs = require('fs')
|
|
@@ -9,19 +9,20 @@ const fs = require('fs')
|
|
|
9
9
|
* @stability experimental
|
|
10
10
|
* @category Security, Identity & Compliance
|
|
11
11
|
* @summary Provides operations on AWS Secrets Manager.
|
|
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
|
|
21
|
-
* this.
|
|
21
|
+
* this.secretsManager.loadSecret('MySecretName', 'eu-west-1')
|
|
22
|
+
* }
|
|
22
23
|
* }
|
|
23
24
|
*
|
|
24
|
-
* @see [CDK Secrets Manager Module]{@link https://docs.aws.amazon.com/cdk/api/
|
|
25
|
+
* @see [CDK Secrets Manager Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager-readme.html}
|
|
25
26
|
*/
|
|
26
27
|
export class SecretsManager {
|
|
27
28
|
/**
|
|
@@ -99,7 +100,12 @@ export class SecretsManager {
|
|
|
99
100
|
* @param stackName
|
|
100
101
|
* @param exportName
|
|
101
102
|
*/
|
|
102
|
-
public retrieveSecretFromSecretsManager(
|
|
103
|
+
public retrieveSecretFromSecretsManager(
|
|
104
|
+
id: string,
|
|
105
|
+
scope: common.CommonConstruct,
|
|
106
|
+
stackName: string,
|
|
107
|
+
exportName: string
|
|
108
|
+
) {
|
|
103
109
|
return secretsManager.Secret.fromSecretNameV2(
|
|
104
110
|
scope,
|
|
105
111
|
`${id}`,
|