@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.
Files changed (87) hide show
  1. package/dist/src/lib/azure/services/api-management/main.d.ts +2 -2
  2. package/dist/src/lib/azure/services/api-management/main.js +1 -1
  3. package/dist/src/lib/azure/services/redis/main.d.ts +5 -5
  4. package/dist/src/lib/azure/services/redis/main.js +10 -10
  5. package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
  6. package/dist/src/lib/cloudflare/common/construct.d.ts +7 -19
  7. package/dist/src/lib/cloudflare/common/construct.js +12 -66
  8. package/dist/src/lib/cloudflare/common/index.d.ts +0 -1
  9. package/dist/src/lib/cloudflare/common/index.js +0 -1
  10. package/dist/src/lib/cloudflare/common/stack.d.ts +11 -21
  11. package/dist/src/lib/cloudflare/common/stack.js +55 -62
  12. package/dist/src/lib/cloudflare/common/types.d.ts +2 -14
  13. package/dist/src/lib/cloudflare/construct/pages-static-site/main.d.ts +8 -10
  14. package/dist/src/lib/cloudflare/construct/pages-static-site/main.js +18 -25
  15. package/dist/src/lib/cloudflare/construct/worker-site/main.d.ts +13 -10
  16. package/dist/src/lib/cloudflare/construct/worker-site/main.js +29 -41
  17. package/dist/src/lib/cloudflare/index.d.ts +0 -1
  18. package/dist/src/lib/cloudflare/index.js +0 -1
  19. package/dist/src/lib/cloudflare/services/access/main.d.ts +31 -43
  20. package/dist/src/lib/cloudflare/services/access/main.js +56 -83
  21. package/dist/src/lib/cloudflare/services/access/types.d.ts +12 -22
  22. package/dist/src/lib/cloudflare/services/api-shield/main.d.ts +10 -15
  23. package/dist/src/lib/cloudflare/services/api-shield/main.js +16 -36
  24. package/dist/src/lib/cloudflare/services/api-shield/types.d.ts +6 -10
  25. package/dist/src/lib/cloudflare/services/argo/main.d.ts +6 -8
  26. package/dist/src/lib/cloudflare/services/argo/main.js +9 -17
  27. package/dist/src/lib/cloudflare/services/argo/types.d.ts +3 -4
  28. package/dist/src/lib/cloudflare/services/filter/main.d.ts +3 -4
  29. package/dist/src/lib/cloudflare/services/filter/main.js +6 -10
  30. package/dist/src/lib/cloudflare/services/filter/types.d.ts +2 -2
  31. package/dist/src/lib/cloudflare/services/firewall/main.d.ts +2 -3
  32. package/dist/src/lib/cloudflare/services/firewall/main.js +4 -8
  33. package/dist/src/lib/cloudflare/services/firewall/types.d.ts +2 -2
  34. package/dist/src/lib/cloudflare/services/page/main.d.ts +7 -11
  35. package/dist/src/lib/cloudflare/services/page/main.js +13 -26
  36. package/dist/src/lib/cloudflare/services/page/types.d.ts +4 -6
  37. package/dist/src/lib/cloudflare/services/record/main.d.ts +2 -3
  38. package/dist/src/lib/cloudflare/services/record/main.js +4 -8
  39. package/dist/src/lib/cloudflare/services/record/types.d.ts +2 -2
  40. package/dist/src/lib/cloudflare/services/rule-set/main.d.ts +5 -6
  41. package/dist/src/lib/cloudflare/services/rule-set/main.js +7 -10
  42. package/dist/src/lib/cloudflare/services/rule-set/types.d.ts +2 -2
  43. package/dist/src/lib/cloudflare/services/worker/main.d.ts +12 -18
  44. package/dist/src/lib/cloudflare/services/worker/main.js +15 -39
  45. package/dist/src/lib/cloudflare/services/worker/types.d.ts +7 -12
  46. package/dist/src/lib/cloudflare/services/zone/main.d.ts +13 -30
  47. package/dist/src/lib/cloudflare/services/zone/main.js +31 -84
  48. package/dist/src/lib/cloudflare/services/zone/types.d.ts +10 -20
  49. package/dist/src/lib/common/types.d.ts +4 -0
  50. package/package.json +7 -1
  51. package/src/lib/azure/services/api-management/main.ts +3 -3
  52. package/src/lib/azure/services/redis/main.ts +11 -11
  53. package/src/lib/azure/services/redis/types.ts +2 -2
  54. package/src/lib/cloudflare/common/construct.ts +13 -70
  55. package/src/lib/cloudflare/common/index.ts +0 -1
  56. package/src/lib/cloudflare/common/stack.ts +58 -69
  57. package/src/lib/cloudflare/common/types.ts +2 -15
  58. package/src/lib/cloudflare/construct/pages-static-site/main.ts +22 -42
  59. package/src/lib/cloudflare/construct/worker-site/main.ts +38 -62
  60. package/src/lib/cloudflare/index.ts +0 -1
  61. package/src/lib/cloudflare/services/access/main.ts +57 -118
  62. package/src/lib/cloudflare/services/access/types.ts +24 -22
  63. package/src/lib/cloudflare/services/api-shield/main.ts +16 -63
  64. package/src/lib/cloudflare/services/api-shield/types.ts +12 -10
  65. package/src/lib/cloudflare/services/argo/main.ts +9 -23
  66. package/src/lib/cloudflare/services/argo/types.ts +3 -4
  67. package/src/lib/cloudflare/services/filter/main.ts +6 -13
  68. package/src/lib/cloudflare/services/filter/types.ts +2 -2
  69. package/src/lib/cloudflare/services/firewall/main.ts +4 -11
  70. package/src/lib/cloudflare/services/firewall/types.ts +2 -2
  71. package/src/lib/cloudflare/services/page/main.ts +19 -36
  72. package/src/lib/cloudflare/services/page/types.ts +4 -6
  73. package/src/lib/cloudflare/services/record/main.ts +4 -11
  74. package/src/lib/cloudflare/services/record/types.ts +2 -2
  75. package/src/lib/cloudflare/services/rule-set/main.ts +7 -12
  76. package/src/lib/cloudflare/services/rule-set/types.ts +2 -2
  77. package/src/lib/cloudflare/services/worker/main.ts +15 -52
  78. package/src/lib/cloudflare/services/worker/types.ts +14 -12
  79. package/src/lib/cloudflare/services/zone/main.ts +40 -103
  80. package/src/lib/cloudflare/services/zone/types.ts +20 -21
  81. package/src/lib/common/types.ts +5 -0
  82. package/dist/src/lib/cloudflare/common/constants.d.ts +0 -5
  83. package/dist/src/lib/cloudflare/common/constants.js +0 -6
  84. package/dist/src/lib/cloudflare/utils/index.d.ts +0 -3
  85. package/dist/src/lib/cloudflare/utils/index.js +0 -13
  86. package/src/lib/cloudflare/common/constants.ts +0 -5
  87. 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 { RedisCache } from '@cdktf/provider-azurerm/lib/redis-cache/index.js';
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?: RedisCache): ApiManagement;
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.primaryConnectionString,
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 { RedisCache } from '@cdktf/provider-azurerm/lib/redis-cache/index.js';
1
+ import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js';
2
2
  import { CommonAzureConstruct } from '../../common/index.js';
3
- import { RedisCacheProps } from './types.js';
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('MyRedisCache', this, props)
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/redisCache.typescript.md}
27
+ * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md}
28
28
  */
29
- createRedisCache(id: string, scope: CommonAzureConstruct, props: RedisCacheProps): RedisCache;
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 { RedisCache } from '@cdktf/provider-azurerm/lib/redis-cache/index.js';
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('MyRedisCache', this, props)
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/redisCache.typescript.md}
27
+ * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md}
28
28
  */
29
- createRedisCache(id, scope, props) {
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 redisCache = new RedisCache(scope, `${id}-rc`, {
39
+ const managedRedis = new ManagedRedis(scope, `${id}-rc`, {
40
40
  ...props,
41
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.redisCache),
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}-redisCacheName`, scope, redisCache.name);
49
- createAzureTfOutput(`${id}-redisCacheFriendlyUniqueId`, scope, redisCache.friendlyUniqueId);
50
- createAzureTfOutput(`${id}-redisCacheId`, scope, redisCache.id);
51
- return redisCache;
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 { RedisCacheConfig } from '@cdktf/provider-azurerm/lib/redis-cache/index.js';
2
- export interface RedisCacheProps extends RedisCacheConfig {
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 { AwsProvider } from '@cdktf/provider-aws/lib/provider/index.js';
2
- import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider/index.js';
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 TerraformStack {
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
- awsProvider: AwsProvider;
22
- s3Backend: S3Backend;
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 { AwsProvider } from '@cdktf/provider-aws/lib/provider/index.js';
2
- import { CloudflareProvider } from '@cdktf/provider-cloudflare/lib/provider/index.js';
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
- import { RemoteBackend } from './constants.js';
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
- awsProvider;
22
- s3Backend;
23
- azurermProvider;
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.id = id;
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.determineAccountId();
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,4 +1,3 @@
1
- export * from './constants.js';
2
1
  export * from './construct.js';
3
2
  export * from './stack.js';
4
3
  export * from './types.js';
@@ -1,4 +1,3 @@
1
- export * from './constants.js';
2
1
  export * from './construct.js';
3
2
  export * from './stack.js';
4
3
  export * from './types.js';
@@ -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 TerraformStack {
16
+ export declare class CommonCloudflareStack extends ComponentResource {
18
17
  construct: CommonCloudflareConstruct;
19
18
  props: CommonCloudflareStackProps;
20
- constructor(parent: Construct, name: string, props: CommonCloudflareStackProps);
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 cdktf.json
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 cdktf.json
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(): void;
32
+ protected determineExtraContexts(props: CommonCloudflareStackProps): Record<string, any>;
43
33
  /**
44
- * @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
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(): void;
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(): any;
42
+ protected fullyQualifiedDomain(): string;
53
43
  }
@@ -1,6 +1,6 @@
1
- import fs from 'fs';
1
+ import { ComponentResource, Config } from '@pulumi/pulumi';
2
2
  import appRoot from 'app-root-path';
3
- import { TerraformStack } from 'cdktf';
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 TerraformStack {
19
+ export class CommonCloudflareStack extends ComponentResource {
20
20
  construct;
21
21
  props;
22
- constructor(parent, name, props) {
23
- super(parent, name);
24
- /* determine extra cdk contexts */
25
- this.determineExtraContexts();
26
- /* determine extra cdk stage contexts */
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 cdktf.json
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
- const stage = this.node.tryGetContext('stage');
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: this.node.tryGetContext('accountId'),
39
- apiToken: this.node.tryGetContext('apiToken'),
40
- domainName: this.node.tryGetContext('domainName'),
41
- extraContexts: this.node.tryGetContext('extraContexts'),
42
- features: this.node.tryGetContext('features'),
43
- name: this.node.tryGetContext('resourceGroupName'),
44
- skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
45
- stage: stage,
46
- subDomain: this.node.tryGetContext('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 cdktf.json
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
- const extraContexts = this.node.tryGetContext('extraContexts');
56
- const debug = this.node.tryGetContext('debug');
57
- if (!extraContexts) {
58
- if (debug)
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
- _.forEach(extraContexts, (context) => {
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
- const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'));
73
- /* set each of the property into the cdk node context */
74
- _.keys(extraContextProps).forEach((propKey) => {
75
- this.node.setContext(propKey, extraContextProps[propKey]);
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 cdktf.json
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 stage = process.env.STAGE ?? this.node.tryGetContext('stage');
86
- const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv';
87
- const stageContextFilePath = path.join(appRoot.path, stageContextPath, `${stage}.json`);
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
- const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'));
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.node.tryGetContext('domainName');
124
- const subDomain = this.node.tryGetContext('subDomain');
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, CloudflareProviderConfig {
4
+ export interface CommonCloudflareStackProps extends BaseProps {
17
5
  accountId: string;
18
6
  apiToken: string;
19
- remoteBackend?: RemoteBackendProps;
7
+ resourceGroupName?: string;
20
8
  useExistingZone?: boolean;
21
9
  }
@@ -1,9 +1,7 @@
1
- import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone/index.js';
2
- import { DnsRecord } from '@cdktf/provider-cloudflare/lib/dns-record/index.js';
3
- import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain/index.js';
4
- import { PagesProject, PagesProjectDeploymentConfigsPreviewEnvVars, PagesProjectDeploymentConfigsProductionEnvVars } from '@cdktf/provider-cloudflare/lib/pages-project/index.js';
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: DataCloudflareZone | Zone;
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(parent: Construct, id: string, props: CloudflarePagesStaticSiteProps);
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): any;
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
  */