@gradientedge/cdk-utils 8.139.0 → 8.140.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/dist/src/lib/cloudflare/common/construct.d.ts +3 -1
- package/dist/src/lib/cloudflare/common/construct.js +4 -0
- package/dist/src/lib/cloudflare/services/filter/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/filter/index.js +18 -0
- package/dist/src/lib/cloudflare/services/filter/main.d.ts +30 -0
- package/dist/src/lib/cloudflare/services/filter/main.js +46 -0
- package/dist/src/lib/cloudflare/services/filter/types.d.ts +3 -0
- package/dist/src/lib/cloudflare/services/filter/types.js +2 -0
- package/dist/src/lib/cloudflare/services/firewall/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/firewall/index.js +18 -0
- package/dist/src/lib/cloudflare/services/firewall/main.d.ts +30 -0
- package/dist/src/lib/cloudflare/services/firewall/main.js +46 -0
- package/dist/src/lib/cloudflare/services/firewall/types.d.ts +3 -0
- package/dist/src/lib/cloudflare/services/firewall/types.js +2 -0
- package/dist/src/lib/cloudflare/services/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/index.js +2 -0
- package/package.json +1 -1
- package/src/lib/cloudflare/common/construct.ts +11 -1
- package/src/lib/cloudflare/services/filter/index.ts +2 -0
- package/src/lib/cloudflare/services/filter/main.ts +48 -0
- package/src/lib/cloudflare/services/filter/types.ts +3 -0
- package/src/lib/cloudflare/services/firewall/index.ts +2 -0
- package/src/lib/cloudflare/services/firewall/main.ts +48 -0
- package/src/lib/cloudflare/services/firewall/types.ts +3 -0
- package/src/lib/cloudflare/services/index.ts +2 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { CloudflareApiShieldManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
3
|
+
import { CloudflareApiShieldManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
4
4
|
import { CommonCloudflareStackProps } from './types';
|
|
5
5
|
export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
6
6
|
props: CommonCloudflareStackProps;
|
|
7
7
|
id: string;
|
|
8
8
|
fullyQualifiedDomainName: string;
|
|
9
9
|
apiShieldManager: CloudflareApiShieldManager;
|
|
10
|
+
filterManager: CloudflareFilterManager;
|
|
11
|
+
firewallManager: CloudflareFirewallManager;
|
|
10
12
|
workerManager: CloudflareWorkerManager;
|
|
11
13
|
zoneManager: CloudflareZoneManager;
|
|
12
14
|
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
|
|
@@ -9,6 +9,8 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
9
9
|
id;
|
|
10
10
|
fullyQualifiedDomainName;
|
|
11
11
|
apiShieldManager;
|
|
12
|
+
filterManager;
|
|
13
|
+
firewallManager;
|
|
12
14
|
workerManager;
|
|
13
15
|
zoneManager;
|
|
14
16
|
constructor(scope, id, props) {
|
|
@@ -16,6 +18,8 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
16
18
|
this.props = props;
|
|
17
19
|
this.id = id;
|
|
18
20
|
this.apiShieldManager = new services_1.CloudflareApiShieldManager();
|
|
21
|
+
this.filterManager = new services_1.CloudflareFilterManager();
|
|
22
|
+
this.firewallManager = new services_1.CloudflareFirewallManager();
|
|
19
23
|
this.zoneManager = new services_1.CloudflareZoneManager();
|
|
20
24
|
this.workerManager = new services_1.CloudflareWorkerManager();
|
|
21
25
|
this.determineFullyQualifiedDomain();
|
|
@@ -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 { Filter } from '@cdktf/provider-cloudflare/lib/filter';
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
3
|
+
import { FilterProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Cloudflare Filters
|
|
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.filterManager.createApiShield('MyFilter', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudflareFilterManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new Cloudflare Filter
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props filter properties
|
|
27
|
+
* @see [CDKTF Filter Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/filter.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createApiShield(id: string, scope: CommonCloudflareConstruct, props: FilterProps): Filter;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareFilterManager = void 0;
|
|
4
|
+
const filter_1 = require("@cdktf/provider-cloudflare/lib/filter");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Filters
|
|
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.filterManager.createApiShield('MyFilter', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class CloudflareFilterManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Filter
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props filter properties
|
|
29
|
+
* @see [CDKTF Filter Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/filter.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createApiShield(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 filter = new filter_1.Filter(scope, `${id}`, {
|
|
38
|
+
...props,
|
|
39
|
+
zoneId,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-filterFriendlyUniqueId`, scope, filter.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-filterId`, scope, filter.id);
|
|
43
|
+
return filter;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CloudflareFilterManager = CloudflareFilterManager;
|
|
@@ -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 { FirewallRule } from '@cdktf/provider-cloudflare/lib/firewall-rule';
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
3
|
+
import { FirewallRuleProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Cloudflare Firewall Rules
|
|
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.firewallManager.createApiShield('MyFirewallRule', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudflareFirewallManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new Cloudflare Firewall Rule
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props firewall rule properties
|
|
27
|
+
* @see [CDKTF Firewall Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/firewallRule.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createFirewallRule(id: string, scope: CommonCloudflareConstruct, props: FirewallRuleProps): FirewallRule;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareFirewallManager = void 0;
|
|
4
|
+
const firewall_rule_1 = require("@cdktf/provider-cloudflare/lib/firewall-rule");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Firewall Rules
|
|
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.firewallManager.createApiShield('MyFirewallRule', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class CloudflareFirewallManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Firewall Rule
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props firewall rule properties
|
|
29
|
+
* @see [CDKTF Firewall Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/firewallRule.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createFirewallRule(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 firewallRule = new firewall_rule_1.FirewallRule(scope, `${id}`, {
|
|
38
|
+
...props,
|
|
39
|
+
zoneId,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-firewallRuleFriendlyUniqueId`, scope, firewallRule.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-firewallRuleId`, scope, firewallRule.id);
|
|
43
|
+
return firewallRule;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CloudflareFirewallManager = CloudflareFirewallManager;
|
|
@@ -15,5 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./api-shield"), exports);
|
|
18
|
+
__exportStar(require("./filter"), exports);
|
|
19
|
+
__exportStar(require("./firewall"), exports);
|
|
18
20
|
__exportStar(require("./worker"), exports);
|
|
19
21
|
__exportStar(require("./zone"), exports);
|
package/package.json
CHANGED
|
@@ -2,7 +2,13 @@ import { CloudflareProvider } from '@cdktf/provider-cloudflare/lib/provider'
|
|
|
2
2
|
import { TerraformStack } from 'cdktf'
|
|
3
3
|
import { Construct } from 'constructs'
|
|
4
4
|
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
CloudflareApiShieldManager,
|
|
7
|
+
CloudflareFilterManager,
|
|
8
|
+
CloudflareFirewallManager,
|
|
9
|
+
CloudflareWorkerManager,
|
|
10
|
+
CloudflareZoneManager,
|
|
11
|
+
} from '../services'
|
|
6
12
|
import { CommonCloudflareStackProps } from './types'
|
|
7
13
|
|
|
8
14
|
export class CommonCloudflareConstruct extends TerraformStack {
|
|
@@ -10,6 +16,8 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
10
16
|
id: string
|
|
11
17
|
fullyQualifiedDomainName: string
|
|
12
18
|
apiShieldManager: CloudflareApiShieldManager
|
|
19
|
+
filterManager: CloudflareFilterManager
|
|
20
|
+
firewallManager: CloudflareFirewallManager
|
|
13
21
|
workerManager: CloudflareWorkerManager
|
|
14
22
|
zoneManager: CloudflareZoneManager
|
|
15
23
|
|
|
@@ -19,6 +27,8 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
19
27
|
this.id = id
|
|
20
28
|
|
|
21
29
|
this.apiShieldManager = new CloudflareApiShieldManager()
|
|
30
|
+
this.filterManager = new CloudflareFilterManager()
|
|
31
|
+
this.firewallManager = new CloudflareFirewallManager()
|
|
22
32
|
this.zoneManager = new CloudflareZoneManager()
|
|
23
33
|
this.workerManager = new CloudflareWorkerManager()
|
|
24
34
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Filter } from '@cdktf/provider-cloudflare/lib/filter'
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
3
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
4
|
+
import { FilterProps } from './types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Filters
|
|
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.filterManager.createApiShield('MyFilter', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class CloudflareFilterManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Filter
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props filter properties
|
|
29
|
+
* @see [CDKTF Filter Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/filter.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
public createApiShield(id: string, scope: CommonCloudflareConstruct, props: FilterProps) {
|
|
32
|
+
if (!props) throw `Props undefined for ${id}`
|
|
33
|
+
|
|
34
|
+
const zoneId = props.zoneId
|
|
35
|
+
? props.zoneId
|
|
36
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
37
|
+
|
|
38
|
+
const filter = new Filter(scope, `${id}`, {
|
|
39
|
+
...props,
|
|
40
|
+
zoneId,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
createCloudflareTfOutput(`${id}-filterFriendlyUniqueId`, scope, filter.friendlyUniqueId)
|
|
44
|
+
createCloudflareTfOutput(`${id}-filterId`, scope, filter.id)
|
|
45
|
+
|
|
46
|
+
return filter
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FirewallRule } from '@cdktf/provider-cloudflare/lib/firewall-rule'
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
3
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
4
|
+
import { FirewallRuleProps } from './types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Firewall Rules
|
|
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.firewallManager.createApiShield('MyFirewallRule', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class CloudflareFirewallManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Firewall Rule
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props firewall rule properties
|
|
29
|
+
* @see [CDKTF Firewall Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/firewallRule.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
public createFirewallRule(id: string, scope: CommonCloudflareConstruct, props: FirewallRuleProps) {
|
|
32
|
+
if (!props) throw `Props undefined for ${id}`
|
|
33
|
+
|
|
34
|
+
const zoneId = props.zoneId
|
|
35
|
+
? props.zoneId
|
|
36
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
37
|
+
|
|
38
|
+
const firewallRule = new FirewallRule(scope, `${id}`, {
|
|
39
|
+
...props,
|
|
40
|
+
zoneId,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
createCloudflareTfOutput(`${id}-firewallRuleFriendlyUniqueId`, scope, firewallRule.friendlyUniqueId)
|
|
44
|
+
createCloudflareTfOutput(`${id}-firewallRuleId`, scope, firewallRule.id)
|
|
45
|
+
|
|
46
|
+
return firewallRule
|
|
47
|
+
}
|
|
48
|
+
}
|