@gradientedge/cdk-utils 9.89.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 (79) hide show
  1. package/dist/src/lib/cloudflare/common/construct.d.ts +7 -19
  2. package/dist/src/lib/cloudflare/common/construct.js +12 -66
  3. package/dist/src/lib/cloudflare/common/index.d.ts +0 -1
  4. package/dist/src/lib/cloudflare/common/index.js +0 -1
  5. package/dist/src/lib/cloudflare/common/stack.d.ts +11 -21
  6. package/dist/src/lib/cloudflare/common/stack.js +55 -62
  7. package/dist/src/lib/cloudflare/common/types.d.ts +2 -14
  8. package/dist/src/lib/cloudflare/construct/pages-static-site/main.d.ts +8 -10
  9. package/dist/src/lib/cloudflare/construct/pages-static-site/main.js +18 -25
  10. package/dist/src/lib/cloudflare/construct/worker-site/main.d.ts +13 -10
  11. package/dist/src/lib/cloudflare/construct/worker-site/main.js +29 -41
  12. package/dist/src/lib/cloudflare/index.d.ts +0 -1
  13. package/dist/src/lib/cloudflare/index.js +0 -1
  14. package/dist/src/lib/cloudflare/services/access/main.d.ts +31 -43
  15. package/dist/src/lib/cloudflare/services/access/main.js +56 -83
  16. package/dist/src/lib/cloudflare/services/access/types.d.ts +12 -22
  17. package/dist/src/lib/cloudflare/services/api-shield/main.d.ts +10 -15
  18. package/dist/src/lib/cloudflare/services/api-shield/main.js +16 -36
  19. package/dist/src/lib/cloudflare/services/api-shield/types.d.ts +6 -10
  20. package/dist/src/lib/cloudflare/services/argo/main.d.ts +6 -8
  21. package/dist/src/lib/cloudflare/services/argo/main.js +9 -17
  22. package/dist/src/lib/cloudflare/services/argo/types.d.ts +3 -4
  23. package/dist/src/lib/cloudflare/services/filter/main.d.ts +3 -4
  24. package/dist/src/lib/cloudflare/services/filter/main.js +6 -10
  25. package/dist/src/lib/cloudflare/services/filter/types.d.ts +2 -2
  26. package/dist/src/lib/cloudflare/services/firewall/main.d.ts +2 -3
  27. package/dist/src/lib/cloudflare/services/firewall/main.js +4 -8
  28. package/dist/src/lib/cloudflare/services/firewall/types.d.ts +2 -2
  29. package/dist/src/lib/cloudflare/services/page/main.d.ts +7 -11
  30. package/dist/src/lib/cloudflare/services/page/main.js +13 -26
  31. package/dist/src/lib/cloudflare/services/page/types.d.ts +4 -6
  32. package/dist/src/lib/cloudflare/services/record/main.d.ts +2 -3
  33. package/dist/src/lib/cloudflare/services/record/main.js +4 -8
  34. package/dist/src/lib/cloudflare/services/record/types.d.ts +2 -2
  35. package/dist/src/lib/cloudflare/services/rule-set/main.d.ts +5 -6
  36. package/dist/src/lib/cloudflare/services/rule-set/main.js +7 -10
  37. package/dist/src/lib/cloudflare/services/rule-set/types.d.ts +2 -2
  38. package/dist/src/lib/cloudflare/services/worker/main.d.ts +12 -18
  39. package/dist/src/lib/cloudflare/services/worker/main.js +15 -39
  40. package/dist/src/lib/cloudflare/services/worker/types.d.ts +7 -12
  41. package/dist/src/lib/cloudflare/services/zone/main.d.ts +13 -30
  42. package/dist/src/lib/cloudflare/services/zone/main.js +31 -84
  43. package/dist/src/lib/cloudflare/services/zone/types.d.ts +10 -20
  44. package/dist/src/lib/common/types.d.ts +4 -0
  45. package/package.json +7 -1
  46. package/src/lib/cloudflare/common/construct.ts +13 -70
  47. package/src/lib/cloudflare/common/index.ts +0 -1
  48. package/src/lib/cloudflare/common/stack.ts +58 -69
  49. package/src/lib/cloudflare/common/types.ts +2 -15
  50. package/src/lib/cloudflare/construct/pages-static-site/main.ts +22 -42
  51. package/src/lib/cloudflare/construct/worker-site/main.ts +38 -62
  52. package/src/lib/cloudflare/index.ts +0 -1
  53. package/src/lib/cloudflare/services/access/main.ts +57 -118
  54. package/src/lib/cloudflare/services/access/types.ts +24 -22
  55. package/src/lib/cloudflare/services/api-shield/main.ts +16 -63
  56. package/src/lib/cloudflare/services/api-shield/types.ts +12 -10
  57. package/src/lib/cloudflare/services/argo/main.ts +9 -23
  58. package/src/lib/cloudflare/services/argo/types.ts +3 -4
  59. package/src/lib/cloudflare/services/filter/main.ts +6 -13
  60. package/src/lib/cloudflare/services/filter/types.ts +2 -2
  61. package/src/lib/cloudflare/services/firewall/main.ts +4 -11
  62. package/src/lib/cloudflare/services/firewall/types.ts +2 -2
  63. package/src/lib/cloudflare/services/page/main.ts +19 -36
  64. package/src/lib/cloudflare/services/page/types.ts +4 -6
  65. package/src/lib/cloudflare/services/record/main.ts +4 -11
  66. package/src/lib/cloudflare/services/record/types.ts +2 -2
  67. package/src/lib/cloudflare/services/rule-set/main.ts +7 -12
  68. package/src/lib/cloudflare/services/rule-set/types.ts +2 -2
  69. package/src/lib/cloudflare/services/worker/main.ts +15 -52
  70. package/src/lib/cloudflare/services/worker/types.ts +14 -12
  71. package/src/lib/cloudflare/services/zone/main.ts +40 -103
  72. package/src/lib/cloudflare/services/zone/types.ts +20 -21
  73. package/src/lib/common/types.ts +5 -0
  74. package/dist/src/lib/cloudflare/common/constants.d.ts +0 -5
  75. package/dist/src/lib/cloudflare/common/constants.js +0 -6
  76. package/dist/src/lib/cloudflare/utils/index.d.ts +0 -3
  77. package/dist/src/lib/cloudflare/utils/index.js +0 -13
  78. package/src/lib/cloudflare/common/constants.ts +0 -5
  79. package/src/lib/cloudflare/utils/index.ts +0 -23
@@ -1,23 +1,15 @@
1
- import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone/index.js';
2
- import { ZoneCacheReserve } from '@cdktf/provider-cloudflare/lib/zone-cache-reserve/index.js';
3
- import { ZoneCacheVariants } from '@cdktf/provider-cloudflare/lib/zone-cache-variants/index.js';
4
- import { ZoneDnsSettings } from '@cdktf/provider-cloudflare/lib/zone-dns-settings/index.js';
5
- import { ZoneDnssec } from '@cdktf/provider-cloudflare/lib/zone-dnssec/index.js';
6
- import { ZoneHold } from '@cdktf/provider-cloudflare/lib/zone-hold/index.js';
7
- import { ZoneLockdown } from '@cdktf/provider-cloudflare/lib/zone-lockdown/index.js';
8
- import { ZoneSetting } from '@cdktf/provider-cloudflare/lib/zone-setting/index.js';
9
- import { Zone } from '@cdktf/provider-cloudflare/lib/zone/index.js';
10
- import { createCloudflareTfOutput } from '../../utils/index.js';
1
+ import * as cloudflare from '@pulumi/cloudflare';
2
+ import * as pulumi from '@pulumi/pulumi';
11
3
  /**
12
- * @classdesc Provides operations on Cloudflare Zone
4
+ * @classdesc Provides operations on Cloudflare Zone using Pulumi
13
5
  * - A new instance of this class is injected into {@link CommonCloudflareConstruct} constructor.
14
6
  * - If a custom construct extends {@link CommonCloudflareConstruct}, an instance is available within the context.
15
7
  * @example
16
8
  * ```
17
- * import { CommonCloudflareConstruct, CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
9
+ * import { CommonCloudflareConstruct } from '@gradientedge/cdk-utils'
18
10
  *
19
11
  * class CustomConstruct extends CommonCloudflareConstruct {
20
- * constructor(parent: Construct, id: string, props: CommonCloudflareStackProps) {
12
+ * constructor(parent: pulumi.ComponentResource, id: string, props: CommonCloudflareStackProps) {
21
13
  * super(parent, id, props)
22
14
  * this.props = props
23
15
  * this.zoneManager.createZone('MyZone', this, props)
@@ -31,155 +23,115 @@ export class CloudflareZoneManager {
31
23
  * @param id scoped id of the resource
32
24
  * @param scope scope in which this resource is defined
33
25
  * @param props zone properties
34
- * @see [CDKTF Zone Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zone.typescript.md}
35
26
  */
36
27
  createZone(id, scope, props) {
37
28
  if (!props)
38
29
  throw `Props undefined for ${id}`;
39
- const zone = new Zone(scope, `${id}`, {
30
+ return new cloudflare.Zone(id, {
40
31
  ...props,
41
- account: {
42
- id: props.account.id ?? scope.props.accountId,
43
- },
44
- name: props.name ?? scope.props.domainName,
32
+ account: props.account ?? scope.props.accountId,
33
+ name: scope.props.domainName,
45
34
  });
46
- createCloudflareTfOutput(`${id}-zoneName`, scope, zone.name);
47
- createCloudflareTfOutput(`${id}-zoneFriendlyUniqueId`, scope, zone.friendlyUniqueId);
48
- createCloudflareTfOutput(`${id}-zoneId`, scope, zone.id);
49
- return zone;
50
35
  }
51
36
  resolveZone(id, scope, options) {
52
- const zone = new DataCloudflareZone(scope, `${id}-data-zone`, {
53
- filter: {
54
- name: options?.name ?? scope.props.domainName,
55
- },
56
- zoneId: options?.zoneId,
57
- });
58
- return zone;
37
+ const name = options?.filter?.name ?? scope.props.domainName;
38
+ return cloudflare.Zone.get(name, id);
59
39
  }
60
40
  /**
61
41
  * @summary Method to create a new zone cache reserve
62
42
  * @param id scoped id of the resource
63
43
  * @param scope scope in which this resource is defined
64
44
  * @param props zone cache reserve properties
65
- * @see [CDKTF Zone Cache Reserve Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneCacheReserve.typescript.md}
66
45
  */
67
46
  createZoneCacheReserve(id, scope, props) {
68
47
  if (!props)
69
48
  throw `Props undefined for ${id}`;
70
- const zoneId = props.zoneId
71
- ? props.zoneId
72
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
73
- const zoneCacheReserve = new ZoneCacheReserve(scope, `${id}`, {
49
+ const zoneId = props.zoneId ??
50
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
51
+ return new cloudflare.ZoneCacheReserve(id, {
74
52
  ...props,
75
53
  zoneId,
76
54
  });
77
- createCloudflareTfOutput(`${id}-zoneCacheReserveFriendlyUniqueId`, scope, zoneCacheReserve.friendlyUniqueId);
78
- createCloudflareTfOutput(`${id}-zoneCacheReserveId`, scope, zoneCacheReserve.id);
79
- return zoneCacheReserve;
80
55
  }
81
56
  /**
82
57
  * @summary Method to create a new zone cache variants
83
58
  * @param id scoped id of the resource
84
59
  * @param scope scope in which this resource is defined
85
60
  * @param props zone cache variants properties
86
- * @see [CDKTF Zone Cache Variants Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneCacheVariants.typescript.md}
87
61
  */
88
62
  createZoneCacheVariants(id, scope, props) {
89
63
  if (!props)
90
64
  throw `Props undefined for ${id}`;
91
- const zoneId = props.zoneId
92
- ? props.zoneId
93
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
94
- const zoneCacheVariants = new ZoneCacheVariants(scope, `${id}`, {
65
+ const zoneId = props.zoneId ??
66
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
67
+ return new cloudflare.ZoneCacheVariants(id, {
95
68
  ...props,
96
69
  zoneId,
97
70
  });
98
- createCloudflareTfOutput(`${id}-zoneCacheVariantsFriendlyUniqueId`, scope, zoneCacheVariants.friendlyUniqueId);
99
- createCloudflareTfOutput(`${id}-zoneCacheVariantsId`, scope, zoneCacheVariants.id);
100
- return zoneCacheVariants;
101
71
  }
102
72
  /**
103
73
  * @summary Method to create a new zone dnssec
104
74
  * @param id scoped id of the resource
105
75
  * @param scope scope in which this resource is defined
106
76
  * @param props zone dnssec properties
107
- * @see [CDKTF Zone DNS Security Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneDnssec.typescript.md}
108
77
  */
109
78
  createZoneDnssec(id, scope, props) {
110
79
  if (!props)
111
80
  throw `Props undefined for ${id}`;
112
- const zoneId = props.zoneId
113
- ? props.zoneId
114
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
115
- const zoneDnssec = new ZoneDnssec(scope, `${id}`, {
81
+ const zoneId = props.zoneId ??
82
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
83
+ return new cloudflare.ZoneDnssec(id, {
116
84
  ...props,
117
85
  zoneId,
118
86
  });
119
- createCloudflareTfOutput(`${id}-zoneDnssecFriendlyUniqueId`, scope, zoneDnssec.friendlyUniqueId);
120
- createCloudflareTfOutput(`${id}-zoneDnssecId`, scope, zoneDnssec.id);
121
- return zoneDnssec;
122
87
  }
123
88
  /**
124
89
  * @summary Method to create a new zone hold
125
90
  * @param id scoped id of the resource
126
91
  * @param scope scope in which this resource is defined
127
92
  * @param props zone hold properties
128
- * @see [CDKTF Zone Hold Security Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneHold.typescript.md}
129
93
  */
130
94
  createZoneHold(id, scope, props) {
131
95
  if (!props)
132
96
  throw `Props undefined for ${id}`;
133
- const zoneId = props.zoneId
134
- ? props.zoneId
135
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
136
- const zoneHold = new ZoneHold(scope, `${id}`, {
97
+ const zoneId = props.zoneId ??
98
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
99
+ return new cloudflare.ZoneHold(id, {
137
100
  ...props,
138
101
  zoneId,
139
102
  });
140
- createCloudflareTfOutput(`${id}-zoneHoldFriendlyUniqueId`, scope, zoneHold.friendlyUniqueId);
141
- createCloudflareTfOutput(`${id}-zoneHoldId`, scope, zoneHold.id);
142
- return zoneHold;
143
103
  }
144
104
  /**
145
105
  * @summary Method to create a new zone lockdown
146
106
  * @param id scoped id of the resource
147
107
  * @param scope scope in which this resource is defined
148
108
  * @param props zone lockdown properties
149
- * @see [CDKTF Zone Lockdown Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneLockdown.typescript.md}
150
109
  */
151
110
  createZoneLockdown(id, scope, props) {
152
111
  if (!props)
153
112
  throw `Props undefined for ${id}`;
154
- const zoneId = props.zoneId
155
- ? props.zoneId
156
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
157
- const zoneLockdown = new ZoneLockdown(scope, `${id}`, {
113
+ const zoneId = props.zoneId ??
114
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
115
+ return new cloudflare.ZoneLockdown(id, {
158
116
  ...props,
159
117
  zoneId,
160
118
  });
161
- createCloudflareTfOutput(`${id}-zoneLockdownFriendlyUniqueId`, scope, zoneLockdown.friendlyUniqueId);
162
- createCloudflareTfOutput(`${id}-zoneLockdownId`, scope, zoneLockdown.id);
163
- return zoneLockdown;
164
119
  }
165
120
  /**
166
121
  * @summary Method to create new zone dns settings
167
122
  * @param id scoped id of the resource
168
123
  * @param scope scope in which this resource is defined
169
124
  * @param props zone dns settings properties
170
- * @see [CDKTF Zone Dns Settings Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/dnsZoneSettings.typescript.md}
171
125
  */
172
126
  createZoneDnsSettings(id, scope, props) {
173
127
  if (!props)
174
128
  throw `Props undefined for ${id}`;
175
- const zoneId = props.zoneId
176
- ? props.zoneId
177
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
178
- const zoneDnsSettings = new ZoneDnsSettings(scope, `${id}`, {
129
+ const zoneId = props.zoneId ??
130
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
131
+ const zoneDnsSettings = new cloudflare.ZoneSetting(id, {
179
132
  ...props,
180
133
  zoneId,
181
134
  });
182
- createCloudflareTfOutput(`${id}-zoneDnsSettingsFriendlyUniqueId`, scope, zoneDnsSettings.friendlyUniqueId);
183
135
  return zoneDnsSettings;
184
136
  }
185
137
  /**
@@ -187,20 +139,15 @@ export class CloudflareZoneManager {
187
139
  * @param id scoped id of the resource
188
140
  * @param scope scope in which this resource is defined
189
141
  * @param props zone setting properties
190
- * @see [CDKTF Zone Setting Module]{@link https://github.com/cdktf/cdktf-provider-cloudflare/blob/main/docs/zoneSetting.typescript.md}
191
142
  */
192
143
  createZoneSetting(id, scope, props) {
193
144
  if (!props)
194
145
  throw `Props undefined for ${id}`;
195
- const zoneId = props.zoneId
196
- ? props.zoneId
197
- : this.resolveZone(`${id}-data-zone`, scope, { name: scope.props.domainName })?.id;
198
- const zoneSetting = new ZoneSetting(scope, `${id}`, {
146
+ const zoneId = props.zoneId ??
147
+ pulumi.output(this.resolveZone(`${id}-data-zone`, scope, { filter: { name: scope.props.domainName } })).id;
148
+ return new cloudflare.ZoneSetting(id, {
199
149
  ...props,
200
150
  zoneId,
201
151
  });
202
- createCloudflareTfOutput(`${id}-zoneSettingFriendlyUniqueId`, scope, zoneSetting.friendlyUniqueId);
203
- createCloudflareTfOutput(`${id}-zoneSettingId`, scope, zoneSetting.id);
204
- return zoneSetting;
205
152
  }
206
153
  }
@@ -1,29 +1,19 @@
1
- import { ZoneConfig } from '@cdktf/provider-cloudflare/lib/zone/index.js';
2
- import { ZoneCacheReserveConfig } from '@cdktf/provider-cloudflare/lib/zone-cache-reserve/index.js';
3
- import { ZoneCacheVariantsConfig } from '@cdktf/provider-cloudflare/lib/zone-cache-variants/index.js';
4
- import { ZoneDnssecConfig } from '@cdktf/provider-cloudflare/lib/zone-dnssec/index.js';
5
- import { ZoneHoldConfig } from '@cdktf/provider-cloudflare/lib/zone-hold/index.js';
6
- import { ZoneLockdownConfig } from '@cdktf/provider-cloudflare/lib/zone-lockdown/index.js';
7
- import { ZoneSettingConfig } from '@cdktf/provider-cloudflare/lib/zone-setting/index.js';
8
- import { ZoneDnsSettingsConfig } from '@cdktf/provider-cloudflare/lib/zone-dns-settings/index.js';
9
- import { DataCloudflareZoneConfig } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone/index.js';
10
- export interface ZoneProps extends ZoneConfig {
1
+ import { GetZoneArgs, ZoneArgs, ZoneCacheReserveArgs, ZoneCacheVariantsArgs, ZoneDnssecArgs, ZoneDnsSettingsArgs, ZoneHoldArgs, ZoneLockdownArgs, ZoneSettingArgs } from '@pulumi/cloudflare';
2
+ export interface ZoneProps extends ZoneArgs {
11
3
  }
12
- export interface ZoneOptions extends DataCloudflareZoneConfig {
13
- id?: string;
14
- name?: string;
4
+ export interface GetZoneProps extends GetZoneArgs {
15
5
  }
16
- export interface ZoneCacheReserveProps extends ZoneCacheReserveConfig {
6
+ export interface ZoneCacheReserveProps extends ZoneCacheReserveArgs {
17
7
  }
18
- export interface ZoneCacheVariantsProps extends ZoneCacheVariantsConfig {
8
+ export interface ZoneCacheVariantsProps extends ZoneCacheVariantsArgs {
19
9
  }
20
- export interface ZoneDnssecProps extends ZoneDnssecConfig {
10
+ export interface ZoneDnssecProps extends ZoneDnssecArgs {
21
11
  }
22
- export interface ZoneHoldProps extends ZoneHoldConfig {
12
+ export interface ZoneHoldProps extends ZoneHoldArgs {
23
13
  }
24
- export interface ZoneLockdownProps extends ZoneLockdownConfig {
14
+ export interface ZoneLockdownProps extends ZoneLockdownArgs {
25
15
  }
26
- export interface ZoneSettingProps extends ZoneSettingConfig {
16
+ export interface ZoneSettingProps extends ZoneSettingArgs {
27
17
  }
28
- export interface ZoneDnsSettingsProps extends ZoneDnsSettingsConfig {
18
+ export interface ZoneDnsSettingsProps extends ZoneDnsSettingsArgs {
29
19
  }
@@ -1,4 +1,6 @@
1
+ import { ComponentResourceOptions } from '@pulumi/pulumi';
1
2
  export interface BaseProps {
3
+ debug?: boolean;
2
4
  domainName: string;
3
5
  extraContexts?: string[];
4
6
  name: string;
@@ -7,3 +9,5 @@ export interface BaseProps {
7
9
  stageContextPath?: string;
8
10
  subDomain?: string;
9
11
  }
12
+ export interface BaseOptions extends ComponentResourceOptions {
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.89.0",
3
+ "version": "10.0.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -61,6 +61,12 @@
61
61
  "@cdktf/provider-aws": "^21.22.1",
62
62
  "@cdktf/provider-azurerm": "^14.23.1",
63
63
  "@cdktf/provider-cloudflare": "^13.9.1",
64
+ "@pulumi/aws": "^7.14.0",
65
+ "@pulumi/azure-native": "^3.11.0",
66
+ "@pulumi/cloudflare": "^6.11.0",
67
+ "@pulumi/command": "^1.1.3",
68
+ "@pulumi/pulumi": "^3.213.0",
69
+ "@pulumi/std": "^2.2.0",
64
70
  "@types/lodash": "^4.17.21",
65
71
  "@types/node": "^25.0.3",
66
72
  "@types/uuid": "^11.0.0",
@@ -1,8 +1,5 @@
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'
5
- import { Construct } from 'constructs'
1
+ import { Provider as CloudflareProvider } from '@pulumi/cloudflare'
2
+ import { ComponentResource, ComponentResourceOptions, Config } from '@pulumi/pulumi'
6
3
  import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common/index.js'
7
4
  import {
8
5
  CloudflareAccessManager,
@@ -16,12 +13,13 @@ import {
16
13
  CloudflareWorkerManager,
17
14
  CloudflareZoneManager,
18
15
  } from '../services/index.js'
19
- import { RemoteBackend } from './constants.js'
20
16
  import { CommonCloudflareStackProps } from './types.js'
21
17
 
22
- export class CommonCloudflareConstruct extends TerraformStack {
18
+ export class CommonCloudflareConstruct extends ComponentResource {
23
19
  declare props: CommonCloudflareStackProps
20
+ declare options?: ComponentResourceOptions
24
21
  id: string
22
+ config: Config
25
23
  fullyQualifiedDomainName: string
26
24
  accessManager: CloudflareAccessManager
27
25
  apiShieldManager: CloudflareApiShieldManager
@@ -33,15 +31,13 @@ export class CommonCloudflareConstruct extends TerraformStack {
33
31
  ruleSetManager: CloudflareRuleSetManager
34
32
  workerManager: CloudflareWorkerManager
35
33
  zoneManager: CloudflareZoneManager
36
- awsProvider: AwsProvider
37
- s3Backend: S3Backend
38
- azurermProvider: AzurermProvider
39
- azurermBackend: AzurermBackend
34
+ provider: CloudflareProvider
40
35
 
41
- constructor(scope: Construct, id: string, props: CommonCloudflareStackProps) {
42
- super(scope, id)
36
+ constructor(name: string, props: CommonCloudflareStackProps, options?: ComponentResourceOptions) {
37
+ super(`custom:cloudflare:Construct:${name}`, name, props, options)
43
38
  this.props = props
44
- this.id = id
39
+ this.options = options
40
+ this.id = name
45
41
 
46
42
  this.accessManager = new CloudflareAccessManager()
47
43
  this.apiShieldManager = new CloudflareApiShieldManager()
@@ -54,11 +50,10 @@ export class CommonCloudflareConstruct extends TerraformStack {
54
50
  this.workerManager = new CloudflareWorkerManager()
55
51
  this.zoneManager = new CloudflareZoneManager()
56
52
 
53
+ /* initialise config */
54
+ this.config = new Config()
57
55
  this.determineFullyQualifiedDomain()
58
- this.determineAccountId()
59
- this.determineApiToken()
60
- this.determineRemoteBackend()
61
- new CloudflareProvider(this, `${this.id}-provider`, this.props)
56
+ this.provider = new CloudflareProvider(`${this.id}-provider`, this.props, options)
62
57
  }
63
58
 
64
59
  /**
@@ -70,58 +65,6 @@ export class CommonCloudflareConstruct extends TerraformStack {
70
65
  : this.props.domainName
71
66
  }
72
67
 
73
- /**
74
- * @summary Determine the account id based on the cdktf.json context
75
- */
76
- protected determineAccountId() {
77
- this.props.accountId = new TerraformVariable(this, `accountId`, {}).stringValue
78
- }
79
-
80
- /**
81
- * @summary Determine the api token based on the cdktf.json context
82
- */
83
- protected determineApiToken() {
84
- this.props.apiToken = new TerraformVariable(this, `apiToken`, {}).stringValue
85
- }
86
-
87
- protected determineRemoteBackend() {
88
- const debug = this.node.tryGetContext('debug')
89
-
90
- switch (this.props.remoteBackend?.type) {
91
- case RemoteBackend.s3:
92
- this.awsProvider = new AwsProvider(this, `${this.id}-aws-provider`, {
93
- profile: process.env.AWS_PROFILE,
94
- region: this.props.remoteBackend.region,
95
- })
96
- this.s3Backend = new S3Backend(this, {
97
- bucket: this.props.remoteBackend.bucketName,
98
- dynamodbTable: this.props.remoteBackend.tableName,
99
- key: `${this.id}`,
100
- profile: process.env.AWS_PROFILE,
101
- region: this.props.remoteBackend.region,
102
- })
103
- break
104
- case RemoteBackend.azurerm:
105
- this.azurermProvider = new AzurermProvider(this, `${this.id}-azurerm-provider`, {
106
- features: [{}],
107
- subscriptionId: this.props.remoteBackend.subscriptionId,
108
- })
109
- this.azurermBackend = new AzurermBackend(this, {
110
- storageAccountName: this.props.remoteBackend.storageAccountName,
111
- containerName: this.props.remoteBackend.containerName,
112
- key: `${this.id}`,
113
- subscriptionId: this.props.remoteBackend.subscriptionId,
114
- resourceGroupName: this.props.remoteBackend.resourceGroupName,
115
- })
116
- break
117
- case RemoteBackend.local:
118
- if (debug) console.debug(`Using local backend for ${this.id}`)
119
- break
120
- default:
121
- break
122
- }
123
- }
124
-
125
68
  /**
126
69
  * @summary Utility method to determine if the initialisation is in development (dev) stage
127
70
  * 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,13 +1,11 @@
1
- import fs from 'fs'
2
- import { CommonCloudflareConstruct } from './construct.js'
3
- import { CommonCloudflareStackProps } from './types.js'
4
-
1
+ import { ComponentResource, ComponentResourceOptions, Config } from '@pulumi/pulumi'
5
2
  import appRoot from 'app-root-path'
6
- import { TerraformStack } from 'cdktf'
7
- import { Construct } from 'constructs'
3
+ import fs from 'fs'
8
4
  import _ from 'lodash'
9
5
  import path from 'path'
10
6
  import { isDevStage } from '../../common/index.js'
7
+ import { CommonCloudflareConstruct } from './construct.js'
8
+ import { CommonCloudflareStackProps } from './types.js'
11
9
 
12
10
  /**
13
11
  * @classdesc Common stack to use as a base for all higher level constructs.
@@ -21,57 +19,62 @@ import { isDevStage } from '../../common/index.js'
21
19
  * }
22
20
  * }
23
21
  */
24
- export class CommonCloudflareStack extends TerraformStack {
22
+ export class CommonCloudflareStack extends ComponentResource {
25
23
  construct: CommonCloudflareConstruct
26
24
  props: CommonCloudflareStackProps
25
+ config: Config
27
26
 
28
- constructor(parent: Construct, name: string, props: CommonCloudflareStackProps) {
29
- super(parent, name)
30
-
31
- /* determine extra cdk contexts */
32
- this.determineExtraContexts()
33
-
34
- /* determine extra cdk stage contexts */
35
- this.determineStageContexts()
27
+ constructor(name: string, props: CommonCloudflareStackProps, options?: ComponentResourceOptions) {
28
+ super(`custom:cloudflare:Stack:${name}`, name, props, options)
36
29
 
30
+ /* initialise config */
31
+ this.config = new Config()
37
32
  this.props = this.determineConstructProps(props)
38
33
  }
39
34
 
40
35
  /**
41
- * @summary Method to determine the core CDK construct properties injected via context cdktf.json
36
+ * @summary Method to determine the core CDK construct properties injected via context
42
37
  * @param props The stack properties
43
38
  * @returns The stack properties
44
39
  */
45
40
  protected determineConstructProps(props: CommonCloudflareStackProps) {
46
- const stage = this.node.tryGetContext('stage')
41
+ let projectProps: CommonCloudflareStackProps = props
42
+ if (!projectProps) {
43
+ const projectPropsPath = path.join(appRoot.path, 'pulumi.json')
44
+ if (!fs.existsSync(projectPropsPath)) throw `Context properties unavailable in path:${projectPropsPath}`
45
+
46
+ const projectPropsBuffer = fs.readFileSync(projectPropsPath)
47
+ projectProps = JSON.parse(projectPropsBuffer.toString('utf-8'))
48
+ }
49
+
47
50
  return {
48
- accountId: this.node.tryGetContext('accountId'),
49
- apiToken: this.node.tryGetContext('apiToken'),
50
- domainName: this.node.tryGetContext('domainName'),
51
- extraContexts: this.node.tryGetContext('extraContexts'),
52
- features: this.node.tryGetContext('features'),
53
- name: this.node.tryGetContext('resourceGroupName'),
54
- skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
55
- stage: stage,
56
- subDomain: this.node.tryGetContext('subDomain'),
51
+ accountId: projectProps.accountId,
52
+ apiToken: projectProps.apiToken,
53
+ domainName: projectProps.domainName,
54
+ extraContexts: projectProps.extraContexts,
55
+ name: projectProps.resourceGroupName ?? projectProps.name,
56
+ skipStageForARecords: projectProps.skipStageForARecords,
57
+ stage: projectProps.stage,
58
+ stageContextPath: projectProps.stageContextPath,
59
+ subDomain: projectProps.subDomain,
60
+ ...this.determineExtraContexts(props),
61
+ ...this.determineStageContexts(props),
57
62
  }
58
63
  }
59
64
 
60
65
  /**
61
- * @summary Method to determine extra cdk contexts apart from the main cdktf.json
66
+ * @summary Method to determine extra cdk contexts apart from the main context
62
67
  * - Sets the properties from the extra contexts into cdk node context
63
68
  * - Primary use is to have layered config in separate files to enable easier maintenance and readability
64
69
  */
65
- protected determineExtraContexts() {
66
- const extraContexts = this.node.tryGetContext('extraContexts')
67
- const debug = this.node.tryGetContext('debug')
68
-
69
- if (!extraContexts) {
70
- if (debug) console.debug(`No additional contexts provided. Using default context properties from cdktf.json`)
71
- return
70
+ protected determineExtraContexts(props: CommonCloudflareStackProps) {
71
+ if (!props.extraContexts) {
72
+ if (props.debug) console.debug(`No additional contexts provided. Using default context properties`)
73
+ return {}
72
74
  }
73
75
 
74
- _.forEach(extraContexts, (context: string) => {
76
+ let extraContextProps: Record<string, any> = {}
77
+ _.forEach(props.extraContexts, (context: string) => {
75
78
  const extraContextPath = path.join(appRoot.path, context)
76
79
 
77
80
  /* scenario where extra context is configured in cdk.json but absent in file system */
@@ -79,65 +82,51 @@ export class CommonCloudflareStack extends TerraformStack {
79
82
 
80
83
  /* read the extra properties */
81
84
  const extraContextPropsBuffer = fs.readFileSync(extraContextPath)
82
- if (debug) console.debug(`Adding additional contexts provided in ${extraContextPath}`)
85
+ if (props.debug) console.debug(`Adding additional contexts provided in ${extraContextPath}`)
83
86
 
84
87
  /* parse as JSON properties */
85
- const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'))
86
-
87
- /* set each of the property into the cdk node context */
88
- _.keys(extraContextProps).forEach((propKey: any) => {
89
- this.node.setContext(propKey, extraContextProps[propKey])
90
- })
88
+ extraContextProps = {
89
+ ...extraContextProps,
90
+ ...JSON.parse(extraContextPropsBuffer.toString('utf-8')),
91
+ }
91
92
  })
93
+ return extraContextProps
92
94
  }
93
95
 
94
96
  /**
95
- * @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
97
+ * @summary Method to determine extra cdk stage contexts apart from the main context
96
98
  * - Sets the properties from the extra stage contexts into cdk node context
97
99
  * - Primary use is to have layered config for each environment which is injected into the context
98
100
  */
99
- protected determineStageContexts() {
100
- const stage = process.env.STAGE ?? this.node.tryGetContext('stage')
101
- const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv'
102
- const stageContextFilePath = path.join(appRoot.path, stageContextPath, `${stage}.json`)
103
- const debug = this.node.tryGetContext('debug')
104
-
105
- if (isDevStage(stage)) {
106
- if (debug) console.debug(`Development stage. Using default stage context properties`)
101
+ protected determineStageContexts(props: CommonCloudflareStackProps) {
102
+ const stageContextFilePath = path.join(appRoot.path, props.stageContextPath ?? 'cdkEnv', `${props.stage}.json`)
103
+
104
+ if (isDevStage(props.stage)) {
105
+ if (props.debug) console.debug(`Development stage. Using default stage context properties`)
107
106
  }
108
107
 
109
108
  /* alert default context usage when extra stage config is missing */
110
109
  if (!fs.existsSync(stageContextFilePath)) {
111
- if (debug) console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`)
112
- if (debug) console.debug(`Using default stage context properties for ${stage} stage`)
113
- return
110
+ if (props.debug) console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`)
111
+ if (props.debug) console.debug(`Using default stage context properties for ${props.stage} stage`)
112
+ return {}
114
113
  }
115
114
 
116
115
  /* read the extra properties */
117
116
  const stageContextPropsBuffer = fs.readFileSync(stageContextFilePath)
118
- if (debug) console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`)
117
+ if (props.debug) console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`)
119
118
 
120
119
  /* parse as JSON properties */
121
- const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'))
122
-
123
- /* set each of the property into the cdk node context */
124
- _.keys(stageContextProps).forEach((propKey: any) => {
125
- /* handle object, array properties */
126
- if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
127
- this.node.setContext(propKey, _.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]))
128
- } else {
129
- /* handle all other primitive properties */
130
- this.node.setContext(propKey, stageContextProps[propKey])
131
- }
132
- })
120
+ return JSON.parse(stageContextPropsBuffer.toString('utf-8'))
133
121
  }
134
122
 
135
123
  /**
136
124
  * @summary Determine the fully qualified domain name based on domainName & subDomain
137
125
  */
138
126
  protected fullyQualifiedDomain() {
139
- const domainName = this.node.tryGetContext('domainName')
140
- const subDomain = this.node.tryGetContext('subDomain')
127
+ const domainName = this.props.domainName
128
+ const subDomain = this.props.subDomain
129
+
141
130
  return subDomain ? `${subDomain}.${domainName}` : domainName
142
131
  }
143
132
  }
@@ -1,23 +1,10 @@
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
-
5
- export interface RemoteBackendProps {
6
- bucketName: string
7
- region: string
8
- tableName: string
9
- type: RemoteBackend
10
- storageAccountName: string
11
- containerName: string
12
- subscriptionId: string
13
- resourceGroupName: string
14
- }
15
2
 
16
3
  /**
17
4
  */
18
- export interface CommonCloudflareStackProps extends BaseProps, CloudflareProviderConfig {
5
+ export interface CommonCloudflareStackProps extends BaseProps {
19
6
  accountId: string
20
7
  apiToken: string
21
- remoteBackend?: RemoteBackendProps
8
+ resourceGroupName?: string
22
9
  useExistingZone?: boolean
23
10
  }