@gradientedge/cdk-utils 8.141.0 → 8.143.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/argo/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/argo/index.js +18 -0
- package/dist/src/lib/cloudflare/services/argo/main.d.ts +30 -0
- package/dist/src/lib/cloudflare/services/argo/main.js +46 -0
- package/dist/src/lib/cloudflare/services/argo/types.d.ts +3 -0
- package/dist/src/lib/cloudflare/services/argo/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/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/package.json +1 -1
- package/src/lib/cloudflare/common/construct.ts +7 -1
- package/src/lib/cloudflare/services/argo/index.ts +2 -0
- package/src/lib/cloudflare/services/argo/main.ts +48 -0
- package/src/lib/cloudflare/services/argo/types.ts +3 -0
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
3
|
+
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services';
|
|
4
4
|
import { CommonCloudflareStackProps } from './types';
|
|
5
5
|
export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
6
6
|
props: CommonCloudflareStackProps;
|
|
@@ -8,8 +8,10 @@ export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
|
8
8
|
fullyQualifiedDomainName: string;
|
|
9
9
|
accessManager: CloudflareAccessManager;
|
|
10
10
|
apiShieldManager: CloudflareApiShieldManager;
|
|
11
|
+
argoManager: CloudflareArgoManager;
|
|
11
12
|
filterManager: CloudflareFilterManager;
|
|
12
13
|
firewallManager: CloudflareFirewallManager;
|
|
14
|
+
pageManager: CloudflarePageManager;
|
|
13
15
|
workerManager: CloudflareWorkerManager;
|
|
14
16
|
zoneManager: CloudflareZoneManager;
|
|
15
17
|
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
|
|
@@ -10,8 +10,10 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
10
10
|
fullyQualifiedDomainName;
|
|
11
11
|
accessManager;
|
|
12
12
|
apiShieldManager;
|
|
13
|
+
argoManager;
|
|
13
14
|
filterManager;
|
|
14
15
|
firewallManager;
|
|
16
|
+
pageManager;
|
|
15
17
|
workerManager;
|
|
16
18
|
zoneManager;
|
|
17
19
|
constructor(scope, id, props) {
|
|
@@ -20,10 +22,12 @@ class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
|
20
22
|
this.id = id;
|
|
21
23
|
this.accessManager = new services_1.CloudflareAccessManager();
|
|
22
24
|
this.apiShieldManager = new services_1.CloudflareApiShieldManager();
|
|
25
|
+
this.argoManager = new services_1.CloudflareArgoManager();
|
|
23
26
|
this.filterManager = new services_1.CloudflareFilterManager();
|
|
24
27
|
this.firewallManager = new services_1.CloudflareFirewallManager();
|
|
25
|
-
this.
|
|
28
|
+
this.pageManager = new services_1.CloudflarePageManager();
|
|
26
29
|
this.workerManager = new services_1.CloudflareWorkerManager();
|
|
30
|
+
this.zoneManager = new services_1.CloudflareZoneManager();
|
|
27
31
|
this.determineFullyQualifiedDomain();
|
|
28
32
|
new provider_1.CloudflareProvider(this, `${this.id}-provider`, this.props);
|
|
29
33
|
}
|
|
@@ -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 { Argo } from '@cdktf/provider-cloudflare/lib/argo';
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
3
|
+
import { ArgoProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Cloudflare Argo
|
|
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.argoManager.createArgo('MyArgo', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class CloudflareArgoManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new Cloudflare Argo
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props argo properties
|
|
27
|
+
* @see [CDKTF Argo Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/argo.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createArgo(id: string, scope: CommonCloudflareConstruct, props: ArgoProps): Argo;
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareArgoManager = void 0;
|
|
4
|
+
const argo_1 = require("@cdktf/provider-cloudflare/lib/argo");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Argo
|
|
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.argoManager.createArgo('MyArgo', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class CloudflareArgoManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Argo
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props argo properties
|
|
29
|
+
* @see [CDKTF Argo Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/argo.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
createArgo(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 argo = new argo_1.Argo(scope, `${id}`, {
|
|
38
|
+
...props,
|
|
39
|
+
zoneId,
|
|
40
|
+
});
|
|
41
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-argoFriendlyUniqueId`, scope, argo.friendlyUniqueId);
|
|
42
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-argoId`, scope, argo.id);
|
|
43
|
+
return argo;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CloudflareArgoManager = CloudflareArgoManager;
|
|
@@ -16,7 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./access"), exports);
|
|
18
18
|
__exportStar(require("./api-shield"), exports);
|
|
19
|
+
__exportStar(require("./argo"), exports);
|
|
19
20
|
__exportStar(require("./filter"), exports);
|
|
20
21
|
__exportStar(require("./firewall"), exports);
|
|
22
|
+
__exportStar(require("./page"), exports);
|
|
21
23
|
__exportStar(require("./worker"), exports);
|
|
22
24
|
__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
|
+
}
|
package/package.json
CHANGED
|
@@ -5,8 +5,10 @@ import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common'
|
|
|
5
5
|
import {
|
|
6
6
|
CloudflareAccessManager,
|
|
7
7
|
CloudflareApiShieldManager,
|
|
8
|
+
CloudflareArgoManager,
|
|
8
9
|
CloudflareFilterManager,
|
|
9
10
|
CloudflareFirewallManager,
|
|
11
|
+
CloudflarePageManager,
|
|
10
12
|
CloudflareWorkerManager,
|
|
11
13
|
CloudflareZoneManager,
|
|
12
14
|
} from '../services'
|
|
@@ -18,8 +20,10 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
18
20
|
fullyQualifiedDomainName: string
|
|
19
21
|
accessManager: CloudflareAccessManager
|
|
20
22
|
apiShieldManager: CloudflareApiShieldManager
|
|
23
|
+
argoManager: CloudflareArgoManager
|
|
21
24
|
filterManager: CloudflareFilterManager
|
|
22
25
|
firewallManager: CloudflareFirewallManager
|
|
26
|
+
pageManager: CloudflarePageManager
|
|
23
27
|
workerManager: CloudflareWorkerManager
|
|
24
28
|
zoneManager: CloudflareZoneManager
|
|
25
29
|
|
|
@@ -30,10 +34,12 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
30
34
|
|
|
31
35
|
this.accessManager = new CloudflareAccessManager()
|
|
32
36
|
this.apiShieldManager = new CloudflareApiShieldManager()
|
|
37
|
+
this.argoManager = new CloudflareArgoManager()
|
|
33
38
|
this.filterManager = new CloudflareFilterManager()
|
|
34
39
|
this.firewallManager = new CloudflareFirewallManager()
|
|
35
|
-
this.
|
|
40
|
+
this.pageManager = new CloudflarePageManager()
|
|
36
41
|
this.workerManager = new CloudflareWorkerManager()
|
|
42
|
+
this.zoneManager = new CloudflareZoneManager()
|
|
37
43
|
|
|
38
44
|
this.determineFullyQualifiedDomain()
|
|
39
45
|
new CloudflareProvider(this, `${this.id}-provider`, this.props)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Argo } from '@cdktf/provider-cloudflare/lib/argo'
|
|
2
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
3
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
4
|
+
import { ArgoProps } from './types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @classdesc Provides operations on Cloudflare Argo
|
|
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.argoManager.createArgo('MyArgo', this, props)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class CloudflareArgoManager {
|
|
24
|
+
/**
|
|
25
|
+
* @summary Method to create a new Cloudflare Argo
|
|
26
|
+
* @param id scoped id of the resource
|
|
27
|
+
* @param scope scope in which this resource is defined
|
|
28
|
+
* @param props argo properties
|
|
29
|
+
* @see [CDKTF Argo Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/argo.typescript.md}
|
|
30
|
+
*/
|
|
31
|
+
public createArgo(id: string, scope: CommonCloudflareConstruct, props: ArgoProps) {
|
|
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 argo = new Argo(scope, `${id}`, {
|
|
39
|
+
...props,
|
|
40
|
+
zoneId,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
createCloudflareTfOutput(`${id}-argoFriendlyUniqueId`, scope, argo.friendlyUniqueId)
|
|
44
|
+
createCloudflareTfOutput(`${id}-argoId`, scope, argo.id)
|
|
45
|
+
|
|
46
|
+
return argo
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -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 {}
|