@gradientedge/cdk-utils 9.2.0 → 9.4.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/app/api-destined-function/node_modules/.bin/uuid +2 -2
- package/app/api-destined-function/package.json +3 -3
- package/dist/src/lib/aws/utils/index.js +4 -5
- package/dist/src/lib/cloudflare/common/construct.d.ts +2 -1
- package/dist/src/lib/cloudflare/common/construct.js +2 -0
- package/dist/src/lib/cloudflare/services/index.d.ts +1 -0
- package/dist/src/lib/cloudflare/services/index.js +1 -0
- package/dist/src/lib/cloudflare/services/rule-set/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/rule-set/index.js +18 -0
- package/dist/src/lib/cloudflare/services/rule-set/main.d.ts +30 -0
- package/dist/src/lib/cloudflare/services/rule-set/main.js +46 -0
- package/dist/src/lib/cloudflare/services/rule-set/types.d.ts +3 -0
- package/dist/src/lib/cloudflare/services/rule-set/types.js +2 -0
- package/dist/src/lib/common/utils.d.ts +4 -4
- package/package.json +27 -27
- package/src/lib/cloudflare/common/construct.ts +3 -0
- package/src/lib/cloudflare/services/index.ts +1 -0
- package/src/lib/cloudflare/services/rule-set/index.ts +2 -0
- package/src/lib/cloudflare/services/rule-set/main.ts +49 -0
- package/src/lib/cloudflare/services/rule-set/types.ts +3 -0
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@
|
|
9
|
+
export NODE_PATH="/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/bin/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@
|
|
11
|
+
export NODE_PATH="/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/bin/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/uuid@10.0.0/node_modules:/home/runner/work/cdk-utils/cdk-utils/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../uuid/dist/bin/uuid" "$@"
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"test": "npx jest --ci --runInBand --passWithNoTests"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@types/uuid": "^
|
|
20
|
-
"uuid": "^
|
|
19
|
+
"@types/uuid": "^10.0.0",
|
|
20
|
+
"uuid": "^10.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"mkdirp": "^3.0.1",
|
|
24
|
-
"rimraf": "^5.0.
|
|
24
|
+
"rimraf": "^5.0.7"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.createCfnOutput = createCfnOutput;
|
|
7
|
+
exports.determineCredentials = determineCredentials;
|
|
8
|
+
exports.redirectError = redirectError;
|
|
9
|
+
exports.redirectSuccess = redirectSuccess;
|
|
7
10
|
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
8
11
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
9
12
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -28,7 +31,6 @@ function createCfnOutput(id, scope, value, description, overrideId = true) {
|
|
|
28
31
|
}
|
|
29
32
|
return output;
|
|
30
33
|
}
|
|
31
|
-
exports.createCfnOutput = createCfnOutput;
|
|
32
34
|
/**
|
|
33
35
|
*
|
|
34
36
|
*/
|
|
@@ -37,7 +39,6 @@ function determineCredentials() {
|
|
|
37
39
|
return (0, credential_providers_1.fromIni)();
|
|
38
40
|
return (0, credential_providers_1.fromEnv)();
|
|
39
41
|
}
|
|
40
|
-
exports.determineCredentials = determineCredentials;
|
|
41
42
|
/**
|
|
42
43
|
*/
|
|
43
44
|
const defaultResponseObject = {
|
|
@@ -58,7 +59,6 @@ function redirectError(error) {
|
|
|
58
59
|
statusCode: 500,
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
|
-
exports.redirectError = redirectError;
|
|
62
62
|
/**
|
|
63
63
|
* @param message
|
|
64
64
|
*/
|
|
@@ -68,4 +68,3 @@ function redirectSuccess(message) {
|
|
|
68
68
|
statusCode: 200,
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
exports.redirectSuccess = redirectSuccess;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AwsProvider } from '@cdktf/provider-aws/lib/provider';
|
|
2
2
|
import { S3Backend, TerraformStack } from 'cdktf';
|
|
3
3
|
import { Construct } from 'constructs';
|
|
4
|
-
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareRecordManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
4
|
+
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareRecordManager, CloudflareRuleSetManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
5
5
|
import { CommonCloudflareStackProps } from './types';
|
|
6
6
|
export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
7
7
|
props: CommonCloudflareStackProps;
|
|
@@ -14,6 +14,7 @@ export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
|
14
14
|
firewallManager: CloudflareFirewallManager;
|
|
15
15
|
pageManager: CloudflarePageManager;
|
|
16
16
|
recordManager: CloudflareRecordManager;
|
|
17
|
+
ruleSetManager: CloudflareRuleSetManager;
|
|
17
18
|
workerManager: CloudflareWorkerManager;
|
|
18
19
|
zoneManager: CloudflareZoneManager;
|
|
19
20
|
awsProvider: AwsProvider;
|
|
@@ -17,6 +17,7 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
17
17
|
firewallManager;
|
|
18
18
|
pageManager;
|
|
19
19
|
recordManager;
|
|
20
|
+
ruleSetManager;
|
|
20
21
|
workerManager;
|
|
21
22
|
zoneManager;
|
|
22
23
|
awsProvider;
|
|
@@ -32,6 +33,7 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
32
33
|
this.firewallManager = new services_1.CloudflareFirewallManager();
|
|
33
34
|
this.pageManager = new services_1.CloudflarePageManager();
|
|
34
35
|
this.recordManager = new services_1.CloudflareRecordManager();
|
|
36
|
+
this.ruleSetManager = new services_1.CloudflareRuleSetManager();
|
|
35
37
|
this.workerManager = new services_1.CloudflareWorkerManager();
|
|
36
38
|
this.zoneManager = new services_1.CloudflareZoneManager();
|
|
37
39
|
this.determineFullyQualifiedDomain();
|
|
@@ -21,5 +21,6 @@ __exportStar(require("./filter"), exports);
|
|
|
21
21
|
__exportStar(require("./firewall"), exports);
|
|
22
22
|
__exportStar(require("./page"), exports);
|
|
23
23
|
__exportStar(require("./record"), exports);
|
|
24
|
+
__exportStar(require("./rule-set"), exports);
|
|
24
25
|
__exportStar(require("./worker"), exports);
|
|
25
26
|
__exportStar(require("./zone"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./main"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
2
|
+
import { RulesetProps } from './types';
|
|
3
|
+
import { Ruleset } from '@cdktf/provider-cloudflare/lib/ruleset';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Cloudflare Rule Sets
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.ruleSetManager.createRuleSet('MyRule', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudflareRuleSetManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new Cloudflare Rule Set
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props rule set properties
|
|
27
|
+
* @see [CDKTF Ruleset Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/ruleset.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createRuleSet(id: string, scope: CommonCloudflareConstruct, props: RulesetProps): Ruleset;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareRuleSetManager = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const ruleset_1 = require("@cdktf/provider-cloudflare/lib/ruleset");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Rule Sets
|
|
8
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
9
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
13
|
+
*
|
|
14
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
15
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
16
|
+
* super(parent, id, props)
|
|
17
|
+
* this.props = props
|
|
18
|
+
* this.ruleSetManager.createRuleSet('MyRule', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class CloudflareRuleSetManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Rule Set
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props rule set properties
|
|
29
|
+
* @see [CDKTF Ruleset Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/ruleset.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createRuleSet(id, scope, props) {
|
|
32
|
+
if (!props)
|
|
33
|
+
throw `Props undefined for ${id}`;
|
|
34
|
+
const zoneId = props.zoneId
|
|
35
|
+
? props.zoneId
|
|
36
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
37
|
+
const ruleSet = new ruleset_1.Ruleset(scope, `${id}`, {
|
|
38
|
+
...props,
|
|
39
|
+
zoneId,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-ruleSetFriendlyUniqueId`, scope, ruleSet.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-ruleSetId`, scope, ruleSet.id);
|
|
43
|
+
return ruleSet;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CloudflareRuleSetManager = CloudflareRuleSetManager;
|
|
@@ -11,16 +11,16 @@ export declare enum LogLevel {
|
|
|
11
11
|
/**
|
|
12
12
|
* @param stage
|
|
13
13
|
*/
|
|
14
|
-
export declare const isDevStage: (stage: string) =>
|
|
14
|
+
export declare const isDevStage: (stage: string) => stage is "dev";
|
|
15
15
|
/**
|
|
16
16
|
* @param stage
|
|
17
17
|
*/
|
|
18
|
-
export declare const isTestStage: (stage: string) =>
|
|
18
|
+
export declare const isTestStage: (stage: string) => stage is "tst";
|
|
19
19
|
/**
|
|
20
20
|
* @param stage
|
|
21
21
|
*/
|
|
22
|
-
export declare const isUatStage: (stage: string) =>
|
|
22
|
+
export declare const isUatStage: (stage: string) => stage is "uat";
|
|
23
23
|
/**
|
|
24
24
|
* @param stage
|
|
25
25
|
*/
|
|
26
|
-
export declare const isPrdStage: (stage: string) =>
|
|
26
|
+
export declare const isPrdStage: (stage: string) => stage is "prd";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -50,62 +50,62 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
54
|
-
"@aws-sdk/credential-providers": "^3.
|
|
55
|
-
"@aws-sdk/types": "^3.
|
|
56
|
-
"@cdktf/provider-aws": "^19.
|
|
57
|
-
"@cdktf/provider-azurerm": "^12.
|
|
58
|
-
"@cdktf/provider-cloudflare": "^11.
|
|
59
|
-
"@types/lodash": "^4.17.
|
|
60
|
-
"@types/node": "^20.
|
|
61
|
-
"@types/uuid": "^
|
|
53
|
+
"@aws-sdk/client-secrets-manager": "^3.600.0",
|
|
54
|
+
"@aws-sdk/credential-providers": "^3.600.0",
|
|
55
|
+
"@aws-sdk/types": "^3.598.0",
|
|
56
|
+
"@cdktf/provider-aws": "^19.23.0",
|
|
57
|
+
"@cdktf/provider-azurerm": "^12.21.0",
|
|
58
|
+
"@cdktf/provider-cloudflare": "^11.13.0",
|
|
59
|
+
"@types/lodash": "^4.17.5",
|
|
60
|
+
"@types/node": "^20.14.8",
|
|
61
|
+
"@types/uuid": "^10.0.0",
|
|
62
62
|
"app-root-path": "^3.1.0",
|
|
63
|
-
"aws-cdk-lib": "^2.
|
|
63
|
+
"aws-cdk-lib": "^2.147.1",
|
|
64
64
|
"cdktf": "^0.20.7",
|
|
65
|
-
"cdktf-local-exec": "^0.5.
|
|
65
|
+
"cdktf-local-exec": "^0.5.23",
|
|
66
66
|
"constructs": "^10.3.0",
|
|
67
67
|
"lodash": "^4.17.21",
|
|
68
68
|
"moment": "^2.30.1",
|
|
69
69
|
"nconf": "^0.12.1",
|
|
70
70
|
"pluralize": "^8.0.0",
|
|
71
71
|
"ts-node": "^10.9.2",
|
|
72
|
-
"uuid": "^
|
|
72
|
+
"uuid": "^10.0.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@babel/core": "^7.24.
|
|
76
|
-
"@babel/eslint-parser": "^7.24.
|
|
75
|
+
"@babel/core": "^7.24.7",
|
|
76
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
77
77
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
78
78
|
"@types/jest": "^29.5.12",
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
80
|
-
"@typescript-eslint/parser": "^7.
|
|
81
|
-
"aws-cdk": "^2.
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
80
|
+
"@typescript-eslint/parser": "^7.14.1",
|
|
81
|
+
"aws-cdk": "^2.147.1",
|
|
82
82
|
"better-docs": "^2.7.3",
|
|
83
83
|
"codecov": "^3.8.3",
|
|
84
84
|
"commitizen": "^4.3.0",
|
|
85
85
|
"docdash": "^2.0.2",
|
|
86
86
|
"dotenv": "^16.4.5",
|
|
87
|
-
"eslint": "^9.
|
|
87
|
+
"eslint": "^9.5.0",
|
|
88
88
|
"eslint-config-prettier": "^9.1.0",
|
|
89
89
|
"eslint-plugin-import": "^2.29.1",
|
|
90
|
-
"eslint-plugin-jsdoc": "^48.
|
|
90
|
+
"eslint-plugin-jsdoc": "^48.4.0",
|
|
91
91
|
"husky": "^9.0.11",
|
|
92
92
|
"jest": "^29.7.0",
|
|
93
93
|
"jest-extended": "^4.0.2",
|
|
94
94
|
"jest-junit": "^16.0.0",
|
|
95
|
-
"jsdoc": "^4.0.
|
|
95
|
+
"jsdoc": "^4.0.3",
|
|
96
96
|
"jsdoc-babel": "^0.5.0",
|
|
97
97
|
"jsdoc-mermaid": "^1.0.0",
|
|
98
98
|
"jsdoc-plugin-typescript": "^2.2.1",
|
|
99
99
|
"jsdoc-to-markdown": "^8.0.1",
|
|
100
|
-
"prettier": "^3.2
|
|
100
|
+
"prettier": "^3.3.2",
|
|
101
101
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
102
|
-
"rimraf": "^5.0.
|
|
103
|
-
"semantic-release": "^
|
|
102
|
+
"rimraf": "^5.0.7",
|
|
103
|
+
"semantic-release": "^24.0.0",
|
|
104
104
|
"taffydb": "^2.7.3",
|
|
105
|
-
"ts-jest": "^29.1.
|
|
105
|
+
"ts-jest": "^29.1.5",
|
|
106
106
|
"ts-node": "^10.9.2",
|
|
107
|
-
"typescript": "5.
|
|
108
|
-
"yaml": "^2.4.
|
|
107
|
+
"typescript": "5.5.2",
|
|
108
|
+
"yaml": "^2.4.5"
|
|
109
109
|
},
|
|
110
110
|
"optionalDependencies": {
|
|
111
111
|
"prop-types": "^15.8.1",
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
CloudflareFirewallManager,
|
|
12
12
|
CloudflarePageManager,
|
|
13
13
|
CloudflareRecordManager,
|
|
14
|
+
CloudflareRuleSetManager,
|
|
14
15
|
CloudflareWorkerManager,
|
|
15
16
|
CloudflareZoneManager,
|
|
16
17
|
} from '../services'
|
|
@@ -28,6 +29,7 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
28
29
|
firewallManager: CloudflareFirewallManager
|
|
29
30
|
pageManager: CloudflarePageManager
|
|
30
31
|
recordManager: CloudflareRecordManager
|
|
32
|
+
ruleSetManager: CloudflareRuleSetManager
|
|
31
33
|
workerManager: CloudflareWorkerManager
|
|
32
34
|
zoneManager: CloudflareZoneManager
|
|
33
35
|
awsProvider: AwsProvider
|
|
@@ -45,6 +47,7 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
45
47
|
this.firewallManager = new CloudflareFirewallManager()
|
|
46
48
|
this.pageManager = new CloudflarePageManager()
|
|
47
49
|
this.recordManager = new CloudflareRecordManager()
|
|
50
|
+
this.ruleSetManager = new CloudflareRuleSetManager()
|
|
48
51
|
this.workerManager = new CloudflareWorkerManager()
|
|
49
52
|
this.zoneManager = new CloudflareZoneManager()
|
|
50
53
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Filter } from '@cdktf/provider-cloudflare/lib/filter'
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
3
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
4
|
+
import { RulesetProps } from './types'
|
|
5
|
+
import { Ruleset } from '@cdktf/provider-cloudflare/lib/ruleset'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @classdesc Provides operations on Cloudflare Rule Sets
|
|
9
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
10
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
14
|
+
*
|
|
15
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
16
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
17
|
+
* super(parent, id, props)
|
|
18
|
+
* this.props = props
|
|
19
|
+
* this.ruleSetManager.createRuleSet('MyRule', this, props)
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class CloudflareRuleSetManager {
|
|
25
|
+
/**
|
|
26
|
+
* @summary Method to create a new Cloudflare Rule Set
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props rule set properties
|
|
30
|
+
* @see [CDKTF Ruleset Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/ruleset.typescript.md}
|
|
31
|
+
*/
|
|
32
|
+
public createRuleSet(id: string, scope: CommonCloudflareConstruct, props: RulesetProps) {
|
|
33
|
+
if (!props) throw `Props undefined for ${id}`
|
|
34
|
+
|
|
35
|
+
const zoneId = props.zoneId
|
|
36
|
+
? props.zoneId
|
|
37
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
38
|
+
|
|
39
|
+
const ruleSet = new Ruleset(scope, `${id}`, {
|
|
40
|
+
...props,
|
|
41
|
+
zoneId,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
createCloudflareTfOutput(`${id}-ruleSetFriendlyUniqueId`, scope, ruleSet.friendlyUniqueId)
|
|
45
|
+
createCloudflareTfOutput(`${id}-ruleSetId`, scope, ruleSet.id)
|
|
46
|
+
|
|
47
|
+
return ruleSet
|
|
48
|
+
}
|
|
49
|
+
}
|