@gradientedge/cdk-utils 9.88.0 → 10.0.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/azure/services/api-management/main.d.ts +2 -2
- package/dist/src/lib/azure/services/api-management/main.js +1 -1
- package/dist/src/lib/azure/services/redis/main.d.ts +5 -5
- package/dist/src/lib/azure/services/redis/main.js +10 -10
- package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
- 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 +7 -1
- package/src/lib/azure/services/api-management/main.ts +3 -3
- package/src/lib/azure/services/redis/main.ts +11 -11
- package/src/lib/azure/services/redis/types.ts +2 -2
- 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
|
@@ -4,7 +4,7 @@ import { ApiManagementCustomDomain } from '@cdktf/provider-azurerm/lib/api-manag
|
|
|
4
4
|
import { ApiManagementLoggerApplicationInsights } from '@cdktf/provider-azurerm/lib/api-management-logger/index.js';
|
|
5
5
|
import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management/index.js';
|
|
6
6
|
import { DataAzurermApiManagement, DataAzurermApiManagementConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
|
|
8
8
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
9
9
|
import { ApiManagementApiProps, ApiManagementBackendProps, ApiManagementCustomDomainProps, ApiManagementProps } from './types.js';
|
|
10
10
|
/**
|
|
@@ -32,7 +32,7 @@ export declare class AzureApiManagementManager {
|
|
|
32
32
|
* @param props api management properties
|
|
33
33
|
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
34
34
|
*/
|
|
35
|
-
createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey'], externalRedisCache?:
|
|
35
|
+
createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps, applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey'], externalRedisCache?: ManagedRedis): ApiManagement;
|
|
36
36
|
/**
|
|
37
37
|
* @summary Method to resolve an api management
|
|
38
38
|
* @param id scoped id of the resource
|
|
@@ -67,7 +67,7 @@ export class AzureApiManagementManager {
|
|
|
67
67
|
new ApiManagementRedisCache(scope, `${id}-am-redis-cache`, {
|
|
68
68
|
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementRedisCache),
|
|
69
69
|
apiManagementId: apiManagement.id,
|
|
70
|
-
connectionString: externalRedisCache.
|
|
70
|
+
connectionString: `${externalRedisCache.name}:10000,password=${externalRedisCache.defaultDatabase.primaryAccessKey},ssl=True,abortConnect=False`,
|
|
71
71
|
cacheLocation: externalRedisCache.location,
|
|
72
72
|
redisCacheId: externalRedisCache.id,
|
|
73
73
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
|
|
2
2
|
import { CommonAzureConstruct } from '../../common/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ManagedRedisProps } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc Provides operations on Azure Redis
|
|
6
6
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -13,7 +13,7 @@ import { RedisCacheProps } from './types.js';
|
|
|
13
13
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
14
14
|
* super(parent, id, props)
|
|
15
15
|
* this.props = props
|
|
16
|
-
* this.redisManager.createRedis('
|
|
16
|
+
* this.redisManager.createRedis('MyManagedRedis', this, props)
|
|
17
17
|
* }
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
@@ -24,7 +24,7 @@ export declare class AzureRedisManager {
|
|
|
24
24
|
* @param id scoped id of the resource
|
|
25
25
|
* @param scope scope in which this resource is defined
|
|
26
26
|
* @param props redis cache properties
|
|
27
|
-
* @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/
|
|
27
|
+
* @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md}
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
createManagedRedis(id: string, scope: CommonAzureConstruct, props: ManagedRedisProps): ManagedRedis;
|
|
30
30
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
|
|
3
3
|
import { createAzureTfOutput } from '../../utils/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc Provides operations on Azure Redis
|
|
@@ -13,7 +13,7 @@ import { createAzureTfOutput } from '../../utils/index.js';
|
|
|
13
13
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
14
14
|
* super(parent, id, props)
|
|
15
15
|
* this.props = props
|
|
16
|
-
* this.redisManager.createRedis('
|
|
16
|
+
* this.redisManager.createRedis('MyManagedRedis', this, props)
|
|
17
17
|
* }
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
@@ -24,9 +24,9 @@ export class AzureRedisManager {
|
|
|
24
24
|
* @param id scoped id of the resource
|
|
25
25
|
* @param scope scope in which this resource is defined
|
|
26
26
|
* @param props redis cache properties
|
|
27
|
-
* @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/
|
|
27
|
+
* @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md}
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
createManagedRedis(id, scope, props) {
|
|
30
30
|
if (!props)
|
|
31
31
|
throw `Props undefined for ${id}`;
|
|
32
32
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-rc-rg`, {
|
|
@@ -36,18 +36,18 @@ export class AzureRedisManager {
|
|
|
36
36
|
});
|
|
37
37
|
if (!resourceGroup)
|
|
38
38
|
throw `Resource group undefined for ${id}`;
|
|
39
|
-
const
|
|
39
|
+
const managedRedis = new ManagedRedis(scope, `${id}-rc`, {
|
|
40
40
|
...props,
|
|
41
|
-
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.
|
|
41
|
+
name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.managedRedis),
|
|
42
42
|
location: resourceGroup.location,
|
|
43
43
|
resourceGroupName: resourceGroup.name,
|
|
44
44
|
tags: props.tags ?? {
|
|
45
45
|
environment: scope.props.stage,
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
|
-
createAzureTfOutput(`${id}-
|
|
49
|
-
createAzureTfOutput(`${id}-
|
|
50
|
-
createAzureTfOutput(`${id}-
|
|
51
|
-
return
|
|
48
|
+
createAzureTfOutput(`${id}-managedRedisName`, scope, managedRedis.name);
|
|
49
|
+
createAzureTfOutput(`${id}-managedRedisFriendlyUniqueId`, scope, managedRedis.friendlyUniqueId);
|
|
50
|
+
createAzureTfOutput(`${id}-managedRedisId`, scope, managedRedis.id);
|
|
51
|
+
return managedRedis;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
1
|
+
import { ManagedRedisConfig } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
|
|
2
|
+
export interface ManagedRedisProps extends ManagedRedisConfig {
|
|
3
3
|
}
|
|
@@ -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
|
*/
|