@gradientedge/cdk-utils 8.137.0 → 8.139.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/api-shield/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/api-shield/index.js +18 -0
- package/dist/src/lib/cloudflare/services/api-shield/main.d.ts +66 -0
- package/dist/src/lib/cloudflare/services/api-shield/main.js +135 -0
- package/dist/src/lib/cloudflare/services/api-shield/types.d.ts +15 -0
- package/dist/src/lib/cloudflare/services/api-shield/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/worker/index.d.ts +2 -0
- package/dist/src/lib/cloudflare/services/worker/index.js +18 -0
- package/dist/src/lib/cloudflare/services/worker/main.d.ts +75 -0
- package/dist/src/lib/cloudflare/services/worker/main.js +148 -0
- package/dist/src/lib/cloudflare/services/worker/types.d.ts +18 -0
- package/dist/src/lib/cloudflare/services/worker/types.js +2 -0
- package/package.json +1 -1
- package/src/lib/cloudflare/common/construct.ts +5 -1
- package/src/lib/cloudflare/services/api-shield/index.ts +2 -0
- package/src/lib/cloudflare/services/api-shield/main.ts +179 -0
- package/src/lib/cloudflare/services/api-shield/types.ts +12 -0
- package/src/lib/cloudflare/services/index.ts +2 -0
- package/src/lib/cloudflare/services/worker/index.ts +2 -0
- package/src/lib/cloudflare/services/worker/main.ts +173 -0
- package/src/lib/cloudflare/services/worker/types.ts +13 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { CloudflareZoneManager } from '../services';
|
|
3
|
+
import { CloudflareApiShieldManager, 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
|
+
apiShieldManager: CloudflareApiShieldManager;
|
|
10
|
+
workerManager: CloudflareWorkerManager;
|
|
9
11
|
zoneManager: CloudflareZoneManager;
|
|
10
12
|
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
|
|
11
13
|
/**
|
|
@@ -8,12 +8,16 @@ const services_1 = require("../services");
|
|
|
8
8
|
class CommonCloudflareConstruct extends cdktf_1.TerraformStack {
|
|
9
9
|
id;
|
|
10
10
|
fullyQualifiedDomainName;
|
|
11
|
+
apiShieldManager;
|
|
12
|
+
workerManager;
|
|
11
13
|
zoneManager;
|
|
12
14
|
constructor(scope, id, props) {
|
|
13
15
|
super(scope, id);
|
|
14
16
|
this.props = props;
|
|
15
17
|
this.id = id;
|
|
18
|
+
this.apiShieldManager = new services_1.CloudflareApiShieldManager();
|
|
16
19
|
this.zoneManager = new services_1.CloudflareZoneManager();
|
|
20
|
+
this.workerManager = new services_1.CloudflareWorkerManager();
|
|
17
21
|
this.determineFullyQualifiedDomain();
|
|
18
22
|
new provider_1.CloudflareProvider(this, `${this.id}-provider`, this.props);
|
|
19
23
|
}
|
|
@@ -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,66 @@
|
|
|
1
|
+
import { ApiShield } from '@cdktf/provider-cloudflare/lib/api-shield';
|
|
2
|
+
import { ApiShieldOperation } from '@cdktf/provider-cloudflare/lib/api-shield-operation';
|
|
3
|
+
import { ApiShieldOperationSchemaValidationSettings } from '@cdktf/provider-cloudflare/lib/api-shield-operation-schema-validation-settings';
|
|
4
|
+
import { ApiShieldSchema } from '@cdktf/provider-cloudflare/lib/api-shield-schema';
|
|
5
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
6
|
+
import { ApiShieldOperationProps, ApiShieldOperationSchemaValidationSettingsProps, ApiShieldProps, ApiShieldSchemaProps, ApiShieldSchemaValidationSettingsProps } from './types';
|
|
7
|
+
import { ApiShieldSchemaValidationSettings } from '@cdktf/provider-cloudflare/lib/api-shield-schema-validation-settings';
|
|
8
|
+
/**
|
|
9
|
+
* @classdesc Provides operations on Cloudflare Api Shield
|
|
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.apiShieldManager.createApiShield('MyApiShield', this, props)
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class CloudflareApiShieldManager {
|
|
26
|
+
/**
|
|
27
|
+
* @summary Method to create a new Cloudflare Api Shield
|
|
28
|
+
* @param id scoped id of the resource
|
|
29
|
+
* @param scope scope in which this resource is defined
|
|
30
|
+
* @param props api shield properties
|
|
31
|
+
* @see [CDKTF API Shield Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShield.typescript.md}
|
|
32
|
+
*/
|
|
33
|
+
createApiShield(id: string, scope: CommonCloudflareConstruct, props: ApiShieldProps): ApiShield;
|
|
34
|
+
/**
|
|
35
|
+
* @summary Method to create a new Cloudflare Api Shield Schema
|
|
36
|
+
* @param id scoped id of the resource
|
|
37
|
+
* @param scope scope in which this resource is defined
|
|
38
|
+
* @param props api shield schema properties
|
|
39
|
+
* @see [CDKTF API Shield Schema Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
40
|
+
*/
|
|
41
|
+
createApiShieldSchema(id: string, scope: CommonCloudflareConstruct, props: ApiShieldSchemaProps): ApiShieldSchema;
|
|
42
|
+
/**
|
|
43
|
+
* @summary Method to create a new Cloudflare Api Shield Schema Validation Settings
|
|
44
|
+
* @param id scoped id of the resource
|
|
45
|
+
* @param scope scope in which this resource is defined
|
|
46
|
+
* @param props api shield schema validation settings properties
|
|
47
|
+
* @see [CDKTF API Shield Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
48
|
+
*/
|
|
49
|
+
createApiShieldSchemaValidationSettings(id: string, scope: CommonCloudflareConstruct, props: ApiShieldSchemaValidationSettingsProps): ApiShieldSchemaValidationSettings;
|
|
50
|
+
/**
|
|
51
|
+
* @summary Method to create a new Cloudflare Api Shield Operation
|
|
52
|
+
* @param id scoped id of the resource
|
|
53
|
+
* @param scope scope in which this resource is defined
|
|
54
|
+
* @param props api shield operation properties
|
|
55
|
+
* @see [CDKTF API Shield Operation Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperation.typescript.md}
|
|
56
|
+
*/
|
|
57
|
+
createApiShieldOperation(id: string, scope: CommonCloudflareConstruct, props: ApiShieldOperationProps): ApiShieldOperation;
|
|
58
|
+
/**
|
|
59
|
+
* @summary Method to create a new Cloudflare Api Shield Operation Schema Validation Settings
|
|
60
|
+
* @param id scoped id of the resource
|
|
61
|
+
* @param scope scope in which this resource is defined
|
|
62
|
+
* @param props api shield operation schema validation settings properties
|
|
63
|
+
* @see [CDKTF API Shield Operation Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperationSchemaValidationSettings.typescript.md}
|
|
64
|
+
*/
|
|
65
|
+
createApiShieldOperationSchemaValidationSettings(id: string, scope: CommonCloudflareConstruct, props: ApiShieldOperationSchemaValidationSettingsProps): ApiShieldOperationSchemaValidationSettings;
|
|
66
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareApiShieldManager = void 0;
|
|
4
|
+
const api_shield_1 = require("@cdktf/provider-cloudflare/lib/api-shield");
|
|
5
|
+
const api_shield_operation_1 = require("@cdktf/provider-cloudflare/lib/api-shield-operation");
|
|
6
|
+
const api_shield_operation_schema_validation_settings_1 = require("@cdktf/provider-cloudflare/lib/api-shield-operation-schema-validation-settings");
|
|
7
|
+
const api_shield_schema_1 = require("@cdktf/provider-cloudflare/lib/api-shield-schema");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
const api_shield_schema_validation_settings_1 = require("@cdktf/provider-cloudflare/lib/api-shield-schema-validation-settings");
|
|
10
|
+
/**
|
|
11
|
+
* @classdesc Provides operations on Cloudflare Api Shield
|
|
12
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
13
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
14
|
+
* @example
|
|
15
|
+
* ```
|
|
16
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
17
|
+
*
|
|
18
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
19
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
20
|
+
* super(parent, id, props)
|
|
21
|
+
* this.props = props
|
|
22
|
+
* this.apiShieldManager.createApiShield('MyApiShield', this, props)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class CloudflareApiShieldManager {
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create a new Cloudflare Api Shield
|
|
30
|
+
* @param id scoped id of the resource
|
|
31
|
+
* @param scope scope in which this resource is defined
|
|
32
|
+
* @param props api shield properties
|
|
33
|
+
* @see [CDKTF API Shield Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShield.typescript.md}
|
|
34
|
+
*/
|
|
35
|
+
createApiShield(id, scope, props) {
|
|
36
|
+
if (!props)
|
|
37
|
+
throw `Props undefined for ${id}`;
|
|
38
|
+
const zoneId = props.zoneId
|
|
39
|
+
? props.zoneId
|
|
40
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
41
|
+
const apiShield = new api_shield_1.ApiShield(scope, `${id}`, {
|
|
42
|
+
...props,
|
|
43
|
+
zoneId,
|
|
44
|
+
});
|
|
45
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldFriendlyUniqueId`, scope, apiShield.friendlyUniqueId);
|
|
46
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldId`, scope, apiShield.id);
|
|
47
|
+
return apiShield;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @summary Method to create a new Cloudflare Api Shield Schema
|
|
51
|
+
* @param id scoped id of the resource
|
|
52
|
+
* @param scope scope in which this resource is defined
|
|
53
|
+
* @param props api shield schema properties
|
|
54
|
+
* @see [CDKTF API Shield Schema Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
55
|
+
*/
|
|
56
|
+
createApiShieldSchema(id, scope, props) {
|
|
57
|
+
if (!props)
|
|
58
|
+
throw `Props undefined for ${id}`;
|
|
59
|
+
const zoneId = props.zoneId
|
|
60
|
+
? props.zoneId
|
|
61
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
62
|
+
const apiShieldSchema = new api_shield_schema_1.ApiShieldSchema(scope, `${id}`, {
|
|
63
|
+
...props,
|
|
64
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
65
|
+
zoneId,
|
|
66
|
+
});
|
|
67
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldSchemaFriendlyUniqueId`, scope, apiShieldSchema.friendlyUniqueId);
|
|
68
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldSchemaId`, scope, apiShieldSchema.id);
|
|
69
|
+
return apiShieldSchema;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @summary Method to create a new Cloudflare Api Shield Schema Validation Settings
|
|
73
|
+
* @param id scoped id of the resource
|
|
74
|
+
* @param scope scope in which this resource is defined
|
|
75
|
+
* @param props api shield schema validation settings properties
|
|
76
|
+
* @see [CDKTF API Shield Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
77
|
+
*/
|
|
78
|
+
createApiShieldSchemaValidationSettings(id, scope, props) {
|
|
79
|
+
if (!props)
|
|
80
|
+
throw `Props undefined for ${id}`;
|
|
81
|
+
const zoneId = props.zoneId
|
|
82
|
+
? props.zoneId
|
|
83
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
84
|
+
const apiShieldSchemaValidationSettings = new api_shield_schema_validation_settings_1.ApiShieldSchemaValidationSettings(scope, `${id}`, {
|
|
85
|
+
...props,
|
|
86
|
+
zoneId,
|
|
87
|
+
});
|
|
88
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldSchemaValidationSettingsFriendlyUniqueId`, scope, apiShieldSchemaValidationSettings.friendlyUniqueId);
|
|
89
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldSchemaValidationSettingsId`, scope, apiShieldSchemaValidationSettings.id);
|
|
90
|
+
return apiShieldSchemaValidationSettings;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @summary Method to create a new Cloudflare Api Shield Operation
|
|
94
|
+
* @param id scoped id of the resource
|
|
95
|
+
* @param scope scope in which this resource is defined
|
|
96
|
+
* @param props api shield operation properties
|
|
97
|
+
* @see [CDKTF API Shield Operation Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperation.typescript.md}
|
|
98
|
+
*/
|
|
99
|
+
createApiShieldOperation(id, scope, props) {
|
|
100
|
+
if (!props)
|
|
101
|
+
throw `Props undefined for ${id}`;
|
|
102
|
+
const zoneId = props.zoneId
|
|
103
|
+
? props.zoneId
|
|
104
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
105
|
+
const apiShieldOperation = new api_shield_operation_1.ApiShieldOperation(scope, `${id}`, {
|
|
106
|
+
...props,
|
|
107
|
+
zoneId,
|
|
108
|
+
});
|
|
109
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldOperationFriendlyUniqueId`, scope, apiShieldOperation.friendlyUniqueId);
|
|
110
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldOperationId`, scope, apiShieldOperation.id);
|
|
111
|
+
return apiShieldOperation;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @summary Method to create a new Cloudflare Api Shield Operation Schema Validation Settings
|
|
115
|
+
* @param id scoped id of the resource
|
|
116
|
+
* @param scope scope in which this resource is defined
|
|
117
|
+
* @param props api shield operation schema validation settings properties
|
|
118
|
+
* @see [CDKTF API Shield Operation Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperationSchemaValidationSettings.typescript.md}
|
|
119
|
+
*/
|
|
120
|
+
createApiShieldOperationSchemaValidationSettings(id, scope, props) {
|
|
121
|
+
if (!props)
|
|
122
|
+
throw `Props undefined for ${id}`;
|
|
123
|
+
const zoneId = props.zoneId
|
|
124
|
+
? props.zoneId
|
|
125
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
126
|
+
const apiShieldOperationSchemaValidationSettings = new api_shield_operation_schema_validation_settings_1.ApiShieldOperationSchemaValidationSettings(scope, `${id}`, {
|
|
127
|
+
...props,
|
|
128
|
+
zoneId,
|
|
129
|
+
});
|
|
130
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldOperationSchemaValidationSettingsFriendlyUniqueId`, scope, apiShieldOperationSchemaValidationSettings.friendlyUniqueId);
|
|
131
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-apiShieldOperationSchemaValidationSettingsId`, scope, apiShieldOperationSchemaValidationSettings.id);
|
|
132
|
+
return apiShieldOperationSchemaValidationSettings;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.CloudflareApiShieldManager = CloudflareApiShieldManager;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiShieldConfig } from '@cdktf/provider-cloudflare/lib/api-shield';
|
|
2
|
+
import { ApiShieldOperationConfig } from '@cdktf/provider-cloudflare/lib/api-shield-operation';
|
|
3
|
+
import { ApiShieldOperationSchemaValidationSettingsConfig } from '@cdktf/provider-cloudflare/lib/api-shield-operation-schema-validation-settings';
|
|
4
|
+
import { ApiShieldSchemaConfig } from '@cdktf/provider-cloudflare/lib/api-shield-schema';
|
|
5
|
+
import { ApiShieldSchemaValidationSettingsConfig } from '@cdktf/provider-cloudflare/lib/api-shield-schema-validation-settings';
|
|
6
|
+
export interface ApiShieldProps extends ApiShieldConfig {
|
|
7
|
+
}
|
|
8
|
+
export interface ApiShieldSchemaProps extends ApiShieldSchemaConfig {
|
|
9
|
+
}
|
|
10
|
+
export interface ApiShieldSchemaValidationSettingsProps extends ApiShieldSchemaValidationSettingsConfig {
|
|
11
|
+
}
|
|
12
|
+
export interface ApiShieldOperationProps extends ApiShieldOperationConfig {
|
|
13
|
+
}
|
|
14
|
+
export interface ApiShieldOperationSchemaValidationSettingsProps extends ApiShieldOperationSchemaValidationSettingsConfig {
|
|
15
|
+
}
|
|
@@ -14,4 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api-shield"), exports);
|
|
18
|
+
__exportStar(require("./worker"), exports);
|
|
17
19
|
__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,75 @@
|
|
|
1
|
+
import { WorkerDomain } from '@cdktf/provider-cloudflare/lib/worker-domain';
|
|
2
|
+
import { WorkerRoute } from '@cdktf/provider-cloudflare/lib/worker-route';
|
|
3
|
+
import { WorkerScript } from '@cdktf/provider-cloudflare/lib/worker-script';
|
|
4
|
+
import { CommonCloudflareConstruct } from '../../common';
|
|
5
|
+
import { WorkerCronTriggerProps, WorkerDomainProps, WorkerRouteProps, WorkerScriptProps, WorkersKvNamespaceProps, WorkersKvProps } from './types';
|
|
6
|
+
import { WorkersKvNamespace } from '@cdktf/provider-cloudflare/lib/workers-kv-namespace';
|
|
7
|
+
import { WorkersKv } from '@cdktf/provider-cloudflare/lib/workers-kv';
|
|
8
|
+
import { WorkerCronTrigger } from '@cdktf/provider-cloudflare/lib/worker-cron-trigger';
|
|
9
|
+
/**
|
|
10
|
+
* @classdesc Provides operations on Cloudflare Worker
|
|
11
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
12
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
16
|
+
*
|
|
17
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
18
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
19
|
+
* super(parent, id, props)
|
|
20
|
+
* this.props = props
|
|
21
|
+
* this.workerManager.createWorkerDomain('MyWorkerDomain', this, props)
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class CloudflareWorkerManager {
|
|
27
|
+
/**
|
|
28
|
+
* @summary Method to create a new Cloudflare Worker Domain
|
|
29
|
+
* @param id scoped id of the resource
|
|
30
|
+
* @param scope scope in which this resource is defined
|
|
31
|
+
* @param props worker domain properties
|
|
32
|
+
* @see [CDKTF Worker Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerDomain.typescript.md}
|
|
33
|
+
*/
|
|
34
|
+
createWorkerDomain(id: string, scope: CommonCloudflareConstruct, props: WorkerDomainProps): WorkerDomain;
|
|
35
|
+
/**
|
|
36
|
+
* @summary Method to create a new Cloudflare Worker Route
|
|
37
|
+
* @param id scoped id of the resource
|
|
38
|
+
* @param scope scope in which this resource is defined
|
|
39
|
+
* @param props worker route properties
|
|
40
|
+
* @see [CDKTF Worker Route Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerRoute.typescript.md}
|
|
41
|
+
*/
|
|
42
|
+
createWorkerRoute(id: string, scope: CommonCloudflareConstruct, props: WorkerRouteProps): WorkerRoute;
|
|
43
|
+
/**
|
|
44
|
+
* @summary Method to create a new Cloudflare Worker Script
|
|
45
|
+
* @param id scoped id of the resource
|
|
46
|
+
* @param scope scope in which this resource is defined
|
|
47
|
+
* @param props worker script properties
|
|
48
|
+
* @see [CDKTF Worker Script Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerScript.typescript.md}
|
|
49
|
+
*/
|
|
50
|
+
createWorkerScript(id: string, scope: CommonCloudflareConstruct, props: WorkerScriptProps): WorkerScript;
|
|
51
|
+
/**
|
|
52
|
+
* @summary Method to create a new Cloudflare Workers KV Namespace
|
|
53
|
+
* @param id scoped id of the resource
|
|
54
|
+
* @param scope scope in which this resource is defined
|
|
55
|
+
* @param props workers kv namespace properties
|
|
56
|
+
* @see [CDKTF Workers KV Namespace Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKvNamespace.typescript.md}
|
|
57
|
+
*/
|
|
58
|
+
createWorkersKvNamespace(id: string, scope: CommonCloudflareConstruct, props: WorkersKvNamespaceProps): WorkersKvNamespace;
|
|
59
|
+
/**
|
|
60
|
+
* @summary Method to create a new Cloudflare Workers KV
|
|
61
|
+
* @param id scoped id of the resource
|
|
62
|
+
* @param scope scope in which this resource is defined
|
|
63
|
+
* @param props workers kv properties
|
|
64
|
+
* @see [CDKTF Workers KV Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKv.typescript.md}
|
|
65
|
+
*/
|
|
66
|
+
createWorkersKv(id: string, scope: CommonCloudflareConstruct, props: WorkersKvProps): WorkersKv;
|
|
67
|
+
/**
|
|
68
|
+
* @summary Method to create a new Cloudflare Worker Cron Trigger
|
|
69
|
+
* @param id scoped id of the resource
|
|
70
|
+
* @param scope scope in which this resource is defined
|
|
71
|
+
* @param props workers cron trigger properties
|
|
72
|
+
* @see [CDKTF Workers Cron Trigger Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerCronTrigger.typescript.md}
|
|
73
|
+
*/
|
|
74
|
+
createWorkerCronTrigger(id: string, scope: CommonCloudflareConstruct, props: WorkerCronTriggerProps): WorkerCronTrigger;
|
|
75
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudflareWorkerManager = void 0;
|
|
4
|
+
const worker_domain_1 = require("@cdktf/provider-cloudflare/lib/worker-domain");
|
|
5
|
+
const worker_route_1 = require("@cdktf/provider-cloudflare/lib/worker-route");
|
|
6
|
+
const worker_script_1 = require("@cdktf/provider-cloudflare/lib/worker-script");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const workers_kv_namespace_1 = require("@cdktf/provider-cloudflare/lib/workers-kv-namespace");
|
|
9
|
+
const workers_kv_1 = require("@cdktf/provider-cloudflare/lib/workers-kv");
|
|
10
|
+
const worker_cron_trigger_1 = require("@cdktf/provider-cloudflare/lib/worker-cron-trigger");
|
|
11
|
+
/**
|
|
12
|
+
* @classdesc Provides operations on Cloudflare Worker
|
|
13
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
14
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
18
|
+
*
|
|
19
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
20
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
21
|
+
* super(parent, id, props)
|
|
22
|
+
* this.props = props
|
|
23
|
+
* this.workerManager.createWorkerDomain('MyWorkerDomain', this, props)
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
class CloudflareWorkerManager {
|
|
29
|
+
/**
|
|
30
|
+
* @summary Method to create a new Cloudflare Worker Domain
|
|
31
|
+
* @param id scoped id of the resource
|
|
32
|
+
* @param scope scope in which this resource is defined
|
|
33
|
+
* @param props worker domain properties
|
|
34
|
+
* @see [CDKTF Worker Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerDomain.typescript.md}
|
|
35
|
+
*/
|
|
36
|
+
createWorkerDomain(id, scope, props) {
|
|
37
|
+
if (!props)
|
|
38
|
+
throw `Props undefined for ${id}`;
|
|
39
|
+
const zoneId = props.zoneId
|
|
40
|
+
? props.zoneId
|
|
41
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
42
|
+
const workerDomain = new worker_domain_1.WorkerDomain(scope, `${id}`, {
|
|
43
|
+
...props,
|
|
44
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
45
|
+
zoneId,
|
|
46
|
+
});
|
|
47
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerDomainFriendlyUniqueId`, scope, workerDomain.friendlyUniqueId);
|
|
48
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerDomainId`, scope, workerDomain.id);
|
|
49
|
+
return workerDomain;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @summary Method to create a new Cloudflare Worker Route
|
|
53
|
+
* @param id scoped id of the resource
|
|
54
|
+
* @param scope scope in which this resource is defined
|
|
55
|
+
* @param props worker route properties
|
|
56
|
+
* @see [CDKTF Worker Route Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerRoute.typescript.md}
|
|
57
|
+
*/
|
|
58
|
+
createWorkerRoute(id, scope, props) {
|
|
59
|
+
if (!props)
|
|
60
|
+
throw `Props undefined for ${id}`;
|
|
61
|
+
const zoneId = props.zoneId
|
|
62
|
+
? props.zoneId
|
|
63
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
|
|
64
|
+
const workerRoute = new worker_route_1.WorkerRoute(scope, `${id}`, {
|
|
65
|
+
...props,
|
|
66
|
+
scriptName: `${props.scriptName}-${scope.props.stage}`,
|
|
67
|
+
zoneId,
|
|
68
|
+
});
|
|
69
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerRouteFriendlyUniqueId`, scope, workerRoute.friendlyUniqueId);
|
|
70
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerRouteId`, scope, workerRoute.id);
|
|
71
|
+
return workerRoute;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @summary Method to create a new Cloudflare Worker Script
|
|
75
|
+
* @param id scoped id of the resource
|
|
76
|
+
* @param scope scope in which this resource is defined
|
|
77
|
+
* @param props worker script properties
|
|
78
|
+
* @see [CDKTF Worker Script Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerScript.typescript.md}
|
|
79
|
+
*/
|
|
80
|
+
createWorkerScript(id, scope, props) {
|
|
81
|
+
if (!props)
|
|
82
|
+
throw `Props undefined for ${id}`;
|
|
83
|
+
const workerScript = new worker_script_1.WorkerScript(scope, `${id}`, {
|
|
84
|
+
...props,
|
|
85
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
86
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
87
|
+
});
|
|
88
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerScriptFriendlyUniqueId`, scope, workerScript.friendlyUniqueId);
|
|
89
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerScriptId`, scope, workerScript.id);
|
|
90
|
+
return workerScript;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @summary Method to create a new Cloudflare Workers KV Namespace
|
|
94
|
+
* @param id scoped id of the resource
|
|
95
|
+
* @param scope scope in which this resource is defined
|
|
96
|
+
* @param props workers kv namespace properties
|
|
97
|
+
* @see [CDKTF Workers KV Namespace Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKvNamespace.typescript.md}
|
|
98
|
+
*/
|
|
99
|
+
createWorkersKvNamespace(id, scope, props) {
|
|
100
|
+
if (!props)
|
|
101
|
+
throw `Props undefined for ${id}`;
|
|
102
|
+
const workersKvNamespace = new workers_kv_namespace_1.WorkersKvNamespace(scope, `${id}`, {
|
|
103
|
+
...props,
|
|
104
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
105
|
+
title: scope.isProductionStage() ? props.title : `${props.title}-${scope.props.stage}`,
|
|
106
|
+
});
|
|
107
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workersKvNamespaceFriendlyUniqueId`, scope, workersKvNamespace.friendlyUniqueId);
|
|
108
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workersKvNamespaceId`, scope, workersKvNamespace.id);
|
|
109
|
+
return workersKvNamespace;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @summary Method to create a new Cloudflare Workers KV
|
|
113
|
+
* @param id scoped id of the resource
|
|
114
|
+
* @param scope scope in which this resource is defined
|
|
115
|
+
* @param props workers kv properties
|
|
116
|
+
* @see [CDKTF Workers KV Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKv.typescript.md}
|
|
117
|
+
*/
|
|
118
|
+
createWorkersKv(id, scope, props) {
|
|
119
|
+
if (!props)
|
|
120
|
+
throw `Props undefined for ${id}`;
|
|
121
|
+
const workersKv = new workers_kv_1.WorkersKv(scope, `${id}`, {
|
|
122
|
+
...props,
|
|
123
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
124
|
+
});
|
|
125
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workersKvFriendlyUniqueId`, scope, workersKv.friendlyUniqueId);
|
|
126
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workersKvId`, scope, workersKv.id);
|
|
127
|
+
return workersKv;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @summary Method to create a new Cloudflare Worker Cron Trigger
|
|
131
|
+
* @param id scoped id of the resource
|
|
132
|
+
* @param scope scope in which this resource is defined
|
|
133
|
+
* @param props workers cron trigger properties
|
|
134
|
+
* @see [CDKTF Workers Cron Trigger Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerCronTrigger.typescript.md}
|
|
135
|
+
*/
|
|
136
|
+
createWorkerCronTrigger(id, scope, props) {
|
|
137
|
+
if (!props)
|
|
138
|
+
throw `Props undefined for ${id}`;
|
|
139
|
+
const workerCronTrigger = new worker_cron_trigger_1.WorkerCronTrigger(scope, `${id}`, {
|
|
140
|
+
...props,
|
|
141
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
142
|
+
});
|
|
143
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerCronTriggerFriendlyUniqueId`, scope, workerCronTrigger.friendlyUniqueId);
|
|
144
|
+
(0, utils_1.createCloudflareTfOutput)(`${id}-workerCronTriggerId`, scope, workerCronTrigger.id);
|
|
145
|
+
return workerCronTrigger;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.CloudflareWorkerManager = CloudflareWorkerManager;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WorkerCronTriggerConfig } from '@cdktf/provider-cloudflare/lib/worker-cron-trigger';
|
|
2
|
+
import { WorkerDomainConfig } from '@cdktf/provider-cloudflare/lib/worker-domain';
|
|
3
|
+
import { WorkerRouteConfig } from '@cdktf/provider-cloudflare/lib/worker-route';
|
|
4
|
+
import { WorkerScriptConfig } from '@cdktf/provider-cloudflare/lib/worker-script';
|
|
5
|
+
import { WorkersKvConfig } from '@cdktf/provider-cloudflare/lib/workers-kv';
|
|
6
|
+
import { WorkersKvNamespaceConfig } from '@cdktf/provider-cloudflare/lib/workers-kv-namespace';
|
|
7
|
+
export interface WorkerDomainProps extends WorkerDomainConfig {
|
|
8
|
+
}
|
|
9
|
+
export interface WorkerRouteProps extends WorkerRouteConfig {
|
|
10
|
+
}
|
|
11
|
+
export interface WorkerScriptProps extends WorkerScriptConfig {
|
|
12
|
+
}
|
|
13
|
+
export interface WorkersKvNamespaceProps extends WorkersKvNamespaceConfig {
|
|
14
|
+
}
|
|
15
|
+
export interface WorkersKvProps extends WorkersKvConfig {
|
|
16
|
+
}
|
|
17
|
+
export interface WorkerCronTriggerProps extends WorkerCronTriggerConfig {
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -2,13 +2,15 @@ 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 { CloudflareZoneManager } from '../services'
|
|
5
|
+
import { CloudflareApiShieldManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services'
|
|
6
6
|
import { CommonCloudflareStackProps } from './types'
|
|
7
7
|
|
|
8
8
|
export class CommonCloudflareConstruct extends TerraformStack {
|
|
9
9
|
declare props: CommonCloudflareStackProps
|
|
10
10
|
id: string
|
|
11
11
|
fullyQualifiedDomainName: string
|
|
12
|
+
apiShieldManager: CloudflareApiShieldManager
|
|
13
|
+
workerManager: CloudflareWorkerManager
|
|
12
14
|
zoneManager: CloudflareZoneManager
|
|
13
15
|
|
|
14
16
|
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
@@ -16,7 +18,9 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
16
18
|
this.props = props
|
|
17
19
|
this.id = id
|
|
18
20
|
|
|
21
|
+
this.apiShieldManager = new CloudflareApiShieldManager()
|
|
19
22
|
this.zoneManager = new CloudflareZoneManager()
|
|
23
|
+
this.workerManager = new CloudflareWorkerManager()
|
|
20
24
|
|
|
21
25
|
this.determineFullyQualifiedDomain()
|
|
22
26
|
new CloudflareProvider(this, `${this.id}-provider`, this.props)
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { ApiShield } from '@cdktf/provider-cloudflare/lib/api-shield'
|
|
2
|
+
import { ApiShieldOperation } from '@cdktf/provider-cloudflare/lib/api-shield-operation'
|
|
3
|
+
import { ApiShieldOperationSchemaValidationSettings } from '@cdktf/provider-cloudflare/lib/api-shield-operation-schema-validation-settings'
|
|
4
|
+
import { ApiShieldSchema } from '@cdktf/provider-cloudflare/lib/api-shield-schema'
|
|
5
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
6
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
7
|
+
import {
|
|
8
|
+
ApiShieldOperationProps,
|
|
9
|
+
ApiShieldOperationSchemaValidationSettingsProps,
|
|
10
|
+
ApiShieldProps,
|
|
11
|
+
ApiShieldSchemaProps,
|
|
12
|
+
ApiShieldSchemaValidationSettingsProps,
|
|
13
|
+
} from './types'
|
|
14
|
+
import { ApiShieldSchemaValidationSettings } from '@cdktf/provider-cloudflare/lib/api-shield-schema-validation-settings'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @classdesc Provides operations on Cloudflare Api Shield
|
|
18
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
19
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
20
|
+
* @example
|
|
21
|
+
* ```
|
|
22
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
23
|
+
*
|
|
24
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
25
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
26
|
+
* super(parent, id, props)
|
|
27
|
+
* this.props = props
|
|
28
|
+
* this.apiShieldManager.createApiShield('MyApiShield', this, props)
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class CloudflareApiShieldManager {
|
|
34
|
+
/**
|
|
35
|
+
* @summary Method to create a new Cloudflare Api Shield
|
|
36
|
+
* @param id scoped id of the resource
|
|
37
|
+
* @param scope scope in which this resource is defined
|
|
38
|
+
* @param props api shield properties
|
|
39
|
+
* @see [CDKTF API Shield Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShield.typescript.md}
|
|
40
|
+
*/
|
|
41
|
+
public createApiShield(id: string, scope: CommonCloudflareConstruct, props: ApiShieldProps) {
|
|
42
|
+
if (!props) throw `Props undefined for ${id}`
|
|
43
|
+
|
|
44
|
+
const zoneId = props.zoneId
|
|
45
|
+
? props.zoneId
|
|
46
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
47
|
+
|
|
48
|
+
const apiShield = new ApiShield(scope, `${id}`, {
|
|
49
|
+
...props,
|
|
50
|
+
zoneId,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
createCloudflareTfOutput(`${id}-apiShieldFriendlyUniqueId`, scope, apiShield.friendlyUniqueId)
|
|
54
|
+
createCloudflareTfOutput(`${id}-apiShieldId`, scope, apiShield.id)
|
|
55
|
+
|
|
56
|
+
return apiShield
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @summary Method to create a new Cloudflare Api Shield Schema
|
|
61
|
+
* @param id scoped id of the resource
|
|
62
|
+
* @param scope scope in which this resource is defined
|
|
63
|
+
* @param props api shield schema properties
|
|
64
|
+
* @see [CDKTF API Shield Schema Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
65
|
+
*/
|
|
66
|
+
public createApiShieldSchema(id: string, scope: CommonCloudflareConstruct, props: ApiShieldSchemaProps) {
|
|
67
|
+
if (!props) throw `Props undefined for ${id}`
|
|
68
|
+
|
|
69
|
+
const zoneId = props.zoneId
|
|
70
|
+
? props.zoneId
|
|
71
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
72
|
+
|
|
73
|
+
const apiShieldSchema = new ApiShieldSchema(scope, `${id}`, {
|
|
74
|
+
...props,
|
|
75
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
76
|
+
zoneId,
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
createCloudflareTfOutput(`${id}-apiShieldSchemaFriendlyUniqueId`, scope, apiShieldSchema.friendlyUniqueId)
|
|
80
|
+
createCloudflareTfOutput(`${id}-apiShieldSchemaId`, scope, apiShieldSchema.id)
|
|
81
|
+
|
|
82
|
+
return apiShieldSchema
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @summary Method to create a new Cloudflare Api Shield Schema Validation Settings
|
|
87
|
+
* @param id scoped id of the resource
|
|
88
|
+
* @param scope scope in which this resource is defined
|
|
89
|
+
* @param props api shield schema validation settings properties
|
|
90
|
+
* @see [CDKTF API Shield Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldSchema.typescript.md}
|
|
91
|
+
*/
|
|
92
|
+
public createApiShieldSchemaValidationSettings(
|
|
93
|
+
id: string,
|
|
94
|
+
scope: CommonCloudflareConstruct,
|
|
95
|
+
props: ApiShieldSchemaValidationSettingsProps
|
|
96
|
+
) {
|
|
97
|
+
if (!props) throw `Props undefined for ${id}`
|
|
98
|
+
|
|
99
|
+
const zoneId = props.zoneId
|
|
100
|
+
? props.zoneId
|
|
101
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
102
|
+
|
|
103
|
+
const apiShieldSchemaValidationSettings = new ApiShieldSchemaValidationSettings(scope, `${id}`, {
|
|
104
|
+
...props,
|
|
105
|
+
zoneId,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
createCloudflareTfOutput(
|
|
109
|
+
`${id}-apiShieldSchemaValidationSettingsFriendlyUniqueId`,
|
|
110
|
+
scope,
|
|
111
|
+
apiShieldSchemaValidationSettings.friendlyUniqueId
|
|
112
|
+
)
|
|
113
|
+
createCloudflareTfOutput(`${id}-apiShieldSchemaValidationSettingsId`, scope, apiShieldSchemaValidationSettings.id)
|
|
114
|
+
|
|
115
|
+
return apiShieldSchemaValidationSettings
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @summary Method to create a new Cloudflare Api Shield Operation
|
|
120
|
+
* @param id scoped id of the resource
|
|
121
|
+
* @param scope scope in which this resource is defined
|
|
122
|
+
* @param props api shield operation properties
|
|
123
|
+
* @see [CDKTF API Shield Operation Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperation.typescript.md}
|
|
124
|
+
*/
|
|
125
|
+
public createApiShieldOperation(id: string, scope: CommonCloudflareConstruct, props: ApiShieldOperationProps) {
|
|
126
|
+
if (!props) throw `Props undefined for ${id}`
|
|
127
|
+
|
|
128
|
+
const zoneId = props.zoneId
|
|
129
|
+
? props.zoneId
|
|
130
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
131
|
+
|
|
132
|
+
const apiShieldOperation = new ApiShieldOperation(scope, `${id}`, {
|
|
133
|
+
...props,
|
|
134
|
+
zoneId,
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
createCloudflareTfOutput(`${id}-apiShieldOperationFriendlyUniqueId`, scope, apiShieldOperation.friendlyUniqueId)
|
|
138
|
+
createCloudflareTfOutput(`${id}-apiShieldOperationId`, scope, apiShieldOperation.id)
|
|
139
|
+
|
|
140
|
+
return apiShieldOperation
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @summary Method to create a new Cloudflare Api Shield Operation Schema Validation Settings
|
|
145
|
+
* @param id scoped id of the resource
|
|
146
|
+
* @param scope scope in which this resource is defined
|
|
147
|
+
* @param props api shield operation schema validation settings properties
|
|
148
|
+
* @see [CDKTF API Shield Operation Schema Validation Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/apiShieldOperationSchemaValidationSettings.typescript.md}
|
|
149
|
+
*/
|
|
150
|
+
public createApiShieldOperationSchemaValidationSettings(
|
|
151
|
+
id: string,
|
|
152
|
+
scope: CommonCloudflareConstruct,
|
|
153
|
+
props: ApiShieldOperationSchemaValidationSettingsProps
|
|
154
|
+
) {
|
|
155
|
+
if (!props) throw `Props undefined for ${id}`
|
|
156
|
+
|
|
157
|
+
const zoneId = props.zoneId
|
|
158
|
+
? props.zoneId
|
|
159
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
160
|
+
|
|
161
|
+
const apiShieldOperationSchemaValidationSettings = new ApiShieldOperationSchemaValidationSettings(scope, `${id}`, {
|
|
162
|
+
...props,
|
|
163
|
+
zoneId,
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
createCloudflareTfOutput(
|
|
167
|
+
`${id}-apiShieldOperationSchemaValidationSettingsFriendlyUniqueId`,
|
|
168
|
+
scope,
|
|
169
|
+
apiShieldOperationSchemaValidationSettings.friendlyUniqueId
|
|
170
|
+
)
|
|
171
|
+
createCloudflareTfOutput(
|
|
172
|
+
`${id}-apiShieldOperationSchemaValidationSettingsId`,
|
|
173
|
+
scope,
|
|
174
|
+
apiShieldOperationSchemaValidationSettings.id
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
return apiShieldOperationSchemaValidationSettings
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiShieldConfig } from '@cdktf/provider-cloudflare/lib/api-shield'
|
|
2
|
+
import { ApiShieldOperationConfig } from '@cdktf/provider-cloudflare/lib/api-shield-operation'
|
|
3
|
+
import { ApiShieldOperationSchemaValidationSettingsConfig } from '@cdktf/provider-cloudflare/lib/api-shield-operation-schema-validation-settings'
|
|
4
|
+
import { ApiShieldSchemaConfig } from '@cdktf/provider-cloudflare/lib/api-shield-schema'
|
|
5
|
+
import { ApiShieldSchemaValidationSettingsConfig } from '@cdktf/provider-cloudflare/lib/api-shield-schema-validation-settings'
|
|
6
|
+
|
|
7
|
+
export interface ApiShieldProps extends ApiShieldConfig {}
|
|
8
|
+
export interface ApiShieldSchemaProps extends ApiShieldSchemaConfig {}
|
|
9
|
+
export interface ApiShieldSchemaValidationSettingsProps extends ApiShieldSchemaValidationSettingsConfig {}
|
|
10
|
+
export interface ApiShieldOperationProps extends ApiShieldOperationConfig {}
|
|
11
|
+
export interface ApiShieldOperationSchemaValidationSettingsProps
|
|
12
|
+
extends ApiShieldOperationSchemaValidationSettingsConfig {}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { WorkerDomain } from '@cdktf/provider-cloudflare/lib/worker-domain'
|
|
2
|
+
import { WorkerRoute } from '@cdktf/provider-cloudflare/lib/worker-route'
|
|
3
|
+
import { WorkerScript } from '@cdktf/provider-cloudflare/lib/worker-script'
|
|
4
|
+
import { CommonCloudflareConstruct } from '../../common'
|
|
5
|
+
import { createCloudflareTfOutput } from '../../utils'
|
|
6
|
+
import {
|
|
7
|
+
WorkerCronTriggerProps,
|
|
8
|
+
WorkerDomainProps,
|
|
9
|
+
WorkerRouteProps,
|
|
10
|
+
WorkerScriptProps,
|
|
11
|
+
WorkersKvNamespaceProps,
|
|
12
|
+
WorkersKvProps,
|
|
13
|
+
} from './types'
|
|
14
|
+
import { WorkersKvNamespace } from '@cdktf/provider-cloudflare/lib/workers-kv-namespace'
|
|
15
|
+
import { WorkersKv } from '@cdktf/provider-cloudflare/lib/workers-kv'
|
|
16
|
+
import { WorkerCronTrigger } from '@cdktf/provider-cloudflare/lib/worker-cron-trigger'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @classdesc Provides operations on Cloudflare Worker
|
|
20
|
+
* - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
|
|
21
|
+
* - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
|
|
22
|
+
* @example
|
|
23
|
+
* ```
|
|
24
|
+
* import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
|
|
25
|
+
*
|
|
26
|
+
* class CustomConstruct extends CommonCloudflareConstruct {
|
|
27
|
+
* constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
|
|
28
|
+
* super(parent, id, props)
|
|
29
|
+
* this.props = props
|
|
30
|
+
* this.workerManager.createWorkerDomain('MyWorkerDomain', this, props)
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export class CloudflareWorkerManager {
|
|
36
|
+
/**
|
|
37
|
+
* @summary Method to create a new Cloudflare Worker Domain
|
|
38
|
+
* @param id scoped id of the resource
|
|
39
|
+
* @param scope scope in which this resource is defined
|
|
40
|
+
* @param props worker domain properties
|
|
41
|
+
* @see [CDKTF Worker Domain Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerDomain.typescript.md}
|
|
42
|
+
*/
|
|
43
|
+
public createWorkerDomain(id: string, scope: CommonCloudflareConstruct, props: WorkerDomainProps) {
|
|
44
|
+
if (!props) throw `Props undefined for ${id}`
|
|
45
|
+
|
|
46
|
+
const zoneId = props.zoneId
|
|
47
|
+
? props.zoneId
|
|
48
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
49
|
+
|
|
50
|
+
const workerDomain = new WorkerDomain(scope, `${id}`, {
|
|
51
|
+
...props,
|
|
52
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
53
|
+
zoneId,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
createCloudflareTfOutput(`${id}-workerDomainFriendlyUniqueId`, scope, workerDomain.friendlyUniqueId)
|
|
57
|
+
createCloudflareTfOutput(`${id}-workerDomainId`, scope, workerDomain.id)
|
|
58
|
+
|
|
59
|
+
return workerDomain
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @summary Method to create a new Cloudflare Worker Route
|
|
64
|
+
* @param id scoped id of the resource
|
|
65
|
+
* @param scope scope in which this resource is defined
|
|
66
|
+
* @param props worker route properties
|
|
67
|
+
* @see [CDKTF Worker Route Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerRoute.typescript.md}
|
|
68
|
+
*/
|
|
69
|
+
public createWorkerRoute(id: string, scope: CommonCloudflareConstruct, props: WorkerRouteProps) {
|
|
70
|
+
if (!props) throw `Props undefined for ${id}`
|
|
71
|
+
|
|
72
|
+
const zoneId = props.zoneId
|
|
73
|
+
? props.zoneId
|
|
74
|
+
: scope.zoneManager.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id
|
|
75
|
+
|
|
76
|
+
const workerRoute = new WorkerRoute(scope, `${id}`, {
|
|
77
|
+
...props,
|
|
78
|
+
scriptName: `${props.scriptName}-${scope.props.stage}`,
|
|
79
|
+
zoneId,
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
createCloudflareTfOutput(`${id}-workerRouteFriendlyUniqueId`, scope, workerRoute.friendlyUniqueId)
|
|
83
|
+
createCloudflareTfOutput(`${id}-workerRouteId`, scope, workerRoute.id)
|
|
84
|
+
|
|
85
|
+
return workerRoute
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @summary Method to create a new Cloudflare Worker Script
|
|
90
|
+
* @param id scoped id of the resource
|
|
91
|
+
* @param scope scope in which this resource is defined
|
|
92
|
+
* @param props worker script properties
|
|
93
|
+
* @see [CDKTF Worker Script Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerScript.typescript.md}
|
|
94
|
+
*/
|
|
95
|
+
public createWorkerScript(id: string, scope: CommonCloudflareConstruct, props: WorkerScriptProps) {
|
|
96
|
+
if (!props) throw `Props undefined for ${id}`
|
|
97
|
+
|
|
98
|
+
const workerScript = new WorkerScript(scope, `${id}`, {
|
|
99
|
+
...props,
|
|
100
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
101
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
createCloudflareTfOutput(`${id}-workerScriptFriendlyUniqueId`, scope, workerScript.friendlyUniqueId)
|
|
105
|
+
createCloudflareTfOutput(`${id}-workerScriptId`, scope, workerScript.id)
|
|
106
|
+
|
|
107
|
+
return workerScript
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @summary Method to create a new Cloudflare Workers KV Namespace
|
|
112
|
+
* @param id scoped id of the resource
|
|
113
|
+
* @param scope scope in which this resource is defined
|
|
114
|
+
* @param props workers kv namespace properties
|
|
115
|
+
* @see [CDKTF Workers KV Namespace Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKvNamespace.typescript.md}
|
|
116
|
+
*/
|
|
117
|
+
public createWorkersKvNamespace(id: string, scope: CommonCloudflareConstruct, props: WorkersKvNamespaceProps) {
|
|
118
|
+
if (!props) throw `Props undefined for ${id}`
|
|
119
|
+
|
|
120
|
+
const workersKvNamespace = new WorkersKvNamespace(scope, `${id}`, {
|
|
121
|
+
...props,
|
|
122
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
123
|
+
title: scope.isProductionStage() ? props.title : `${props.title}-${scope.props.stage}`,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
createCloudflareTfOutput(`${id}-workersKvNamespaceFriendlyUniqueId`, scope, workersKvNamespace.friendlyUniqueId)
|
|
127
|
+
createCloudflareTfOutput(`${id}-workersKvNamespaceId`, scope, workersKvNamespace.id)
|
|
128
|
+
|
|
129
|
+
return workersKvNamespace
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @summary Method to create a new Cloudflare Workers KV
|
|
134
|
+
* @param id scoped id of the resource
|
|
135
|
+
* @param scope scope in which this resource is defined
|
|
136
|
+
* @param props workers kv properties
|
|
137
|
+
* @see [CDKTF Workers KV Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workersKv.typescript.md}
|
|
138
|
+
*/
|
|
139
|
+
public createWorkersKv(id: string, scope: CommonCloudflareConstruct, props: WorkersKvProps) {
|
|
140
|
+
if (!props) throw `Props undefined for ${id}`
|
|
141
|
+
|
|
142
|
+
const workersKv = new WorkersKv(scope, `${id}`, {
|
|
143
|
+
...props,
|
|
144
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
createCloudflareTfOutput(`${id}-workersKvFriendlyUniqueId`, scope, workersKv.friendlyUniqueId)
|
|
148
|
+
createCloudflareTfOutput(`${id}-workersKvId`, scope, workersKv.id)
|
|
149
|
+
|
|
150
|
+
return workersKv
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @summary Method to create a new Cloudflare Worker Cron Trigger
|
|
155
|
+
* @param id scoped id of the resource
|
|
156
|
+
* @param scope scope in which this resource is defined
|
|
157
|
+
* @param props workers cron trigger properties
|
|
158
|
+
* @see [CDKTF Workers Cron Trigger Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/workerCronTrigger.typescript.md}
|
|
159
|
+
*/
|
|
160
|
+
public createWorkerCronTrigger(id: string, scope: CommonCloudflareConstruct, props: WorkerCronTriggerProps) {
|
|
161
|
+
if (!props) throw `Props undefined for ${id}`
|
|
162
|
+
|
|
163
|
+
const workerCronTrigger = new WorkerCronTrigger(scope, `${id}`, {
|
|
164
|
+
...props,
|
|
165
|
+
accountId: props.accountId ?? scope.props.accountId,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
createCloudflareTfOutput(`${id}-workerCronTriggerFriendlyUniqueId`, scope, workerCronTrigger.friendlyUniqueId)
|
|
169
|
+
createCloudflareTfOutput(`${id}-workerCronTriggerId`, scope, workerCronTrigger.id)
|
|
170
|
+
|
|
171
|
+
return workerCronTrigger
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkerCronTriggerConfig } from '@cdktf/provider-cloudflare/lib/worker-cron-trigger'
|
|
2
|
+
import { WorkerDomainConfig } from '@cdktf/provider-cloudflare/lib/worker-domain'
|
|
3
|
+
import { WorkerRouteConfig } from '@cdktf/provider-cloudflare/lib/worker-route'
|
|
4
|
+
import { WorkerScriptConfig } from '@cdktf/provider-cloudflare/lib/worker-script'
|
|
5
|
+
import { WorkersKvConfig } from '@cdktf/provider-cloudflare/lib/workers-kv'
|
|
6
|
+
import { WorkersKvNamespaceConfig } from '@cdktf/provider-cloudflare/lib/workers-kv-namespace'
|
|
7
|
+
|
|
8
|
+
export interface WorkerDomainProps extends WorkerDomainConfig {}
|
|
9
|
+
export interface WorkerRouteProps extends WorkerRouteConfig {}
|
|
10
|
+
export interface WorkerScriptProps extends WorkerScriptConfig {}
|
|
11
|
+
export interface WorkersKvNamespaceProps extends WorkersKvNamespaceConfig {}
|
|
12
|
+
export interface WorkersKvProps extends WorkersKvConfig {}
|
|
13
|
+
export interface WorkerCronTriggerProps extends WorkerCronTriggerConfig {}
|