@gradientedge/cdk-utils 9.2.0 → 9.3.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 +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/package.json +1 -1
- 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
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|