@gradientedge/cdk-utils 9.89.0 → 10.1.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 +7 -19
- package/dist/src/lib/cloudflare/common/construct.js +12 -66
- package/dist/src/lib/cloudflare/common/index.d.ts +0 -1
- package/dist/src/lib/cloudflare/common/index.js +0 -1
- package/dist/src/lib/cloudflare/common/stack.d.ts +11 -21
- package/dist/src/lib/cloudflare/common/stack.js +55 -62
- package/dist/src/lib/cloudflare/common/types.d.ts +2 -14
- package/dist/src/lib/cloudflare/construct/pages-static-site/main.d.ts +8 -10
- package/dist/src/lib/cloudflare/construct/pages-static-site/main.js +18 -25
- package/dist/src/lib/cloudflare/construct/worker-site/main.d.ts +13 -10
- package/dist/src/lib/cloudflare/construct/worker-site/main.js +29 -41
- package/dist/src/lib/cloudflare/index.d.ts +0 -1
- package/dist/src/lib/cloudflare/index.js +0 -1
- package/dist/src/lib/cloudflare/services/access/main.d.ts +31 -43
- package/dist/src/lib/cloudflare/services/access/main.js +56 -83
- package/dist/src/lib/cloudflare/services/access/types.d.ts +12 -22
- package/dist/src/lib/cloudflare/services/api-shield/main.d.ts +10 -15
- package/dist/src/lib/cloudflare/services/api-shield/main.js +16 -36
- package/dist/src/lib/cloudflare/services/api-shield/types.d.ts +6 -10
- package/dist/src/lib/cloudflare/services/argo/main.d.ts +6 -8
- package/dist/src/lib/cloudflare/services/argo/main.js +9 -17
- package/dist/src/lib/cloudflare/services/argo/types.d.ts +3 -4
- package/dist/src/lib/cloudflare/services/filter/main.d.ts +3 -4
- package/dist/src/lib/cloudflare/services/filter/main.js +6 -10
- package/dist/src/lib/cloudflare/services/filter/types.d.ts +2 -2
- package/dist/src/lib/cloudflare/services/firewall/main.d.ts +2 -3
- package/dist/src/lib/cloudflare/services/firewall/main.js +4 -8
- package/dist/src/lib/cloudflare/services/firewall/types.d.ts +2 -2
- package/dist/src/lib/cloudflare/services/page/main.d.ts +7 -11
- package/dist/src/lib/cloudflare/services/page/main.js +13 -26
- package/dist/src/lib/cloudflare/services/page/types.d.ts +4 -6
- package/dist/src/lib/cloudflare/services/record/main.d.ts +2 -3
- package/dist/src/lib/cloudflare/services/record/main.js +4 -8
- package/dist/src/lib/cloudflare/services/record/types.d.ts +2 -2
- package/dist/src/lib/cloudflare/services/rule-set/main.d.ts +5 -6
- package/dist/src/lib/cloudflare/services/rule-set/main.js +7 -10
- package/dist/src/lib/cloudflare/services/rule-set/types.d.ts +2 -2
- package/dist/src/lib/cloudflare/services/worker/main.d.ts +12 -18
- package/dist/src/lib/cloudflare/services/worker/main.js +15 -39
- package/dist/src/lib/cloudflare/services/worker/types.d.ts +7 -12
- package/dist/src/lib/cloudflare/services/zone/main.d.ts +13 -30
- package/dist/src/lib/cloudflare/services/zone/main.js +31 -84
- package/dist/src/lib/cloudflare/services/zone/types.d.ts +10 -20
- package/dist/src/lib/common/types.d.ts +4 -0
- package/package.json +29 -23
- package/src/lib/cloudflare/common/construct.ts +13 -70
- package/src/lib/cloudflare/common/index.ts +0 -1
- package/src/lib/cloudflare/common/stack.ts +58 -69
- package/src/lib/cloudflare/common/types.ts +2 -15
- package/src/lib/cloudflare/construct/pages-static-site/main.ts +22 -42
- package/src/lib/cloudflare/construct/worker-site/main.ts +38 -62
- package/src/lib/cloudflare/index.ts +0 -1
- package/src/lib/cloudflare/services/access/main.ts +57 -118
- package/src/lib/cloudflare/services/access/types.ts +24 -22
- package/src/lib/cloudflare/services/api-shield/main.ts +16 -63
- package/src/lib/cloudflare/services/api-shield/types.ts +12 -10
- package/src/lib/cloudflare/services/argo/main.ts +9 -23
- package/src/lib/cloudflare/services/argo/types.ts +3 -4
- package/src/lib/cloudflare/services/filter/main.ts +6 -13
- package/src/lib/cloudflare/services/filter/types.ts +2 -2
- package/src/lib/cloudflare/services/firewall/main.ts +4 -11
- package/src/lib/cloudflare/services/firewall/types.ts +2 -2
- package/src/lib/cloudflare/services/page/main.ts +19 -36
- package/src/lib/cloudflare/services/page/types.ts +4 -6
- package/src/lib/cloudflare/services/record/main.ts +4 -11
- package/src/lib/cloudflare/services/record/types.ts +2 -2
- package/src/lib/cloudflare/services/rule-set/main.ts +7 -12
- package/src/lib/cloudflare/services/rule-set/types.ts +2 -2
- package/src/lib/cloudflare/services/worker/main.ts +15 -52
- package/src/lib/cloudflare/services/worker/types.ts +14 -12
- package/src/lib/cloudflare/services/zone/main.ts +40 -103
- package/src/lib/cloudflare/services/zone/types.ts +20 -21
- package/src/lib/common/types.ts +5 -0
- package/dist/src/lib/cloudflare/common/constants.d.ts +0 -5
- package/dist/src/lib/cloudflare/common/constants.js +0 -6
- package/dist/src/lib/cloudflare/utils/index.d.ts +0 -3
- package/dist/src/lib/cloudflare/utils/index.js +0 -13
- package/src/lib/cloudflare/common/constants.ts +0 -5
- package/src/lib/cloudflare/utils/index.ts +0 -23
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AzurermBackend, S3Backend, TerraformStack } from 'cdktf';
|
|
4
|
-
import { Construct } from 'constructs';
|
|
1
|
+
import { Provider as CloudflareProvider } from '@pulumi/cloudflare';
|
|
2
|
+
import { ComponentResource, ComponentResourceOptions, Config } from '@pulumi/pulumi';
|
|
5
3
|
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareRecordManager, CloudflareRuleSetManager, CloudflareWorkerManager, CloudflareZoneManager } from '../services/index.js';
|
|
6
4
|
import { CommonCloudflareStackProps } from './types.js';
|
|
7
|
-
export declare class CommonCloudflareConstruct extends
|
|
5
|
+
export declare class CommonCloudflareConstruct extends ComponentResource {
|
|
8
6
|
props: CommonCloudflareStackProps;
|
|
7
|
+
options?: ComponentResourceOptions;
|
|
9
8
|
id: string;
|
|
9
|
+
config: Config;
|
|
10
10
|
fullyQualifiedDomainName: string;
|
|
11
11
|
accessManager: CloudflareAccessManager;
|
|
12
12
|
apiShieldManager: CloudflareApiShieldManager;
|
|
@@ -18,24 +18,12 @@ export declare class CommonCloudflareConstruct extends TerraformStack {
|
|
|
18
18
|
ruleSetManager: CloudflareRuleSetManager;
|
|
19
19
|
workerManager: CloudflareWorkerManager;
|
|
20
20
|
zoneManager: CloudflareZoneManager;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
azurermProvider: AzurermProvider;
|
|
24
|
-
azurermBackend: AzurermBackend;
|
|
25
|
-
constructor(scope: Construct, id: string, props: CommonCloudflareStackProps);
|
|
21
|
+
provider: CloudflareProvider;
|
|
22
|
+
constructor(name: string, props: CommonCloudflareStackProps, options?: ComponentResourceOptions);
|
|
26
23
|
/**
|
|
27
24
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
28
25
|
*/
|
|
29
26
|
protected determineFullyQualifiedDomain(): void;
|
|
30
|
-
/**
|
|
31
|
-
* @summary Determine the account id based on the cdktf.json context
|
|
32
|
-
*/
|
|
33
|
-
protected determineAccountId(): void;
|
|
34
|
-
/**
|
|
35
|
-
* @summary Determine the api token based on the cdktf.json context
|
|
36
|
-
*/
|
|
37
|
-
protected determineApiToken(): void;
|
|
38
|
-
protected determineRemoteBackend(): void;
|
|
39
27
|
/**
|
|
40
28
|
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
41
29
|
* This is determined by the stage property injected via cdk context
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider/index.js';
|
|
4
|
-
import { AzurermBackend, S3Backend, TerraformStack, TerraformVariable } from 'cdktf';
|
|
1
|
+
import { Provider as CloudflareProvider } from '@pulumi/cloudflare';
|
|
2
|
+
import { ComponentResource, Config } from '@pulumi/pulumi';
|
|
5
3
|
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common/index.js';
|
|
6
4
|
import { CloudflareAccessManager, CloudflareApiShieldManager, CloudflareArgoManager, CloudflareFilterManager, CloudflareFirewallManager, CloudflarePageManager, CloudflareRecordManager, CloudflareRuleSetManager, CloudflareWorkerManager, CloudflareZoneManager, } from '../services/index.js';
|
|
7
|
-
|
|
8
|
-
export class CommonCloudflareConstruct extends TerraformStack {
|
|
5
|
+
export class CommonCloudflareConstruct extends ComponentResource {
|
|
9
6
|
id;
|
|
7
|
+
config;
|
|
10
8
|
fullyQualifiedDomainName;
|
|
11
9
|
accessManager;
|
|
12
10
|
apiShieldManager;
|
|
@@ -18,14 +16,12 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
18
16
|
ruleSetManager;
|
|
19
17
|
workerManager;
|
|
20
18
|
zoneManager;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
azurermBackend;
|
|
25
|
-
constructor(scope, id, props) {
|
|
26
|
-
super(scope, id);
|
|
19
|
+
provider;
|
|
20
|
+
constructor(name, props, options) {
|
|
21
|
+
super(`custom:cloudflare:Construct:${name}`, name, props, options);
|
|
27
22
|
this.props = props;
|
|
28
|
-
this.
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.id = name;
|
|
29
25
|
this.accessManager = new CloudflareAccessManager();
|
|
30
26
|
this.apiShieldManager = new CloudflareApiShieldManager();
|
|
31
27
|
this.argoManager = new CloudflareArgoManager();
|
|
@@ -36,11 +32,10 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
36
32
|
this.ruleSetManager = new CloudflareRuleSetManager();
|
|
37
33
|
this.workerManager = new CloudflareWorkerManager();
|
|
38
34
|
this.zoneManager = new CloudflareZoneManager();
|
|
35
|
+
/* initialise config */
|
|
36
|
+
this.config = new Config();
|
|
39
37
|
this.determineFullyQualifiedDomain();
|
|
40
|
-
this.
|
|
41
|
-
this.determineApiToken();
|
|
42
|
-
this.determineRemoteBackend();
|
|
43
|
-
new CloudflareProvider(this, `${this.id}-provider`, this.props);
|
|
38
|
+
this.provider = new CloudflareProvider(`${this.id}-provider`, this.props, options);
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
41
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
@@ -50,55 +45,6 @@ export class CommonCloudflareConstruct extends TerraformStack {
|
|
|
50
45
|
? `${this.props.subDomain}.${this.props.domainName}`
|
|
51
46
|
: this.props.domainName;
|
|
52
47
|
}
|
|
53
|
-
/**
|
|
54
|
-
* @summary Determine the account id based on the cdktf.json context
|
|
55
|
-
*/
|
|
56
|
-
determineAccountId() {
|
|
57
|
-
this.props.accountId = new TerraformVariable(this, `accountId`, {}).stringValue;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @summary Determine the api token based on the cdktf.json context
|
|
61
|
-
*/
|
|
62
|
-
determineApiToken() {
|
|
63
|
-
this.props.apiToken = new TerraformVariable(this, `apiToken`, {}).stringValue;
|
|
64
|
-
}
|
|
65
|
-
determineRemoteBackend() {
|
|
66
|
-
const debug = this.node.tryGetContext('debug');
|
|
67
|
-
switch (this.props.remoteBackend?.type) {
|
|
68
|
-
case RemoteBackend.s3:
|
|
69
|
-
this.awsProvider = new AwsProvider(this, `${this.id}-aws-provider`, {
|
|
70
|
-
profile: process.env.AWS_PROFILE,
|
|
71
|
-
region: this.props.remoteBackend.region,
|
|
72
|
-
});
|
|
73
|
-
this.s3Backend = new S3Backend(this, {
|
|
74
|
-
bucket: this.props.remoteBackend.bucketName,
|
|
75
|
-
dynamodbTable: this.props.remoteBackend.tableName,
|
|
76
|
-
key: `${this.id}`,
|
|
77
|
-
profile: process.env.AWS_PROFILE,
|
|
78
|
-
region: this.props.remoteBackend.region,
|
|
79
|
-
});
|
|
80
|
-
break;
|
|
81
|
-
case RemoteBackend.azurerm:
|
|
82
|
-
this.azurermProvider = new AzurermProvider(this, `${this.id}-azurerm-provider`, {
|
|
83
|
-
features: [{}],
|
|
84
|
-
subscriptionId: this.props.remoteBackend.subscriptionId,
|
|
85
|
-
});
|
|
86
|
-
this.azurermBackend = new AzurermBackend(this, {
|
|
87
|
-
storageAccountName: this.props.remoteBackend.storageAccountName,
|
|
88
|
-
containerName: this.props.remoteBackend.containerName,
|
|
89
|
-
key: `${this.id}`,
|
|
90
|
-
subscriptionId: this.props.remoteBackend.subscriptionId,
|
|
91
|
-
resourceGroupName: this.props.remoteBackend.resourceGroupName,
|
|
92
|
-
});
|
|
93
|
-
break;
|
|
94
|
-
case RemoteBackend.local:
|
|
95
|
-
if (debug)
|
|
96
|
-
console.debug(`Using local backend for ${this.id}`);
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
48
|
/**
|
|
103
49
|
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
104
50
|
* This is determined by the stage property injected via cdk context
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { ComponentResource, ComponentResourceOptions, Config } from '@pulumi/pulumi';
|
|
1
2
|
import { CommonCloudflareConstruct } from './construct.js';
|
|
2
3
|
import { CommonCloudflareStackProps } from './types.js';
|
|
3
|
-
import { TerraformStack } from 'cdktf';
|
|
4
|
-
import { Construct } from 'constructs';
|
|
5
4
|
/**
|
|
6
5
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
7
6
|
* @example
|
|
@@ -14,40 +13,31 @@ import { Construct } from 'constructs';
|
|
|
14
13
|
* }
|
|
15
14
|
* }
|
|
16
15
|
*/
|
|
17
|
-
export declare class CommonCloudflareStack extends
|
|
16
|
+
export declare class CommonCloudflareStack extends ComponentResource {
|
|
18
17
|
construct: CommonCloudflareConstruct;
|
|
19
18
|
props: CommonCloudflareStackProps;
|
|
20
|
-
|
|
19
|
+
config: Config;
|
|
20
|
+
constructor(name: string, props: CommonCloudflareStackProps, options?: ComponentResourceOptions);
|
|
21
21
|
/**
|
|
22
|
-
* @summary Method to determine the core CDK construct properties injected via context
|
|
22
|
+
* @summary Method to determine the core CDK construct properties injected via context
|
|
23
23
|
* @param props The stack properties
|
|
24
24
|
* @returns The stack properties
|
|
25
25
|
*/
|
|
26
|
-
protected determineConstructProps(props: CommonCloudflareStackProps):
|
|
27
|
-
accountId: any;
|
|
28
|
-
apiToken: any;
|
|
29
|
-
domainName: any;
|
|
30
|
-
extraContexts: any;
|
|
31
|
-
features: any;
|
|
32
|
-
name: any;
|
|
33
|
-
skipStageForARecords: any;
|
|
34
|
-
stage: any;
|
|
35
|
-
subDomain: any;
|
|
36
|
-
};
|
|
26
|
+
protected determineConstructProps(props: CommonCloudflareStackProps): any;
|
|
37
27
|
/**
|
|
38
|
-
* @summary Method to determine extra cdk contexts apart from the main
|
|
28
|
+
* @summary Method to determine extra cdk contexts apart from the main context
|
|
39
29
|
* - Sets the properties from the extra contexts into cdk node context
|
|
40
30
|
* - Primary use is to have layered config in separate files to enable easier maintenance and readability
|
|
41
31
|
*/
|
|
42
|
-
protected determineExtraContexts():
|
|
32
|
+
protected determineExtraContexts(props: CommonCloudflareStackProps): Record<string, any>;
|
|
43
33
|
/**
|
|
44
|
-
* @summary Method to determine extra cdk stage contexts apart from the main
|
|
34
|
+
* @summary Method to determine extra cdk stage contexts apart from the main context
|
|
45
35
|
* - Sets the properties from the extra stage contexts into cdk node context
|
|
46
36
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
47
37
|
*/
|
|
48
|
-
protected determineStageContexts():
|
|
38
|
+
protected determineStageContexts(props: CommonCloudflareStackProps): any;
|
|
49
39
|
/**
|
|
50
40
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
51
41
|
*/
|
|
52
|
-
protected fullyQualifiedDomain():
|
|
42
|
+
protected fullyQualifiedDomain(): string;
|
|
53
43
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ComponentResource, Config } from '@pulumi/pulumi';
|
|
2
2
|
import appRoot from 'app-root-path';
|
|
3
|
-
import
|
|
3
|
+
import fs from 'fs';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { isDevStage } from '../../common/index.js';
|
|
@@ -16,112 +16,105 @@ import { isDevStage } from '../../common/index.js';
|
|
|
16
16
|
* }
|
|
17
17
|
* }
|
|
18
18
|
*/
|
|
19
|
-
export class CommonCloudflareStack extends
|
|
19
|
+
export class CommonCloudflareStack extends ComponentResource {
|
|
20
20
|
construct;
|
|
21
21
|
props;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.determineStageContexts();
|
|
22
|
+
config;
|
|
23
|
+
constructor(name, props, options) {
|
|
24
|
+
super(`custom:cloudflare:Stack:${name}`, name, props, options);
|
|
25
|
+
/* initialise config */
|
|
26
|
+
this.config = new Config();
|
|
28
27
|
this.props = this.determineConstructProps(props);
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
|
-
* @summary Method to determine the core CDK construct properties injected via context
|
|
30
|
+
* @summary Method to determine the core CDK construct properties injected via context
|
|
32
31
|
* @param props The stack properties
|
|
33
32
|
* @returns The stack properties
|
|
34
33
|
*/
|
|
35
34
|
determineConstructProps(props) {
|
|
36
|
-
|
|
35
|
+
let projectProps = props;
|
|
36
|
+
if (!projectProps) {
|
|
37
|
+
const projectPropsPath = path.join(appRoot.path, 'pulumi.json');
|
|
38
|
+
if (!fs.existsSync(projectPropsPath))
|
|
39
|
+
throw `Context properties unavailable in path:${projectPropsPath}`;
|
|
40
|
+
const projectPropsBuffer = fs.readFileSync(projectPropsPath);
|
|
41
|
+
projectProps = JSON.parse(projectPropsBuffer.toString('utf-8'));
|
|
42
|
+
}
|
|
37
43
|
return {
|
|
38
|
-
accountId:
|
|
39
|
-
apiToken:
|
|
40
|
-
domainName:
|
|
41
|
-
extraContexts:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
subDomain:
|
|
44
|
+
accountId: projectProps.accountId,
|
|
45
|
+
apiToken: projectProps.apiToken,
|
|
46
|
+
domainName: projectProps.domainName,
|
|
47
|
+
extraContexts: projectProps.extraContexts,
|
|
48
|
+
name: projectProps.resourceGroupName ?? projectProps.name,
|
|
49
|
+
skipStageForARecords: projectProps.skipStageForARecords,
|
|
50
|
+
stage: projectProps.stage,
|
|
51
|
+
stageContextPath: projectProps.stageContextPath,
|
|
52
|
+
subDomain: projectProps.subDomain,
|
|
53
|
+
...this.determineExtraContexts(props),
|
|
54
|
+
...this.determineStageContexts(props),
|
|
47
55
|
};
|
|
48
56
|
}
|
|
49
57
|
/**
|
|
50
|
-
* @summary Method to determine extra cdk contexts apart from the main
|
|
58
|
+
* @summary Method to determine extra cdk contexts apart from the main context
|
|
51
59
|
* - Sets the properties from the extra contexts into cdk node context
|
|
52
60
|
* - Primary use is to have layered config in separate files to enable easier maintenance and readability
|
|
53
61
|
*/
|
|
54
|
-
determineExtraContexts() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
console.debug(`No additional contexts provided. Using default context properties from cdktf.json`);
|
|
60
|
-
return;
|
|
62
|
+
determineExtraContexts(props) {
|
|
63
|
+
if (!props.extraContexts) {
|
|
64
|
+
if (props.debug)
|
|
65
|
+
console.debug(`No additional contexts provided. Using default context properties`);
|
|
66
|
+
return {};
|
|
61
67
|
}
|
|
62
|
-
|
|
68
|
+
let extraContextProps = {};
|
|
69
|
+
_.forEach(props.extraContexts, (context) => {
|
|
63
70
|
const extraContextPath = path.join(appRoot.path, context);
|
|
64
71
|
/* scenario where extra context is configured in cdk.json but absent in file system */
|
|
65
72
|
if (!fs.existsSync(extraContextPath))
|
|
66
73
|
throw `Extra context properties unavailable in path:${extraContextPath}`;
|
|
67
74
|
/* read the extra properties */
|
|
68
75
|
const extraContextPropsBuffer = fs.readFileSync(extraContextPath);
|
|
69
|
-
if (debug)
|
|
76
|
+
if (props.debug)
|
|
70
77
|
console.debug(`Adding additional contexts provided in ${extraContextPath}`);
|
|
71
78
|
/* parse as JSON properties */
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
79
|
+
extraContextProps = {
|
|
80
|
+
...extraContextProps,
|
|
81
|
+
...JSON.parse(extraContextPropsBuffer.toString('utf-8')),
|
|
82
|
+
};
|
|
77
83
|
});
|
|
84
|
+
return extraContextProps;
|
|
78
85
|
}
|
|
79
86
|
/**
|
|
80
|
-
* @summary Method to determine extra cdk stage contexts apart from the main
|
|
87
|
+
* @summary Method to determine extra cdk stage contexts apart from the main context
|
|
81
88
|
* - Sets the properties from the extra stage contexts into cdk node context
|
|
82
89
|
* - Primary use is to have layered config for each environment which is injected into the context
|
|
83
90
|
*/
|
|
84
|
-
determineStageContexts() {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const debug = this.node.tryGetContext('debug');
|
|
89
|
-
if (isDevStage(stage)) {
|
|
90
|
-
if (debug)
|
|
91
|
+
determineStageContexts(props) {
|
|
92
|
+
const stageContextFilePath = path.join(appRoot.path, props.stageContextPath ?? 'cdkEnv', `${props.stage}.json`);
|
|
93
|
+
if (isDevStage(props.stage)) {
|
|
94
|
+
if (props.debug)
|
|
91
95
|
console.debug(`Development stage. Using default stage context properties`);
|
|
92
96
|
}
|
|
93
97
|
/* alert default context usage when extra stage config is missing */
|
|
94
98
|
if (!fs.existsSync(stageContextFilePath)) {
|
|
95
|
-
if (debug)
|
|
99
|
+
if (props.debug)
|
|
96
100
|
console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`);
|
|
97
|
-
if (debug)
|
|
98
|
-
console.debug(`Using default stage context properties for ${stage} stage`);
|
|
99
|
-
return;
|
|
101
|
+
if (props.debug)
|
|
102
|
+
console.debug(`Using default stage context properties for ${props.stage} stage`);
|
|
103
|
+
return {};
|
|
100
104
|
}
|
|
101
105
|
/* read the extra properties */
|
|
102
106
|
const stageContextPropsBuffer = fs.readFileSync(stageContextFilePath);
|
|
103
|
-
if (debug)
|
|
107
|
+
if (props.debug)
|
|
104
108
|
console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`);
|
|
105
109
|
/* parse as JSON properties */
|
|
106
|
-
|
|
107
|
-
/* set each of the property into the cdk node context */
|
|
108
|
-
_.keys(stageContextProps).forEach((propKey) => {
|
|
109
|
-
/* handle object, array properties */
|
|
110
|
-
if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
|
|
111
|
-
this.node.setContext(propKey, _.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
/* handle all other primitive properties */
|
|
115
|
-
this.node.setContext(propKey, stageContextProps[propKey]);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
110
|
+
return JSON.parse(stageContextPropsBuffer.toString('utf-8'));
|
|
118
111
|
}
|
|
119
112
|
/**
|
|
120
113
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
121
114
|
*/
|
|
122
115
|
fullyQualifiedDomain() {
|
|
123
|
-
const domainName = this.
|
|
124
|
-
const subDomain = this.
|
|
116
|
+
const domainName = this.props.domainName;
|
|
117
|
+
const subDomain = this.props.subDomain;
|
|
125
118
|
return subDomain ? `${subDomain}.${domainName}` : domainName;
|
|
126
119
|
}
|
|
127
120
|
}
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
import { CloudflareProviderConfig } from '@cdktf/provider-cloudflare/lib/provider/index.js';
|
|
2
1
|
import { BaseProps } from '../../common/index.js';
|
|
3
|
-
import { RemoteBackend } from './constants.js';
|
|
4
|
-
export interface RemoteBackendProps {
|
|
5
|
-
bucketName: string;
|
|
6
|
-
region: string;
|
|
7
|
-
tableName: string;
|
|
8
|
-
type: RemoteBackend;
|
|
9
|
-
storageAccountName: string;
|
|
10
|
-
containerName: string;
|
|
11
|
-
subscriptionId: string;
|
|
12
|
-
resourceGroupName: string;
|
|
13
|
-
}
|
|
14
2
|
/**
|
|
15
3
|
*/
|
|
16
|
-
export interface CommonCloudflareStackProps extends BaseProps
|
|
4
|
+
export interface CommonCloudflareStackProps extends BaseProps {
|
|
17
5
|
accountId: string;
|
|
18
6
|
apiToken: string;
|
|
19
|
-
|
|
7
|
+
resourceGroupName?: string;
|
|
20
8
|
useExistingZone?: boolean;
|
|
21
9
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { Zone } from '@cdktf/provider-cloudflare/lib/zone/index.js';
|
|
6
|
-
import { Construct } from 'constructs';
|
|
1
|
+
import { DnsRecord, PagesDomain, PagesProject, Zone } from '@pulumi/cloudflare';
|
|
2
|
+
import { PagesProjectDeploymentConfigsPreviewEnvVars, PagesProjectDeploymentConfigsProductionEnvVars } from '@pulumi/cloudflare/types/input.js';
|
|
3
|
+
import { ComponentResourceOptions } from '@pulumi/pulumi';
|
|
4
|
+
import * as std from '@pulumi/std';
|
|
7
5
|
import { CommonCloudflareConstruct } from '../../common/index.js';
|
|
8
6
|
import { CloudflarePagesStaticSiteProps } from './types.js';
|
|
9
7
|
/**
|
|
@@ -26,7 +24,7 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
|
|
|
26
24
|
sitePagesCnameRecord: DnsRecord;
|
|
27
25
|
sitePagesDomain: PagesDomain;
|
|
28
26
|
sitePagesProject: PagesProject;
|
|
29
|
-
siteZone:
|
|
27
|
+
siteZone: Zone;
|
|
30
28
|
sitePagesEnvironmentVariables: {
|
|
31
29
|
[key: string]: PagesProjectDeploymentConfigsProductionEnvVars;
|
|
32
30
|
};
|
|
@@ -40,7 +38,7 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
|
|
|
40
38
|
[key: string]: PagesProjectDeploymentConfigsPreviewEnvVars;
|
|
41
39
|
};
|
|
42
40
|
siteDeploymentDependsOn: any;
|
|
43
|
-
constructor(
|
|
41
|
+
constructor(id: string, props: CloudflarePagesStaticSiteProps, options?: ComponentResourceOptions);
|
|
44
42
|
/**
|
|
45
43
|
* @summary Initialise and provision resources
|
|
46
44
|
*/
|
|
@@ -63,7 +61,7 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
|
|
|
63
61
|
* @param secretKey the secret key
|
|
64
62
|
* @returns the secret value
|
|
65
63
|
*/
|
|
66
|
-
protected resolveSecretFromAWS(secretName: string, secretKey: string):
|
|
64
|
+
protected resolveSecretFromAWS(secretName: string, secretKey: string): import("@pulumi/pulumi").Output<std.JsondecodeResult> | undefined;
|
|
67
65
|
/**
|
|
68
66
|
* @summary Resolve secrets from Azure Key Vault
|
|
69
67
|
*
|
|
@@ -72,7 +70,7 @@ export declare class CloudflarePagesStaticSite extends CommonCloudflareConstruct
|
|
|
72
70
|
* @param secretKey the secret key
|
|
73
71
|
* @returns the secret value
|
|
74
72
|
*/
|
|
75
|
-
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string): string;
|
|
73
|
+
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string): import("@pulumi/pulumi").OutputInstance<string | undefined> | undefined;
|
|
76
74
|
/**
|
|
77
75
|
* @summary Create the pages project
|
|
78
76
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { DataAzurermKeyVault } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault/index.js';
|
|
5
|
-
import { Fn } from 'cdktf';
|
|
1
|
+
import * as aws from '@pulumi/aws';
|
|
2
|
+
import * as azure from '@pulumi/azure-native';
|
|
3
|
+
import * as std from '@pulumi/std';
|
|
6
4
|
import { CommonCloudflareConstruct } from '../../common/index.js';
|
|
7
5
|
/**
|
|
8
6
|
* @classdesc Provides a construct to create and deploy a cloudflare pages static site
|
|
@@ -30,9 +28,10 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
|
|
|
30
28
|
sitePagesSecrets;
|
|
31
29
|
sitePagesPreviewSecrets;
|
|
32
30
|
siteDeploymentDependsOn;
|
|
33
|
-
constructor(
|
|
34
|
-
super(
|
|
31
|
+
constructor(id, props, options) {
|
|
32
|
+
super(id, props);
|
|
35
33
|
this.props = props;
|
|
34
|
+
this.options = options;
|
|
36
35
|
this.id = id;
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
@@ -97,16 +96,13 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
|
|
|
97
96
|
* @returns the secret value
|
|
98
97
|
*/
|
|
99
98
|
resolveSecretFromAWS(secretName, secretKey) {
|
|
100
|
-
if (
|
|
99
|
+
if (this.config.require('secretsProvider') !== 'aws')
|
|
101
100
|
return;
|
|
102
|
-
const secret =
|
|
103
|
-
const secretVersion =
|
|
104
|
-
provider: this.awsProvider,
|
|
105
|
-
secretId: secret.id,
|
|
106
|
-
});
|
|
101
|
+
const secret = aws.secretsmanager.getSecretOutput({ name: secretName });
|
|
102
|
+
const secretVersion = aws.secretsmanager.getSecretVersionOutput({ secretId: secret.id });
|
|
107
103
|
if (!secretVersion)
|
|
108
104
|
throw new Error(`Unable to resolve secret:${secretName}`);
|
|
109
|
-
return
|
|
105
|
+
return std.jsondecodeOutput({ input: secretVersion.secretString });
|
|
110
106
|
}
|
|
111
107
|
/**
|
|
112
108
|
* @summary Resolve secrets from Azure Key Vault
|
|
@@ -117,19 +113,16 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
|
|
|
117
113
|
* @returns the secret value
|
|
118
114
|
*/
|
|
119
115
|
resolveSecretFromAzure(resourceGroupName, keyVaultName, secretKey) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
name: secretKey,
|
|
127
|
-
keyVaultId: keyVaultData.id,
|
|
128
|
-
provider: this.azurermProvider,
|
|
116
|
+
if (this.config.require('secretsProvider') !== 'azure')
|
|
117
|
+
return;
|
|
118
|
+
const secretValueData = azure.keyvault.getSecretOutput({
|
|
119
|
+
resourceGroupName,
|
|
120
|
+
secretName: secretKey,
|
|
121
|
+
vaultName: keyVaultName,
|
|
129
122
|
});
|
|
130
123
|
if (!secretValueData)
|
|
131
124
|
throw new Error(`Unable to resolve secret:${secretKey}`);
|
|
132
|
-
return secretValueData.value;
|
|
125
|
+
return secretValueData.properties?.value;
|
|
133
126
|
}
|
|
134
127
|
/**
|
|
135
128
|
* @summary Create the pages project
|
|
@@ -168,7 +161,7 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
|
|
|
168
161
|
branch: this.props.siteBranch ?? 'main',
|
|
169
162
|
directory: this.props.siteAssetDir,
|
|
170
163
|
message: this.props.siteDeployMessage,
|
|
171
|
-
projectName: this.sitePagesProject.name,
|
|
164
|
+
projectName: String(this.sitePagesProject.name),
|
|
172
165
|
dependsOn: this.siteDeploymentDependsOn,
|
|
173
166
|
});
|
|
174
167
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { Ruleset, WorkersCustomDomain, WorkersScript, Zone, ZoneSetting } from '@pulumi/cloudflare';
|
|
2
|
+
import { WorkersScriptBinding } from '@pulumi/cloudflare/types/input.js';
|
|
3
|
+
import { ComponentResourceOptions } from '@pulumi/pulumi';
|
|
4
|
+
import * as std from '@pulumi/std';
|
|
5
5
|
import { CommonCloudflareConstruct } from '../../common/index.js';
|
|
6
6
|
import { CloudflareWorkerSiteProps } from './types.js';
|
|
7
7
|
/**
|
|
@@ -21,11 +21,14 @@ import { CloudflareWorkerSiteProps } from './types.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class CloudflareWorkerSite extends CommonCloudflareConstruct {
|
|
23
23
|
props: CloudflareWorkerSiteProps;
|
|
24
|
-
siteZone:
|
|
24
|
+
siteZone: Zone;
|
|
25
25
|
siteWorkerScript: WorkersScript;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
siteWorkerDomain: WorkersCustomDomain;
|
|
27
|
+
siteRuleSet: Ruleset;
|
|
28
|
+
siteZoneSetting: ZoneSetting;
|
|
29
|
+
workerPlainTextBindingEnvironmentVariables: WorkersScriptBinding[];
|
|
30
|
+
workerSecretTextBindingEnvironmentVariables: WorkersScriptBinding[];
|
|
31
|
+
constructor(id: string, props: CloudflareWorkerSiteProps, options?: ComponentResourceOptions);
|
|
29
32
|
/**
|
|
30
33
|
* @summary Initialise and provision resources
|
|
31
34
|
*/
|
|
@@ -52,7 +55,7 @@ export declare class CloudflareWorkerSite extends CommonCloudflareConstruct {
|
|
|
52
55
|
* @param secretKey the secret key
|
|
53
56
|
* @returns the secret value
|
|
54
57
|
*/
|
|
55
|
-
protected resolveSecretFromAWS(secretName: string, secretKey: string
|
|
58
|
+
protected resolveSecretFromAWS(secretName: string, secretKey: string): import("@pulumi/pulumi").Output<std.JsondecodeResult> | undefined;
|
|
56
59
|
/**
|
|
57
60
|
* @summary Resolve secrets from Azure Key Vault
|
|
58
61
|
*
|
|
@@ -61,7 +64,7 @@ export declare class CloudflareWorkerSite extends CommonCloudflareConstruct {
|
|
|
61
64
|
* @param secretKey the secret key
|
|
62
65
|
* @returns the secret value
|
|
63
66
|
*/
|
|
64
|
-
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string
|
|
67
|
+
protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string): import("@pulumi/pulumi").OutputInstance<string | undefined> | undefined;
|
|
65
68
|
/**
|
|
66
69
|
* @summary Create the rules
|
|
67
70
|
*/
|