@gradientedge/cdk-utils 8.91.0 → 8.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +40 -0
- package/app/api-destined-function/src/lib/lambda.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.d.ts +6 -6
- package/dist/app/api-destined-function/src/lib/lambda.js +6 -6
- package/dist/lib/lambda.d.ts +6 -6
- package/dist/lib/lambda.js +6 -6
- package/dist/lib/lambda.js.map +1 -1
- package/dist/src/lib/common/construct.d.ts +4 -7
- package/dist/src/lib/common/construct.js +4 -7
- package/dist/src/lib/common/stack.d.ts +9 -13
- package/dist/src/lib/common/stack.js +9 -13
- package/dist/src/lib/common/types.d.ts +0 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/event.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +0 -27
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +41 -68
- package/dist/src/lib/construct/api-to-eventbridge-target/types.d.ts +13 -25
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.js +0 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +0 -37
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +44 -81
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/types.d.ts +1 -5
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/api.js +0 -3
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +0 -14
- package/dist/src/lib/construct/api-to-lambda-target/main.js +7 -21
- package/dist/src/lib/construct/api-to-lambda-target/types.d.ts +7 -13
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/graphql-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/graphql-api-lambda/types.d.ts +4 -8
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +1 -12
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +0 -12
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +2 -14
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +0 -18
- package/dist/src/lib/construct/rest-api-lambda/main.js +1 -19
- package/dist/src/lib/construct/rest-api-lambda/types.d.ts +6 -10
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +0 -11
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +3 -14
- package/dist/src/lib/construct/rest-api-lambda-with-cache/types.d.ts +1 -3
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +0 -25
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +32 -52
- package/dist/src/lib/construct/site-with-ecs-backend/types.d.ts +10 -11
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +0 -8
- package/dist/src/lib/construct/static-asset-deployment/main.js +0 -8
- package/dist/src/lib/construct/static-asset-deployment/types.d.ts +1 -1
- package/dist/src/lib/construct/static-site/main.d.ts +0 -17
- package/dist/src/lib/construct/static-site/main.js +1 -18
- package/dist/src/lib/construct/static-site/types.d.ts +9 -11
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +21 -25
- package/dist/src/lib/services/aws/api-gateway/main.js +42 -46
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +0 -2
- package/dist/src/lib/services/aws/appconfig/constants.d.ts +0 -6
- package/dist/src/lib/services/aws/appconfig/constants.js +26 -32
- package/dist/src/lib/services/aws/appconfig/main.d.ts +16 -19
- package/dist/src/lib/services/aws/appconfig/main.js +19 -22
- package/dist/src/lib/services/aws/appconfig/types.d.ts +1 -3
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -10
- package/dist/src/lib/services/aws/certificate-manager/main.js +5 -10
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +3 -5
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +41 -47
- package/dist/src/lib/services/aws/cloudfront/main.js +56 -62
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +1 -7
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +8 -12
- package/dist/src/lib/services/aws/cloudtrail/main.js +8 -12
- package/dist/src/lib/services/aws/cloudtrail/types.d.ts +0 -2
- package/dist/src/lib/services/aws/cloudwatch/logs.d.ts +11 -15
- package/dist/src/lib/services/aws/cloudwatch/logs.js +15 -19
- package/dist/src/lib/services/aws/cloudwatch/main.d.ts +80 -84
- package/dist/src/lib/services/aws/cloudwatch/main.js +116 -122
- package/dist/src/lib/services/aws/cloudwatch/types.d.ts +20 -42
- package/dist/src/lib/services/aws/codebuild/main.d.ts +0 -4
- package/dist/src/lib/services/aws/codebuild/main.js +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -7
- package/dist/src/lib/services/aws/dynamodb/main.js +13 -17
- package/dist/src/lib/services/aws/dynamodb/types.d.ts +0 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +3 -7
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +3 -7
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +19 -23
- package/dist/src/lib/services/aws/elastic-container-service/main.js +35 -39
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +1 -9
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +9 -13
- package/dist/src/lib/services/aws/elastic-file-system/main.js +14 -18
- package/dist/src/lib/services/aws/elastic-file-system/types.d.ts +1 -5
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +5 -9
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -12
- package/dist/src/lib/services/aws/elastic-kubernetes-service/types.d.ts +1 -3
- package/dist/src/lib/services/aws/elasticache/main.d.ts +14 -18
- package/dist/src/lib/services/aws/elasticache/main.js +35 -39
- package/dist/src/lib/services/aws/elasticache/types.d.ts +0 -4
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +25 -29
- package/dist/src/lib/services/aws/eventbridge/main.js +34 -38
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +6 -9
- package/dist/src/lib/services/aws/eventbridge/target.js +8 -10
- package/dist/src/lib/services/aws/eventbridge/types.d.ts +2 -10
- package/dist/src/lib/services/aws/evidently/main.d.ts +15 -19
- package/dist/src/lib/services/aws/evidently/main.js +19 -23
- package/dist/src/lib/services/aws/evidently/types.d.ts +0 -10
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +66 -70
- package/dist/src/lib/services/aws/identity-access-management/main.js +97 -101
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +3 -7
- package/dist/src/lib/services/aws/key-management-service/main.js +6 -10
- package/dist/src/lib/services/aws/key-management-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/lambda/main.d.ts +42 -47
- package/dist/src/lib/services/aws/lambda/main.js +64 -69
- package/dist/src/lib/services/aws/lambda/types.d.ts +6 -16
- package/dist/src/lib/services/aws/route53/main.d.ts +17 -21
- package/dist/src/lib/services/aws/route53/main.js +19 -23
- package/dist/src/lib/services/aws/route53/types.d.ts +0 -2
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +6 -19
- package/dist/src/lib/services/aws/secrets-manager/main.js +6 -25
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +8 -12
- package/dist/src/lib/services/aws/simple-notification-service/main.js +10 -14
- package/dist/src/lib/services/aws/simple-notification-service/types.d.ts +0 -2
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +11 -15
- package/dist/src/lib/services/aws/simple-queue-service/main.js +19 -23
- package/dist/src/lib/services/aws/simple-queue-service/types.d.ts +4 -6
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +24 -32
- package/dist/src/lib/services/aws/simple-storage-service/main.js +32 -40
- package/dist/src/lib/services/aws/simple-storage-service/types.d.ts +2 -8
- package/dist/src/lib/services/aws/step-function/main.d.ts +55 -59
- package/dist/src/lib/services/aws/step-function/main.js +91 -95
- package/dist/src/lib/services/aws/step-function/types.d.ts +0 -32
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +10 -16
- package/dist/src/lib/services/aws/systems-manager/main.js +13 -19
- package/dist/src/lib/services/aws/systems-manager/types.d.ts +0 -2
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +9 -12
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +10 -16
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +6 -10
- package/dist/src/lib/services/aws/web-application-firewall/main.js +12 -16
- package/dist/src/lib/services/aws/web-application-firewall/types.d.ts +0 -4
- package/dist/src/lib/types/aws/index.d.ts +0 -2
- package/dist/src/lib/utils/aws/index.d.ts +6 -9
- package/dist/src/lib/utils/aws/index.js +7 -10
- package/dist/src/lib/utils/index.d.ts +6 -13
- package/dist/src/lib/utils/index.js +4 -12
- package/package.json +1 -1
- package/src/lib/common/construct.ts +4 -7
- package/src/lib/common/stack.ts +9 -13
- package/src/lib/common/types.ts +0 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/event.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target/main.ts +41 -68
- package/src/lib/construct/api-to-eventbridge-target/types.ts +13 -25
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +0 -3
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +44 -81
- package/src/lib/construct/api-to-eventbridge-target-with-sns/types.ts +1 -5
- package/src/lib/construct/api-to-lambda-target/api.ts +0 -3
- package/src/lib/construct/api-to-lambda-target/main.ts +7 -21
- package/src/lib/construct/api-to-lambda-target/types.ts +7 -13
- package/src/lib/construct/graphql-api-lambda/main.ts +1 -19
- package/src/lib/construct/graphql-api-lambda/types.ts +4 -8
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +1 -12
- package/src/lib/construct/graphql-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/lambda-with-iam-access/main.ts +2 -14
- package/src/lib/construct/rest-api-lambda/main.ts +1 -19
- package/src/lib/construct/rest-api-lambda/types.ts +6 -10
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +3 -14
- package/src/lib/construct/rest-api-lambda-with-cache/types.ts +1 -3
- package/src/lib/construct/site-with-ecs-backend/main.ts +31 -52
- package/src/lib/construct/site-with-ecs-backend/types.ts +10 -11
- package/src/lib/construct/static-asset-deployment/main.ts +0 -8
- package/src/lib/construct/static-asset-deployment/types.ts +1 -1
- package/src/lib/construct/static-site/main.ts +1 -18
- package/src/lib/construct/static-site/types.ts +9 -11
- package/src/lib/services/aws/api-gateway/main.ts +43 -47
- package/src/lib/services/aws/api-gateway/types.ts +0 -2
- package/src/lib/services/aws/appconfig/constants.ts +26 -32
- package/src/lib/services/aws/appconfig/main.ts +19 -22
- package/src/lib/services/aws/appconfig/types.ts +1 -3
- package/src/lib/services/aws/certificate-manager/main.ts +5 -10
- package/src/lib/services/aws/certificate-manager/types.ts +3 -5
- package/src/lib/services/aws/cloudfront/main.ts +56 -62
- package/src/lib/services/aws/cloudfront/types.ts +1 -7
- package/src/lib/services/aws/cloudtrail/main.ts +8 -12
- package/src/lib/services/aws/cloudtrail/types.ts +0 -2
- package/src/lib/services/aws/cloudwatch/logs.ts +15 -19
- package/src/lib/services/aws/cloudwatch/main.ts +116 -122
- package/src/lib/services/aws/cloudwatch/types.ts +20 -42
- package/src/lib/services/aws/codebuild/main.ts +3 -7
- package/src/lib/services/aws/dynamodb/main.ts +13 -17
- package/src/lib/services/aws/dynamodb/types.ts +0 -2
- package/src/lib/services/aws/elastic-container-registry/main.ts +3 -7
- package/src/lib/services/aws/elastic-container-service/main.ts +35 -39
- package/src/lib/services/aws/elastic-container-service/types.ts +1 -9
- package/src/lib/services/aws/elastic-file-system/main.ts +14 -18
- package/src/lib/services/aws/elastic-file-system/types.ts +1 -5
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +8 -12
- package/src/lib/services/aws/elastic-kubernetes-service/types.ts +1 -3
- package/src/lib/services/aws/elasticache/main.ts +35 -39
- package/src/lib/services/aws/elasticache/types.ts +0 -4
- package/src/lib/services/aws/eventbridge/main.ts +34 -38
- package/src/lib/services/aws/eventbridge/target.ts +8 -11
- package/src/lib/services/aws/eventbridge/types.ts +2 -10
- package/src/lib/services/aws/evidently/main.ts +19 -23
- package/src/lib/services/aws/evidently/types.ts +0 -10
- package/src/lib/services/aws/identity-access-management/main.ts +97 -101
- package/src/lib/services/aws/key-management-service/main.ts +6 -10
- package/src/lib/services/aws/key-management-service/types.ts +0 -2
- package/src/lib/services/aws/lambda/main.ts +64 -69
- package/src/lib/services/aws/lambda/types.ts +6 -16
- package/src/lib/services/aws/route53/main.ts +19 -23
- package/src/lib/services/aws/route53/types.ts +0 -2
- package/src/lib/services/aws/secrets-manager/main.ts +6 -28
- package/src/lib/services/aws/simple-notification-service/main.ts +10 -14
- package/src/lib/services/aws/simple-notification-service/types.ts +0 -2
- package/src/lib/services/aws/simple-queue-service/main.ts +19 -23
- package/src/lib/services/aws/simple-queue-service/types.ts +4 -6
- package/src/lib/services/aws/simple-storage-service/main.ts +32 -40
- package/src/lib/services/aws/simple-storage-service/types.ts +2 -8
- package/src/lib/services/aws/step-function/main.ts +91 -95
- package/src/lib/services/aws/step-function/types.ts +0 -32
- package/src/lib/services/aws/systems-manager/main.ts +13 -19
- package/src/lib/services/aws/systems-manager/types.ts +0 -2
- package/src/lib/services/aws/virtual-private-cloud/main.ts +10 -16
- package/src/lib/services/aws/web-application-firewall/main.ts +12 -16
- package/src/lib/services/aws/web-application-firewall/types.ts +0 -4
- package/src/lib/types/aws/index.ts +0 -2
- package/src/lib/utils/aws/index.ts +7 -10
- package/src/lib/utils/index.ts +4 -12
|
@@ -2,8 +2,6 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
2
2
|
import * as ec2 from 'aws-cdk-lib/aws-ec2';
|
|
3
3
|
import { CommonConstruct } from '../../../common';
|
|
4
4
|
/**
|
|
5
|
-
* @category cdk-utils.vpc-manager
|
|
6
|
-
* @subcategory Construct
|
|
7
5
|
* @classdesc Provides operations on AWS VPC.
|
|
8
6
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
9
7
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -17,29 +15,28 @@ import { CommonConstruct } from '../../../common';
|
|
|
17
15
|
* this.vpcManager.createVpc('MyVPC', this)
|
|
18
16
|
* }
|
|
19
17
|
* }
|
|
20
|
-
*
|
|
21
18
|
* @see [CDK VPC Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.@aws-cdk_aws-ec2.Vpc.html}
|
|
22
19
|
*/
|
|
23
20
|
export declare class VpcManager {
|
|
24
21
|
/**
|
|
25
22
|
* @summary Method to create a new vpc
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
23
|
+
* @param id scoped id of the resource
|
|
24
|
+
* @param scope scope in which this resource is defined
|
|
25
|
+
* @param props
|
|
29
26
|
*/
|
|
30
27
|
createVpc(id: string, scope: CommonConstruct, props: ec2.VpcProps): cdk.aws_ec2.Vpc;
|
|
31
28
|
/**
|
|
32
29
|
* @summary Method to create a common vpc
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
30
|
+
* @param scope scope in which this resource is defined
|
|
31
|
+
* @param props
|
|
32
|
+
* @param vpcIdentifier optional identifier for VPC
|
|
36
33
|
*/
|
|
37
34
|
createCommonVpc(scope: CommonConstruct, props: ec2.VpcProps, vpcIdentifier?: string): cdk.aws_ec2.Vpc;
|
|
38
35
|
/**
|
|
39
36
|
* @summary Method to retrieve a common vpc
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
37
|
+
* @param id scoped id of the resource
|
|
38
|
+
* @param scope scope in which this resource is defined
|
|
39
|
+
* @param vpcIdentifier optional identifier for VPC
|
|
43
40
|
*/
|
|
44
41
|
retrieveCommonVpc(id: string, scope: CommonConstruct, vpcIdentifier?: string): cdk.aws_ec2.IVpc;
|
|
45
42
|
}
|
|
@@ -28,14 +28,9 @@ const cdk = __importStar(require("aws-cdk-lib"));
|
|
|
28
28
|
const ec2 = __importStar(require("aws-cdk-lib/aws-ec2"));
|
|
29
29
|
const utils = __importStar(require("../../../utils"));
|
|
30
30
|
/**
|
|
31
|
-
* @stability stable
|
|
32
|
-
* @category cdk-utils.vpc-manager
|
|
33
|
-
* @subcategory Construct
|
|
34
31
|
*/
|
|
35
32
|
const CommonVpcIdentifier = 'CommonVpc';
|
|
36
33
|
/**
|
|
37
|
-
* @category cdk-utils.vpc-manager
|
|
38
|
-
* @subcategory Construct
|
|
39
34
|
* @classdesc Provides operations on AWS VPC.
|
|
40
35
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
41
36
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -49,22 +44,21 @@ const CommonVpcIdentifier = 'CommonVpc';
|
|
|
49
44
|
* this.vpcManager.createVpc('MyVPC', this)
|
|
50
45
|
* }
|
|
51
46
|
* }
|
|
52
|
-
*
|
|
53
47
|
* @see [CDK VPC Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.@aws-cdk_aws-ec2.Vpc.html}
|
|
54
48
|
*/
|
|
55
49
|
class VpcManager {
|
|
56
50
|
/**
|
|
57
51
|
* @summary Method to create a new vpc
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @param
|
|
52
|
+
* @param id scoped id of the resource
|
|
53
|
+
* @param scope scope in which this resource is defined
|
|
54
|
+
* @param props
|
|
61
55
|
*/
|
|
62
56
|
createVpc(id, scope, props) {
|
|
63
57
|
if (!props)
|
|
64
58
|
throw `Vpc props undefined for ${id}`;
|
|
65
59
|
const vpc = new ec2.Vpc(scope, `${id}`, {
|
|
66
|
-
maxAzs: props.maxAzs,
|
|
67
60
|
ipAddresses: props.ipAddresses,
|
|
61
|
+
maxAzs: props.maxAzs,
|
|
68
62
|
});
|
|
69
63
|
utils.createCfnOutput(`${id}Id`, scope, vpc.vpcId);
|
|
70
64
|
utils.createCfnOutput(`${id}PublicSubnetIds`, scope, vpc.publicSubnets.map(subnet => subnet.subnetId).toString());
|
|
@@ -77,9 +71,9 @@ class VpcManager {
|
|
|
77
71
|
}
|
|
78
72
|
/**
|
|
79
73
|
* @summary Method to create a common vpc
|
|
80
|
-
* @param
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
74
|
+
* @param scope scope in which this resource is defined
|
|
75
|
+
* @param props
|
|
76
|
+
* @param vpcIdentifier optional identifier for VPC
|
|
83
77
|
*/
|
|
84
78
|
createCommonVpc(scope, props, vpcIdentifier) {
|
|
85
79
|
const vpc = this.createVpc(CommonVpcIdentifier, scope, props);
|
|
@@ -88,9 +82,9 @@ class VpcManager {
|
|
|
88
82
|
}
|
|
89
83
|
/**
|
|
90
84
|
* @summary Method to retrieve a common vpc
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @param
|
|
85
|
+
* @param id scoped id of the resource
|
|
86
|
+
* @param scope scope in which this resource is defined
|
|
87
|
+
* @param vpcIdentifier optional identifier for VPC
|
|
94
88
|
*/
|
|
95
89
|
retrieveCommonVpc(id, scope, vpcIdentifier) {
|
|
96
90
|
return ec2.Vpc.fromLookup(scope, `${id}`, { vpcName: vpcIdentifier ?? CommonVpcIdentifier });
|
|
@@ -2,9 +2,6 @@ import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
|
|
|
2
2
|
import { CommonConstruct } from '../../../common';
|
|
3
3
|
import { WafIPSetProps, WafWebACLProps } from './types';
|
|
4
4
|
/**
|
|
5
|
-
* @stability stable
|
|
6
|
-
* @category cdk-utils.waf-manager
|
|
7
|
-
* @subcategory Construct
|
|
8
5
|
* @classdesc Provides operations on AWS WAF.
|
|
9
6
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
10
7
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -18,22 +15,21 @@ import { WafIPSetProps, WafWebACLProps } from './types';
|
|
|
18
15
|
* this.wafManager.createWebAcl('MyWebAcl', this)
|
|
19
16
|
* }
|
|
20
17
|
* }
|
|
21
|
-
*
|
|
22
18
|
* @see [CDK WAF Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_waf-readme.html}
|
|
23
19
|
*/
|
|
24
20
|
export declare class WafManager {
|
|
25
21
|
/**
|
|
26
22
|
* @summary Method to create an ip set
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
23
|
+
* @param id scoped id of the resource
|
|
24
|
+
* @param scope scope in which this resource is defined
|
|
25
|
+
* @param props
|
|
30
26
|
*/
|
|
31
27
|
createIpSet(id: string, scope: CommonConstruct, props: WafIPSetProps): wafv2.CfnIPSet;
|
|
32
28
|
/**
|
|
33
29
|
* @summary Method to create a web acl
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
30
|
+
* @param id scoped id of the resource
|
|
31
|
+
* @param scope scope in which this resource is defined
|
|
32
|
+
* @param props
|
|
37
33
|
*/
|
|
38
34
|
createWebAcl(id: string, scope: CommonConstruct, props: WafWebACLProps): wafv2.CfnWebACL;
|
|
39
35
|
}
|
|
@@ -27,9 +27,6 @@ exports.WafManager = void 0;
|
|
|
27
27
|
const wafv2 = __importStar(require("aws-cdk-lib/aws-wafv2"));
|
|
28
28
|
const utils = __importStar(require("../../../utils"));
|
|
29
29
|
/**
|
|
30
|
-
* @stability stable
|
|
31
|
-
* @category cdk-utils.waf-manager
|
|
32
|
-
* @subcategory Construct
|
|
33
30
|
* @classdesc Provides operations on AWS WAF.
|
|
34
31
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
35
32
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
@@ -43,24 +40,23 @@ const utils = __importStar(require("../../../utils"));
|
|
|
43
40
|
* this.wafManager.createWebAcl('MyWebAcl', this)
|
|
44
41
|
* }
|
|
45
42
|
* }
|
|
46
|
-
*
|
|
47
43
|
* @see [CDK WAF Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_waf-readme.html}
|
|
48
44
|
*/
|
|
49
45
|
class WafManager {
|
|
50
46
|
/**
|
|
51
47
|
* @summary Method to create an ip set
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
48
|
+
* @param id scoped id of the resource
|
|
49
|
+
* @param scope scope in which this resource is defined
|
|
50
|
+
* @param props
|
|
55
51
|
*/
|
|
56
52
|
createIpSet(id, scope, props) {
|
|
57
53
|
if (!props)
|
|
58
54
|
throw `WAF Ip Set props undefined for ${id}`;
|
|
59
55
|
const ipSet = new wafv2.CfnIPSet(scope, `${id}`, {
|
|
60
|
-
name: scope.isProductionStage() ? props.name : `${props.name}-${scope.props.stage}`,
|
|
61
|
-
description: `IP Set for ${id} - ${scope.props.stage} stage`,
|
|
62
56
|
addresses: props.addresses,
|
|
57
|
+
description: `IP Set for ${id} - ${scope.props.stage} stage`,
|
|
63
58
|
ipAddressVersion: props.ipAddressVersion,
|
|
59
|
+
name: scope.isProductionStage() ? props.name : `${props.name}-${scope.props.stage}`,
|
|
64
60
|
scope: props.scope,
|
|
65
61
|
});
|
|
66
62
|
utils.createCfnOutput(`${id}-ipSetId`, scope, ipSet.attrId);
|
|
@@ -69,21 +65,21 @@ class WafManager {
|
|
|
69
65
|
}
|
|
70
66
|
/**
|
|
71
67
|
* @summary Method to create a web acl
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
68
|
+
* @param id scoped id of the resource
|
|
69
|
+
* @param scope scope in which this resource is defined
|
|
70
|
+
* @param props
|
|
75
71
|
*/
|
|
76
72
|
createWebAcl(id, scope, props) {
|
|
77
73
|
if (!props)
|
|
78
74
|
throw `WAF WebACL props undefined for ${id}`;
|
|
79
75
|
const webAcl = new wafv2.CfnWebACL(scope, `${id}`, {
|
|
80
|
-
name: scope.isProductionStage() ? props.name : `${props.name}-${scope.props.stage}`,
|
|
81
|
-
description: `Web Acl for ${id} - ${scope.props.stage} stage`,
|
|
82
76
|
defaultAction: props.defaultAction,
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
description: `Web Acl for ${id} - ${scope.props.stage} stage`,
|
|
78
|
+
name: scope.isProductionStage() ? props.name : `${props.name}-${scope.props.stage}`,
|
|
85
79
|
rules: props.rules,
|
|
80
|
+
scope: props.scope,
|
|
86
81
|
tags: [{ key: 'service', value: scope.props.name }],
|
|
82
|
+
visibilityConfig: props.visibilityConfig,
|
|
87
83
|
});
|
|
88
84
|
utils.createCfnOutput(`${id}-webAclId`, scope, webAcl.attrId);
|
|
89
85
|
utils.createCfnOutput(`${id}-webAclArn`, scope, webAcl.attrArn);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { CfnIPSetProps, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2';
|
|
2
2
|
/**
|
|
3
|
-
* @category cdk-utils.waf-manager
|
|
4
|
-
* @subcategory Properties
|
|
5
3
|
*/
|
|
6
4
|
export interface WafIPSetProps extends CfnIPSetProps {
|
|
7
5
|
}
|
|
8
6
|
/**
|
|
9
|
-
* @category cdk-utils.waf-manager
|
|
10
|
-
* @subcategory Properties
|
|
11
7
|
*/
|
|
12
8
|
export interface WafWebACLProps extends CfnWebACLProps {
|
|
13
9
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import * as cdk from 'aws-cdk-lib';
|
|
2
2
|
import { CommonConstruct } from '../../common';
|
|
3
3
|
/**
|
|
4
|
-
* @category cdk-utils.utils
|
|
5
4
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
* @return {cdk.CfnOutput} The CloudFormation output
|
|
5
|
+
* @param id scoped id of the resource
|
|
6
|
+
* @param scope scope in which this resource is defined
|
|
7
|
+
* @param value the value of the exported output
|
|
8
|
+
* @param description optional description for the output
|
|
9
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
10
|
+
* @returns The CloudFormation output
|
|
14
11
|
*/
|
|
15
12
|
export declare function createCfnOutput(id: string, scope: CommonConstruct, value?: string, description?: string, overrideId?: boolean): cdk.CfnOutput;
|
|
@@ -27,23 +27,20 @@ exports.createCfnOutput = void 0;
|
|
|
27
27
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
28
28
|
const _ = __importStar(require("lodash"));
|
|
29
29
|
/**
|
|
30
|
-
* @category cdk-utils.utils
|
|
31
30
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @
|
|
38
|
-
*
|
|
39
|
-
* @return {cdk.CfnOutput} The CloudFormation output
|
|
31
|
+
* @param id scoped id of the resource
|
|
32
|
+
* @param scope scope in which this resource is defined
|
|
33
|
+
* @param value the value of the exported output
|
|
34
|
+
* @param description optional description for the output
|
|
35
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
36
|
+
* @returns The CloudFormation output
|
|
40
37
|
*/
|
|
41
38
|
function createCfnOutput(id, scope, value, description, overrideId = true) {
|
|
42
39
|
const camelName = _.camelCase(id);
|
|
43
40
|
const output = new cdk.CfnOutput(scope, id, {
|
|
41
|
+
description,
|
|
44
42
|
exportName: `${scope.props.stackName}-${camelName}`,
|
|
45
43
|
value: value ?? '',
|
|
46
|
-
description,
|
|
47
44
|
});
|
|
48
45
|
if (overrideId) {
|
|
49
46
|
output.overrideLogicalId(camelName);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './aws';
|
|
2
2
|
/**
|
|
3
|
-
* @category cdk-utils.utils
|
|
4
3
|
*/
|
|
5
4
|
export declare enum LogLevel {
|
|
6
5
|
DEBUG = "DEBUG",
|
|
@@ -11,52 +10,46 @@ export declare enum LogLevel {
|
|
|
11
10
|
CRITICAL = "CRITICAL"
|
|
12
11
|
}
|
|
13
12
|
/**
|
|
14
|
-
* @category cdk-utils.utils
|
|
15
13
|
* @param stage
|
|
16
14
|
*/
|
|
17
15
|
export declare const isDevStage: (stage: string) => boolean;
|
|
18
16
|
/**
|
|
19
|
-
* @category cdk-utils.utils
|
|
20
17
|
* @param stage
|
|
21
18
|
*/
|
|
22
19
|
export declare const isTestStage: (stage: string) => boolean;
|
|
23
20
|
/**
|
|
24
|
-
* @category cdk-utils.utils
|
|
25
21
|
* @param stage
|
|
26
22
|
*/
|
|
27
23
|
export declare const isUatStage: (stage: string) => boolean;
|
|
28
24
|
/**
|
|
29
|
-
* @category cdk-utils.utils
|
|
30
25
|
* @param stage
|
|
31
26
|
*/
|
|
32
27
|
export declare const isPrdStage: (stage: string) => boolean;
|
|
33
28
|
/**
|
|
34
|
-
* @category cdk-utils.utils
|
|
35
29
|
* @param error
|
|
36
30
|
*/
|
|
37
31
|
export declare function redirectError(error: any): {
|
|
38
|
-
statusCode: number;
|
|
39
32
|
body: string;
|
|
40
|
-
isBase64Encoded: boolean;
|
|
41
33
|
headers: {
|
|
42
34
|
'Access-Control-Allow-Origin': string;
|
|
43
35
|
};
|
|
44
|
-
|
|
36
|
+
isBase64Encoded: boolean;
|
|
45
37
|
statusCode: number;
|
|
38
|
+
} & {
|
|
46
39
|
body: string;
|
|
40
|
+
statusCode: number;
|
|
47
41
|
};
|
|
48
42
|
/**
|
|
49
|
-
* @category cdk-utils.utils
|
|
50
43
|
* @param message
|
|
51
44
|
*/
|
|
52
45
|
export declare function redirectSuccess(message: any): {
|
|
53
|
-
statusCode: number;
|
|
54
46
|
body: string;
|
|
55
|
-
isBase64Encoded: boolean;
|
|
56
47
|
headers: {
|
|
57
48
|
'Access-Control-Allow-Origin': string;
|
|
58
49
|
};
|
|
59
|
-
|
|
50
|
+
isBase64Encoded: boolean;
|
|
60
51
|
statusCode: number;
|
|
52
|
+
} & {
|
|
61
53
|
body: string;
|
|
54
|
+
statusCode: number;
|
|
62
55
|
};
|
|
@@ -17,18 +17,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.redirectSuccess = exports.redirectError = exports.isPrdStage = exports.isUatStage = exports.isTestStage = exports.isDevStage = exports.LogLevel = void 0;
|
|
18
18
|
__exportStar(require("./aws"), exports);
|
|
19
19
|
/**
|
|
20
|
-
* @category cdk-utils.utils
|
|
21
20
|
*/
|
|
22
21
|
const defaultResponseObject = {
|
|
23
|
-
statusCode: 200,
|
|
24
22
|
body: '',
|
|
25
|
-
isBase64Encoded: false,
|
|
26
23
|
headers: {
|
|
27
24
|
'Access-Control-Allow-Origin': '*',
|
|
28
25
|
},
|
|
26
|
+
isBase64Encoded: false,
|
|
27
|
+
statusCode: 200,
|
|
29
28
|
};
|
|
30
29
|
/**
|
|
31
|
-
* @category cdk-utils.utils
|
|
32
30
|
*/
|
|
33
31
|
var LogLevel;
|
|
34
32
|
(function (LogLevel) {
|
|
@@ -40,49 +38,43 @@ var LogLevel;
|
|
|
40
38
|
LogLevel["CRITICAL"] = "CRITICAL";
|
|
41
39
|
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
42
40
|
/**
|
|
43
|
-
* @category cdk-utils.utils
|
|
44
41
|
* @param stage
|
|
45
42
|
*/
|
|
46
43
|
const isDevStage = (stage) => stage === 'dev';
|
|
47
44
|
exports.isDevStage = isDevStage;
|
|
48
45
|
/**
|
|
49
|
-
* @category cdk-utils.utils
|
|
50
46
|
* @param stage
|
|
51
47
|
*/
|
|
52
48
|
const isTestStage = (stage) => stage === 'tst';
|
|
53
49
|
exports.isTestStage = isTestStage;
|
|
54
50
|
/**
|
|
55
|
-
* @category cdk-utils.utils
|
|
56
51
|
* @param stage
|
|
57
52
|
*/
|
|
58
53
|
const isUatStage = (stage) => stage === 'uat';
|
|
59
54
|
exports.isUatStage = isUatStage;
|
|
60
55
|
/**
|
|
61
|
-
* @category cdk-utils.utils
|
|
62
56
|
* @param stage
|
|
63
57
|
*/
|
|
64
58
|
const isPrdStage = (stage) => stage === 'prd';
|
|
65
59
|
exports.isPrdStage = isPrdStage;
|
|
66
60
|
/**
|
|
67
|
-
* @category cdk-utils.utils
|
|
68
61
|
* @param error
|
|
69
62
|
*/
|
|
70
63
|
function redirectError(error) {
|
|
71
64
|
console.error(error, error.message, error.stack);
|
|
72
65
|
return Object.assign({}, defaultResponseObject, {
|
|
66
|
+
body: JSON.stringify(Object.assign({}, { error: error.message, success: false })),
|
|
73
67
|
statusCode: 500,
|
|
74
|
-
body: JSON.stringify(Object.assign({}, { success: false, error: error.message })),
|
|
75
68
|
});
|
|
76
69
|
}
|
|
77
70
|
exports.redirectError = redirectError;
|
|
78
71
|
/**
|
|
79
|
-
* @category cdk-utils.utils
|
|
80
72
|
* @param message
|
|
81
73
|
*/
|
|
82
74
|
function redirectSuccess(message) {
|
|
83
75
|
return Object.assign({}, defaultResponseObject, {
|
|
76
|
+
body: JSON.stringify(Object.assign({}, { error: message, success: true })),
|
|
84
77
|
statusCode: 200,
|
|
85
|
-
body: JSON.stringify(Object.assign({}, { success: true, error: message })),
|
|
86
78
|
});
|
|
87
79
|
}
|
|
88
80
|
exports.redirectSuccess = redirectSuccess;
|
package/package.json
CHANGED
|
@@ -5,11 +5,8 @@ import * as utils from '../utils'
|
|
|
5
5
|
import { CommonStackProps } from './types'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @stability stable
|
|
9
|
-
* @category cdk-utils.common-construct
|
|
10
8
|
* @subcategory Construct
|
|
11
9
|
* @classdesc Common construct to use as a base for all higher level constructs.
|
|
12
|
-
*
|
|
13
10
|
* @example
|
|
14
11
|
* import { CommonConstruct } from '@gradientedge/cdk-utils';
|
|
15
12
|
*
|
|
@@ -92,10 +89,10 @@ export class CommonConstruct extends Construct {
|
|
|
92
89
|
|
|
93
90
|
/**
|
|
94
91
|
* @summary Helper method to add CloudFormation outputs from the construct
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @param
|
|
92
|
+
* @param id scoped id of the resource
|
|
93
|
+
* @param value the value of the exported output
|
|
94
|
+
* @param description optional description for the output
|
|
95
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
99
96
|
*/
|
|
100
97
|
protected addCfnOutput(id: string, value: string, description?: string, overrideId = true): cdk.CfnOutput {
|
|
101
98
|
return utils.createCfnOutput(id, this, value, description, overrideId)
|
package/src/lib/common/stack.ts
CHANGED
|
@@ -8,11 +8,7 @@ const appRoot = require('app-root-path')
|
|
|
8
8
|
const fs = require('fs')
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @stability stable
|
|
12
|
-
* @category cdk-utils.common-stack
|
|
13
|
-
* @subcategory Construct
|
|
14
11
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
15
|
-
*
|
|
16
12
|
* @example
|
|
17
13
|
* import { CommonStack } from '@gradientedge/cdk-utils'
|
|
18
14
|
*
|
|
@@ -46,22 +42,22 @@ export class CommonStack extends cdk.Stack {
|
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
44
|
* @summary Method to determine the core CDK construct properties injected via context cdk.json
|
|
49
|
-
* @param
|
|
50
|
-
* @
|
|
45
|
+
* @param props The stack properties
|
|
46
|
+
* @returns The stack properties
|
|
51
47
|
*/
|
|
52
48
|
protected determineConstructProps(props: cdk.StackProps) {
|
|
53
49
|
return {
|
|
54
|
-
stackName: props.stackName,
|
|
55
|
-
name: props.stackName || 'cdk-utils',
|
|
56
|
-
region: this.node.tryGetContext('region'),
|
|
57
|
-
stage: this.node.tryGetContext('stage'),
|
|
58
50
|
domainName: this.node.tryGetContext('domainName'),
|
|
59
|
-
|
|
51
|
+
excludeDomainNameForBuckets: this.node.tryGetContext('excludeDomainNameForBuckets'),
|
|
60
52
|
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
61
|
-
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
62
53
|
logRetention: this.node.tryGetContext('logRetention'),
|
|
63
|
-
|
|
54
|
+
name: props.stackName || 'cdk-utils',
|
|
64
55
|
nodejsRuntime: this.node.tryGetContext('nodejsRuntime') ?? CommonStack.NODEJS_RUNTIME,
|
|
56
|
+
region: this.node.tryGetContext('region'),
|
|
57
|
+
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
58
|
+
stackName: props.stackName,
|
|
59
|
+
stage: this.node.tryGetContext('stage'),
|
|
60
|
+
subDomain: this.node.tryGetContext('subDomain'),
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
|
package/src/lib/common/types.ts
CHANGED
|
@@ -7,9 +7,6 @@ import * as sns from 'aws-cdk-lib/aws-sns'
|
|
|
7
7
|
import { ApiToEventBridgeTargetRestApiType } from './types'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @stability stable
|
|
11
|
-
* @category cdk-utils.api-to-eventbridge-target
|
|
12
|
-
* @subcategory member
|
|
13
10
|
* @classdesc Provides a construct to contain api resources for ApiToEventBridgeTargetWithSns
|
|
14
11
|
*/
|
|
15
12
|
export class ApiToEventbridgeTargetRestApi implements ApiToEventBridgeTargetRestApiType {
|
|
@@ -3,9 +3,6 @@ import * as logs from 'aws-cdk-lib/aws-logs'
|
|
|
3
3
|
import { ApiToEventBridgeTargetEventType } from './types'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @stability stable
|
|
7
|
-
* @category cdk-utils.api-to-eventbridge-target
|
|
8
|
-
* @subcategory member
|
|
9
6
|
* @classdesc Provides a construct to contain event resources for ApiToEventBridgeTargetWithSns
|
|
10
7
|
*/
|
|
11
8
|
export class ApiToEventbridgeTargetEvent implements ApiToEventBridgeTargetEventType {
|