@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
@@ -1,8 +1,8 @@
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 { CommonAzureConstruct } from '../../common/index.js'
4
4
  import { createAzureTfOutput } from '../../utils/index.js'
5
- import { RedisCacheProps } from './types.js'
5
+ import { ManagedRedisProps } from './types.js'
6
6
 
7
7
  /**
8
8
  * @classdesc Provides operations on Azure Redis
@@ -16,7 +16,7 @@ import { RedisCacheProps } from './types.js'
16
16
  * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
17
17
  * super(parent, id, props)
18
18
  * this.props = props
19
- * this.redisManager.createRedis('MyRedisCache', this, props)
19
+ * this.redisManager.createRedis('MyManagedRedis', this, props)
20
20
  * }
21
21
  * }
22
22
  * ```
@@ -27,9 +27,9 @@ export class AzureRedisManager {
27
27
  * @param id scoped id of the resource
28
28
  * @param scope scope in which this resource is defined
29
29
  * @param props redis cache properties
30
- * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/redisCache.typescript.md}
30
+ * @see [CDKTF Redis Cache Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/managedRedis.typescript.md}
31
31
  */
32
- public createRedisCache(id: string, scope: CommonAzureConstruct, props: RedisCacheProps) {
32
+ public createManagedRedis(id: string, scope: CommonAzureConstruct, props: ManagedRedisProps) {
33
33
  if (!props) throw `Props undefined for ${id}`
34
34
 
35
35
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-rc-rg`, {
@@ -40,9 +40,9 @@ export class AzureRedisManager {
40
40
 
41
41
  if (!resourceGroup) throw `Resource group undefined for ${id}`
42
42
 
43
- const redisCache = new RedisCache(scope, `${id}-rc`, {
43
+ const managedRedis = new ManagedRedis(scope, `${id}-rc`, {
44
44
  ...props,
45
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.redisCache),
45
+ name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.managedRedis),
46
46
  location: resourceGroup.location,
47
47
  resourceGroupName: resourceGroup.name,
48
48
  tags: props.tags ?? {
@@ -50,10 +50,10 @@ export class AzureRedisManager {
50
50
  },
51
51
  })
52
52
 
53
- createAzureTfOutput(`${id}-redisCacheName`, scope, redisCache.name)
54
- createAzureTfOutput(`${id}-redisCacheFriendlyUniqueId`, scope, redisCache.friendlyUniqueId)
55
- createAzureTfOutput(`${id}-redisCacheId`, scope, redisCache.id)
53
+ createAzureTfOutput(`${id}-managedRedisName`, scope, managedRedis.name)
54
+ createAzureTfOutput(`${id}-managedRedisFriendlyUniqueId`, scope, managedRedis.friendlyUniqueId)
55
+ createAzureTfOutput(`${id}-managedRedisId`, scope, managedRedis.id)
56
56
 
57
- return redisCache
57
+ return managedRedis
58
58
  }
59
59
  }
@@ -1,3 +1,3 @@
1
- import { RedisCacheConfig } from '@cdktf/provider-azurerm/lib/redis-cache/index.js'
1
+ import { ManagedRedisConfig } from '@cdktf/provider-azurerm/lib/managed-redis/index.js'
2
2
 
3
- export interface RedisCacheProps extends RedisCacheConfig {}
3
+ export interface ManagedRedisProps extends ManagedRedisConfig {}
@@ -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
  }
@@ -1,18 +1,12 @@
1
- import { DataAwsSecretsmanagerSecretVersion } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret-version/index.js'
2
- import { DataAwsSecretsmanagerSecret } from '@cdktf/provider-aws/lib/data-aws-secretsmanager-secret/index.js'
3
- import { DataAzurermKeyVaultSecret } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault-secret/index.js'
4
- import { DataAzurermKeyVault } from '@cdktf/provider-azurerm/lib/data-azurerm-key-vault/index.js'
5
- import { DataCloudflareZone } from '@cdktf/provider-cloudflare/lib/data-cloudflare-zone/index.js'
6
- import { DnsRecord } from '@cdktf/provider-cloudflare/lib/dns-record/index.js'
7
- import { PagesDomain } from '@cdktf/provider-cloudflare/lib/pages-domain/index.js'
1
+ import * as aws from '@pulumi/aws'
2
+ import * as azure from '@pulumi/azure-native'
3
+ import { DnsRecord, PagesDomain, PagesProject, Zone } from '@pulumi/cloudflare'
8
4
  import {
9
- PagesProject,
10
5
  PagesProjectDeploymentConfigsPreviewEnvVars,
11
6
  PagesProjectDeploymentConfigsProductionEnvVars,
12
- } from '@cdktf/provider-cloudflare/lib/pages-project/index.js'
13
- import { Zone } from '@cdktf/provider-cloudflare/lib/zone/index.js'
14
- import { Fn } from 'cdktf'
15
- import { Construct } from 'constructs'
7
+ } from '@pulumi/cloudflare/types/input.js'
8
+ import { ComponentResourceOptions } from '@pulumi/pulumi'
9
+ import * as std from '@pulumi/std'
16
10
  import { CommonCloudflareConstruct } from '../../common/index.js'
17
11
  import { CloudflarePagesStaticSiteProps } from './types.js'
18
12
 
@@ -38,16 +32,17 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
38
32
  sitePagesCnameRecord: DnsRecord
39
33
  sitePagesDomain: PagesDomain
40
34
  sitePagesProject: PagesProject
41
- siteZone: DataCloudflareZone | Zone
35
+ siteZone: Zone
42
36
  sitePagesEnvironmentVariables: { [key: string]: PagesProjectDeploymentConfigsProductionEnvVars }
43
37
  sitePagesPreviewEnvironmentVariables: { [key: string]: PagesProjectDeploymentConfigsPreviewEnvVars }
44
38
  sitePagesSecrets: { [key: string]: PagesProjectDeploymentConfigsProductionEnvVars }
45
39
  sitePagesPreviewSecrets: { [key: string]: PagesProjectDeploymentConfigsPreviewEnvVars }
46
40
  siteDeploymentDependsOn: any
47
41
 
48
- constructor(parent: Construct, id: string, props: CloudflarePagesStaticSiteProps) {
49
- super(parent, id, props)
42
+ constructor(id: string, props: CloudflarePagesStaticSiteProps, options?: ComponentResourceOptions) {
43
+ super(id, props)
50
44
  this.props = props
45
+ this.options = options
51
46
  this.id = id
52
47
  }
53
48
 
@@ -116,14 +111,11 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
116
111
  * @returns the secret value
117
112
  */
118
113
  protected resolveSecretFromAWS(secretName: string, secretKey: string) {
119
- if (!this.awsProvider) return
120
- const secret = new DataAwsSecretsmanagerSecret(this, `${this.id}-${secretName}-${secretKey}`, { name: secretName })
121
- const secretVersion = new DataAwsSecretsmanagerSecretVersion(this, `${this.id}-${secretName}-${secretKey}-ver`, {
122
- provider: this.awsProvider,
123
- secretId: secret.id,
124
- })
114
+ if (this.config.require('secretsProvider') !== 'aws') return
115
+ const secret = aws.secretsmanager.getSecretOutput({ name: secretName })
116
+ const secretVersion = aws.secretsmanager.getSecretVersionOutput({ secretId: secret.id })
125
117
  if (!secretVersion) throw new Error(`Unable to resolve secret:${secretName}`)
126
- return Fn.lookup(Fn.jsondecode(secretVersion.secretString), secretKey)
118
+ return std.jsondecodeOutput({ input: secretVersion.secretString })
127
119
  }
128
120
 
129
121
  /**
@@ -135,26 +127,14 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
135
127
  * @returns the secret value
136
128
  */
137
129
  protected resolveSecretFromAzure(resourceGroupName: string, keyVaultName: string, secretKey: string) {
138
- const keyVaultData = new DataAzurermKeyVault(
139
- this,
140
- `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-vault`,
141
- {
142
- resourceGroupName: resourceGroupName,
143
- name: keyVaultName,
144
- provider: this.azurermProvider,
145
- }
146
- )
147
- const secretValueData = new DataAzurermKeyVaultSecret(
148
- this,
149
- `${this.id}-${resourceGroupName}-${keyVaultName}-${secretKey}-secret`,
150
- {
151
- name: secretKey,
152
- keyVaultId: keyVaultData.id,
153
- provider: this.azurermProvider,
154
- }
155
- )
130
+ if (this.config.require('secretsProvider') !== 'azure') return
131
+ const secretValueData = azure.keyvault.getSecretOutput({
132
+ resourceGroupName,
133
+ secretName: secretKey,
134
+ vaultName: keyVaultName,
135
+ })
156
136
  if (!secretValueData) throw new Error(`Unable to resolve secret:${secretKey}`)
157
- return secretValueData.value
137
+ return secretValueData.properties?.value
158
138
  }
159
139
 
160
140
  /**
@@ -201,7 +181,7 @@ export class CloudflarePagesStaticSite extends CommonCloudflareConstruct {
201
181
  branch: this.props.siteBranch ?? 'main',
202
182
  directory: this.props.siteAssetDir,
203
183
  message: this.props.siteDeployMessage,
204
- projectName: this.sitePagesProject.name,
184
+ projectName: String(this.sitePagesProject.name),
205
185
  dependsOn: this.siteDeploymentDependsOn,
206
186
  })
207
187
  }