@gradientedge/cdk-utils 8.142.0 → 8.144.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 +5 -1
- package/dist/src/lib/cloudflare/services/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/index.js +2 -0
- package/dist/src/lib/cloudflare/services/page/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/page/index.js +18 -0
- package/dist/src/lib/cloudflare/services/page/main.d.ts +48 -0
- package/dist/src/lib/cloudflare/services/page/main.js +86 -0
- package/dist/src/lib/cloudflare/services/page/types.d.ts +9 -0
- package/dist/src/lib/cloudflare/services/page/types.js +2 -0
- package/dist/src/lib/cloudflare/services/record/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/record/index.js +18 -0
- package/dist/src/lib/cloudflare/services/record/main.d.ts +30 -0
- package/dist/src/lib/cloudflare/services/record/main.js +46 -0
- package/dist/src/lib/cloudflare/services/record/types.d.ts +3 -0
- package/dist/src/lib/cloudflare/services/record/types.js +2 -0
- package/package.json +1 -1
- package/src/lib/cloudflare/common/construct.ts +7 -1
- package/src/lib/cloudflare/services/index.ts +2 -0
- package/src/lib/cloudflare/services/page/index.ts +2 -0
- package/src/lib/cloudflare/services/page/main.ts +94 -0
- package/src/lib/cloudflare/services/page/types.ts +7 -0
- package/src/lib/cloudflare/services/record/index.ts +2 -0
- package/src/lib/cloudflare/services/record/main.ts +48 -0
- package/src/lib/cloudflare/services/record/types.ts +3 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
3
|
+
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareRecordManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
4
4
|
import { CommonCloudflareStackProps } from './types';
|
|
5
5
|
export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
6
6
|
props: CommonCloudflareStackProps;
|
|
@@ -11,6 +11,8 @@ export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
|
11
11
|
argoManager: CloudflareArgoManager;
|
|
12
12
|
filterManager: CloudflareFilterManager;
|
|
13
13
|
firewallManager: CloudflareFirewallManager;
|
|
14
|
+
pageManager: CloudflarePageManager;
|
|
15
|
+
recordManager: CloudflareRecordManager;
|
|
14
16
|
workerManager: CloudflareWorkerManager;
|
|
15
17
|
zoneManager: CloudflareZoneManager;
|
|
16
18
|
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
|
|
@@ -13,6 +13,8 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
13
13
|
argoManager;
|
|
14
14
|
filterManager;
|
|
15
15
|
firewallManager;
|
|
16
|
+
pageManager;
|
|
17
|
+
recordManager;
|
|
16
18
|
workerManager;
|
|
17
19
|
zoneManager;
|
|
18
20
|
constructor(scope, id, props) {
|
|
@@ -24,8 +26,10 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
24
26
|
this.argoManager = new services_1.CloudflareArgoManager();
|
|
25
27
|
this.filterManager = new services_1.CloudflareFilterManager();
|
|
26
28
|
this.firewallManager = new services_1.CloudflareFirewallManager();
|
|
27
|
-
this.
|
|
29
|
+
this.pageManager = new services_1.CloudflarePageManager();
|
|
30
|
+
this.recordManager = new services_1.CloudflareRecordManager();
|
|
28
31
|
this.workerManager = new services_1.CloudflareWorkerManager();
|
|
32
|
+
this.zoneManager = new services_1.CloudflareZoneManager();
|
|
29
33
|
this.determineFullyQualifiedDomain();
|
|
30
34
|
new provider_1.CloudflareProvider(this, `${this.id}-provider`, this.props);
|
|
31
35
|
}
|
|
@@ -19,5 +19,7 @@ __exportStar(require("./api-shield"), exports);
|
|
|
19
19
|
__exportStar(require("./argo"), exports);
|
|
20
20
|
__exportStar(require("./filter"), exports);
|
|
21
21
|
__exportStar(require("./firewall"), exports);
|
|
22
|
+
__exportStar(require("./page"), exports);
|
|
23
|
+
__exportStar(require("./record"), exports);
|
|
22
24
|
__exportStar(require("./worker"), exports);
|
|
23
25
|
__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,48 @@
|
|
|
1
|
+
import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain';
|
|
2
|
+
import { PagesProject } from '@cdktf/provider-cloudflare/lib/pages-project';
|
|
3
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
4
|
+
import { PageRuleProps, PagesDomainProps, PagesProjectProps } from './types';
|
|
5
|
+
import { PageRule } from '@cdktf/provider-cloudflare/lib/page-rule';
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Pages
|
|
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.pageManager.createPagesProject('MyPage', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class CloudflarePageManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Pages Project
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props pages project properties
|
|
29
|
+
* @see [CDKTF Pages Project Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesProject.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createPagesProject(id: string, scope: CommonCloudflareConstruct, props: PagesProjectProps): PagesProject;
|
|
32
|
+
/**
|
|
33
|
+
* @summary Method to create a new Cloudflare Pages Domain
|
|
34
|
+
* @param id scoped id of the resource
|
|
35
|
+
* @param scope scope in which this resource is defined
|
|
36
|
+
* @param props pages domain properties
|
|
37
|
+
* @see [CDKTF Pages Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesDomain.typescript.md}
|
|
38
|
+
*/
|
|
39
|
+
createPagesDomain(id: string, scope: CommonCloudflareConstruct, props: PagesDomainProps): PagesDomain;
|
|
40
|
+
/**
|
|
41
|
+
* @summary Method to create a new Cloudflare Page Rule
|
|
42
|
+
* @param id scoped id of the resource
|
|
43
|
+
* @param scope scope in which this resource is defined
|
|
44
|
+
* @param props page rule properties
|
|
45
|
+
* @see [CDKTF Page Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pageRule.typescript.md}
|
|
46
|
+
*/
|
|
47
|
+
createPageRule(id: string, scope: CommonCloudflareConstruct, props: PageRuleProps): PageRule;
|
|
48
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflarePageManager = void 0;
|
|
4
|
+
const pages_domain_1 = require("@cdktf/provider-cloudflare/lib/pages-domain");
|
|
5
|
+
const pages_project_1 = require("@cdktf/provider-cloudflare/lib/pages-project");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const page_rule_1 = require("@cdktf/provider-cloudflare/lib/page-rule");
|
|
8
|
+
/**
|
|
9
|
+
* @classdesc Provides operations on Cloudflare Pages
|
|
10
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
11
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
15
|
+
*
|
|
16
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
17
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
18
|
+
* super(parent, id, props)
|
|
19
|
+
* this.props = props
|
|
20
|
+
* this.pageManager.createPagesProject('MyPage', this, props)
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class CloudflarePageManager {
|
|
26
|
+
/**
|
|
27
|
+
* @summary Method to create a new Cloudflare Pages Project
|
|
28
|
+
* @param id scoped id of the resource
|
|
29
|
+
* @param scope scope in which this resource is defined
|
|
30
|
+
* @param props pages project properties
|
|
31
|
+
* @see [CDKTF Pages Project Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesProject.typescript.md}
|
|
32
|
+
*/
|
|
33
|
+
createPagesProject(id, scope, props) {
|
|
34
|
+
if (!props)
|
|
35
|
+
throw `Props undefined for ${id}`;
|
|
36
|
+
const pagesProject = new pages_project_1.PagesProject(scope, `${id}`, {
|
|
37
|
+
...props,
|
|
38
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
39
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pagesProjectFriendlyUniqueId`, scope, pagesProject.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pagesProjectId`, scope, pagesProject.id);
|
|
43
|
+
return pagesProject;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @summary Method to create a new Cloudflare Pages Domain
|
|
47
|
+
* @param id scoped id of the resource
|
|
48
|
+
* @param scope scope in which this resource is defined
|
|
49
|
+
* @param props pages domain properties
|
|
50
|
+
* @see [CDKTF Pages Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesDomain.typescript.md}
|
|
51
|
+
*/
|
|
52
|
+
createPagesDomain(id, scope, props) {
|
|
53
|
+
if (!props)
|
|
54
|
+
throw `Props undefined for ${id}`;
|
|
55
|
+
const pagesDomain = new pages_domain_1.PagesDomain(scope, `${id}`, {
|
|
56
|
+
...props,
|
|
57
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
58
|
+
domain: props.domain ?? scope.props.domainName,
|
|
59
|
+
});
|
|
60
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pagesDomainFriendlyUniqueId`, scope, pagesDomain.friendlyUniqueId);
|
|
61
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pagesDomainId`, scope, pagesDomain.id);
|
|
62
|
+
return pagesDomain;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* @summary Method to create a new Cloudflare Page Rule
|
|
66
|
+
* @param id scoped id of the resource
|
|
67
|
+
* @param scope scope in which this resource is defined
|
|
68
|
+
* @param props page rule properties
|
|
69
|
+
* @see [CDKTF Page Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pageRule.typescript.md}
|
|
70
|
+
*/
|
|
71
|
+
createPageRule(id, scope, props) {
|
|
72
|
+
if (!props)
|
|
73
|
+
throw `Props undefined for ${id}`;
|
|
74
|
+
const zoneId = props.zoneId
|
|
75
|
+
? props.zoneId
|
|
76
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
77
|
+
const pageRule = new page_rule_1.PageRule(scope, `${id}`, {
|
|
78
|
+
...props,
|
|
79
|
+
zoneId,
|
|
80
|
+
});
|
|
81
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pageRuleFriendlyUniqueId`, scope, pageRule.friendlyUniqueId);
|
|
82
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-pageRuleId`, scope, pageRule.id);
|
|
83
|
+
return pageRule;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.CloudflarePageManager = CloudflarePageManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PageRuleConfig } from '@cdktf/provider-cloudflare/lib/page-rule';
|
|
2
|
+
import { PagesDomainConfig } from '@cdktf/provider-cloudflare/lib/pages-domain';
|
|
3
|
+
import { PagesProjectConfig } from '@cdktf/provider-cloudflare/lib/pages-project';
|
|
4
|
+
export interface PagesProjectProps extends PagesProjectConfig {
|
|
5
|
+
}
|
|
6
|
+
export interface PagesDomainProps extends PagesDomainConfig {
|
|
7
|
+
}
|
|
8
|
+
export interface PageRuleProps extends PageRuleConfig {
|
|
9
|
+
}
|
|
@@ -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 { Record } from '@cdktf/provider-cloudflare/lib/record';
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
3
|
+
import { RecordProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Cloudflare Records
|
|
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.recordManager.createRecord('MyRecord', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudflareRecordManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new Cloudflare Record
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props record properties
|
|
27
|
+
* @see [CDKTF Record Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/record.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createRecord(id: string, scope: CommonCloudflareConstruct, props: RecordProps): Record;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareRecordManager = void 0;
|
|
4
|
+
const record_1 = require("@cdktf/provider-cloudflare/lib/record");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Records
|
|
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.recordManager.createRecord('MyRecord', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class CloudflareRecordManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Record
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props record properties
|
|
29
|
+
* @see [CDKTF Record Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/record.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createRecord(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 record = new record_1.Record(scope, `${id}`, {
|
|
38
|
+
...props,
|
|
39
|
+
zoneId,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-recordFriendlyUniqueId`, scope, record.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-recordId`, scope, record.id);
|
|
43
|
+
return record;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CloudflareRecordManager = CloudflareRecordManager;
|
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
CloudflareArgoManager,
|
|
9
9
|
CloudflareFilterManager,
|
|
10
10
|
CloudflareFirewallManager,
|
|
11
|
+
CloudflarePageManager,
|
|
12
|
+
CloudflareRecordManager,
|
|
11
13
|
CloudflareWorkerManager,
|
|
12
14
|
CloudflareZoneManager,
|
|
13
15
|
} from '../services'
|
|
@@ -22,6 +24,8 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
22
24
|
argoManager: CloudflareArgoManager
|
|
23
25
|
filterManager: CloudflareFilterManager
|
|
24
26
|
firewallManager: CloudflareFirewallManager
|
|
27
|
+
pageManager: CloudflarePageManager
|
|
28
|
+
recordManager: CloudflareRecordManager
|
|
25
29
|
workerManager: CloudflareWorkerManager
|
|
26
30
|
zoneManager: CloudflareZoneManager
|
|
27
31
|
|
|
@@ -35,8 +39,10 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
35
39
|
this.argoManager = new CloudflareArgoManager()
|
|
36
40
|
this.filterManager = new CloudflareFilterManager()
|
|
37
41
|
this.firewallManager = new CloudflareFirewallManager()
|
|
38
|
-
this.
|
|
42
|
+
this.pageManager = new CloudflarePageManager()
|
|
43
|
+
this.recordManager = new CloudflareRecordManager()
|
|
39
44
|
this.workerManager = new CloudflareWorkerManager()
|
|
45
|
+
this.zoneManager = new CloudflareZoneManager()
|
|
40
46
|
|
|
41
47
|
this.determineFullyQualifiedDomain()
|
|
42
48
|
new CloudflareProvider(this, `${this.id}-provider`, this.props)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain'
|
|
2
|
+
import { PagesProject } from '@cdktf/provider-cloudflare/lib/pages-project'
|
|
3
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
4
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
5
|
+
import { PageRuleProps, PagesDomainProps, PagesProjectProps } from './types'
|
|
6
|
+
import { PageRule } from '@cdktf/provider-cloudflare/lib/page-rule'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @classdesc Provides operations on Cloudflare Pages
|
|
10
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
11
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
15
|
+
*
|
|
16
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
17
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
18
|
+
* super(parent, id, props)
|
|
19
|
+
* this.props = props
|
|
20
|
+
* this.pageManager.createPagesProject('MyPage', this, props)
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export class CloudflarePageManager {
|
|
26
|
+
/**
|
|
27
|
+
* @summary Method to create a new Cloudflare Pages Project
|
|
28
|
+
* @param id scoped id of the resource
|
|
29
|
+
* @param scope scope in which this resource is defined
|
|
30
|
+
* @param props pages project properties
|
|
31
|
+
* @see [CDKTF Pages Project Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesProject.typescript.md}
|
|
32
|
+
*/
|
|
33
|
+
public createPagesProject(id: string, scope: CommonCloudflareConstruct, props: PagesProjectProps) {
|
|
34
|
+
if (!props) throw `Props undefined for ${id}`
|
|
35
|
+
|
|
36
|
+
const pagesProject = new PagesProject(scope, `${id}`, {
|
|
37
|
+
...props,
|
|
38
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
39
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
createCloudflareTfOutput(`${id}-pagesProjectFriendlyUniqueId`, scope, pagesProject.friendlyUniqueId)
|
|
43
|
+
createCloudflareTfOutput(`${id}-pagesProjectId`, scope, pagesProject.id)
|
|
44
|
+
|
|
45
|
+
return pagesProject
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @summary Method to create a new Cloudflare Pages Domain
|
|
50
|
+
* @param id scoped id of the resource
|
|
51
|
+
* @param scope scope in which this resource is defined
|
|
52
|
+
* @param props pages domain properties
|
|
53
|
+
* @see [CDKTF Pages Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pagesDomain.typescript.md}
|
|
54
|
+
*/
|
|
55
|
+
public createPagesDomain(id: string, scope: CommonCloudflareConstruct, props: PagesDomainProps) {
|
|
56
|
+
if (!props) throw `Props undefined for ${id}`
|
|
57
|
+
|
|
58
|
+
const pagesDomain = new PagesDomain(scope, `${id}`, {
|
|
59
|
+
...props,
|
|
60
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
61
|
+
domain: props.domain ?? scope.props.domainName,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
createCloudflareTfOutput(`${id}-pagesDomainFriendlyUniqueId`, scope, pagesDomain.friendlyUniqueId)
|
|
65
|
+
createCloudflareTfOutput(`${id}-pagesDomainId`, scope, pagesDomain.id)
|
|
66
|
+
|
|
67
|
+
return pagesDomain
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @summary Method to create a new Cloudflare Page Rule
|
|
72
|
+
* @param id scoped id of the resource
|
|
73
|
+
* @param scope scope in which this resource is defined
|
|
74
|
+
* @param props page rule properties
|
|
75
|
+
* @see [CDKTF Page Rule Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/pageRule.typescript.md}
|
|
76
|
+
*/
|
|
77
|
+
public createPageRule(id: string, scope: CommonCloudflareConstruct, props: PageRuleProps) {
|
|
78
|
+
if (!props) throw `Props undefined for ${id}`
|
|
79
|
+
|
|
80
|
+
const zoneId = props.zoneId
|
|
81
|
+
? props.zoneId
|
|
82
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
83
|
+
|
|
84
|
+
const pageRule = new PageRule(scope, `${id}`, {
|
|
85
|
+
...props,
|
|
86
|
+
zoneId,
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
createCloudflareTfOutput(`${id}-pageRuleFriendlyUniqueId`, scope, pageRule.friendlyUniqueId)
|
|
90
|
+
createCloudflareTfOutput(`${id}-pageRuleId`, scope, pageRule.id)
|
|
91
|
+
|
|
92
|
+
return pageRule
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PageRuleConfig } from '@cdktf/provider-cloudflare/lib/page-rule'
|
|
2
|
+
import { PagesDomainConfig } from '@cdktf/provider-cloudflare/lib/pages-domain'
|
|
3
|
+
import { PagesProjectConfig } from '@cdktf/provider-cloudflare/lib/pages-project'
|
|
4
|
+
|
|
5
|
+
export interface PagesProjectProps extends PagesProjectConfig {}
|
|
6
|
+
export interface PagesDomainProps extends PagesDomainConfig {}
|
|
7
|
+
export interface PageRuleProps extends PageRuleConfig {}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Record } from '@cdktf/provider-cloudflare/lib/record'
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
3
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
4
|
+
import { RecordProps } from './types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Records
|
|
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.recordManager.createRecord('MyRecord', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class CloudflareRecordManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Record
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props record properties
|
|
29
|
+
* @see [CDKTF Record Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/record.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
public createRecord(id: string, scope: CommonCloudflareConstruct, props: RecordProps) {
|
|
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 record = new Record(scope, `${id}`, {
|
|
39
|
+
...props,
|
|
40
|
+
zoneId,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
createCloudflareTfOutput(`${id}-recordFriendlyUniqueId`, scope, record.friendlyUniqueId)
|
|
44
|
+
createCloudflareTfOutput(`${id}-recordId`, scope, record.id)
|
|
45
|
+
|
|
46
|
+
return record
|
|
47
|
+
}
|
|
48
|
+
}
|