@gradientedge/cdk-utils 10.6.0 → 10.8.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 (200) hide show
  1. package/dist/app/api-destined-function/src/lib/lambda.d.ts +1 -0
  2. package/dist/app/api-destined-function/src/lib/lambda.d.ts.map +1 -0
  3. package/dist/app/api-destined-function/src/lib/lambda.js +1 -0
  4. package/dist/app/api-destined-function/src/lib/lambda.js.map +1 -0
  5. package/dist/app/api-destined-function/tsconfig.tsbuildinfo +1 -0
  6. package/dist/src/lib/aws/services/cloudwatch/main.d.ts +11 -11
  7. package/dist/src/lib/azure/common/constants.d.ts +74 -0
  8. package/dist/src/lib/azure/common/constants.js +77 -0
  9. package/dist/src/lib/azure/common/construct.d.ts +15 -3
  10. package/dist/src/lib/azure/common/construct.js +40 -4
  11. package/dist/src/lib/azure/common/stack.d.ts +3 -2
  12. package/dist/src/lib/azure/common/stack.js +25 -42
  13. package/dist/src/lib/azure/common/types.d.ts +13 -2
  14. package/dist/src/lib/azure/construct/event-handler/index.d.ts +2 -0
  15. package/dist/src/lib/azure/construct/event-handler/index.js +2 -0
  16. package/dist/src/lib/azure/construct/event-handler/main.d.ts +20 -0
  17. package/dist/src/lib/azure/construct/event-handler/main.js +139 -0
  18. package/dist/src/lib/azure/construct/event-handler/types.d.ts +35 -0
  19. package/dist/src/lib/azure/construct/event-handler/types.js +1 -0
  20. package/dist/src/lib/azure/construct/function-app/index.d.ts +2 -0
  21. package/dist/src/lib/azure/construct/function-app/index.js +2 -0
  22. package/dist/src/lib/azure/construct/function-app/main.d.ts +51 -0
  23. package/dist/src/lib/azure/construct/function-app/main.js +297 -0
  24. package/dist/src/lib/azure/construct/function-app/types.d.ts +33 -0
  25. package/dist/src/lib/azure/construct/function-app/types.js +1 -0
  26. package/dist/src/lib/azure/construct/index.d.ts +6 -0
  27. package/dist/src/lib/azure/construct/index.js +6 -0
  28. package/dist/src/lib/azure/construct/rest-api/index.d.ts +2 -0
  29. package/dist/src/lib/azure/construct/rest-api/index.js +2 -0
  30. package/dist/src/lib/azure/construct/rest-api/main.d.ts +20 -0
  31. package/dist/src/lib/azure/construct/rest-api/main.js +172 -0
  32. package/dist/src/lib/azure/construct/rest-api/types.d.ts +25 -0
  33. package/dist/src/lib/azure/construct/rest-api/types.js +1 -0
  34. package/dist/src/lib/azure/construct/rest-api-function/index.d.ts +2 -0
  35. package/dist/src/lib/azure/construct/rest-api-function/index.js +2 -0
  36. package/dist/src/lib/azure/construct/rest-api-function/main.d.ts +19 -0
  37. package/dist/src/lib/azure/construct/rest-api-function/main.js +255 -0
  38. package/dist/src/lib/azure/construct/rest-api-function/types.d.ts +29 -0
  39. package/dist/src/lib/azure/construct/rest-api-function/types.js +1 -0
  40. package/dist/src/lib/azure/construct/rest-api-with-cache/index.d.ts +2 -0
  41. package/dist/src/lib/azure/construct/rest-api-with-cache/index.js +2 -0
  42. package/dist/src/lib/azure/construct/rest-api-with-cache/main.d.ts +12 -0
  43. package/dist/src/lib/azure/construct/rest-api-with-cache/main.js +56 -0
  44. package/dist/src/lib/azure/construct/rest-api-with-cache/types.d.ts +13 -0
  45. package/dist/src/lib/azure/construct/rest-api-with-cache/types.js +1 -0
  46. package/dist/src/lib/azure/construct/site-with-webapp/index.d.ts +2 -0
  47. package/dist/src/lib/azure/construct/site-with-webapp/index.js +2 -0
  48. package/dist/src/lib/azure/construct/site-with-webapp/main.d.ts +19 -0
  49. package/dist/src/lib/azure/construct/site-with-webapp/main.js +135 -0
  50. package/dist/src/lib/azure/construct/site-with-webapp/types.d.ts +30 -0
  51. package/dist/src/lib/azure/construct/site-with-webapp/types.js +1 -0
  52. package/dist/src/lib/azure/index.d.ts +1 -0
  53. package/dist/src/lib/azure/index.js +1 -0
  54. package/dist/src/lib/azure/services/api-management/main.d.ts +83 -5
  55. package/dist/src/lib/azure/services/api-management/main.js +114 -148
  56. package/dist/src/lib/azure/services/api-management/types.d.ts +22 -1
  57. package/dist/src/lib/azure/services/app-configuration/main.d.ts +13 -1
  58. package/dist/src/lib/azure/services/app-configuration/main.js +21 -2
  59. package/dist/src/lib/azure/services/app-service/main.d.ts +5 -2
  60. package/dist/src/lib/azure/services/app-service/main.js +12 -4
  61. package/dist/src/lib/azure/services/application-insights/main.d.ts +15 -4
  62. package/dist/src/lib/azure/services/application-insights/main.js +27 -6
  63. package/dist/src/lib/azure/services/application-insights/types.d.ts +4 -1
  64. package/dist/src/lib/azure/services/authorisation/constants.d.ts +13 -0
  65. package/dist/src/lib/azure/services/authorisation/constants.js +14 -0
  66. package/dist/src/lib/azure/services/authorisation/index.d.ts +3 -0
  67. package/dist/src/lib/azure/services/authorisation/index.js +3 -0
  68. package/dist/src/lib/azure/services/authorisation/main.d.ts +84 -0
  69. package/dist/src/lib/azure/services/authorisation/main.js +120 -0
  70. package/dist/src/lib/azure/services/authorisation/types.d.ts +3 -0
  71. package/dist/src/lib/azure/services/authorisation/types.js +1 -0
  72. package/dist/src/lib/azure/services/cosmosdb/constants.d.ts +8 -0
  73. package/dist/src/lib/azure/services/cosmosdb/constants.js +10 -0
  74. package/dist/src/lib/azure/services/cosmosdb/index.d.ts +1 -0
  75. package/dist/src/lib/azure/services/cosmosdb/index.js +1 -0
  76. package/dist/src/lib/azure/services/cosmosdb/main.d.ts +47 -5
  77. package/dist/src/lib/azure/services/cosmosdb/main.js +77 -8
  78. package/dist/src/lib/azure/services/cosmosdb/types.d.ts +3 -1
  79. package/dist/src/lib/azure/services/dns/main.d.ts +9 -4
  80. package/dist/src/lib/azure/services/dns/main.js +12 -8
  81. package/dist/src/lib/azure/services/eventgrid/main.d.ts +12 -7
  82. package/dist/src/lib/azure/services/eventgrid/main.js +18 -19
  83. package/dist/src/lib/azure/services/function/main.d.ts +16 -3
  84. package/dist/src/lib/azure/services/function/main.js +122 -8
  85. package/dist/src/lib/azure/services/function/types.d.ts +3 -4
  86. package/dist/src/lib/azure/services/index.d.ts +3 -0
  87. package/dist/src/lib/azure/services/index.js +3 -0
  88. package/dist/src/lib/azure/services/key-vault/main.d.ts +22 -2
  89. package/dist/src/lib/azure/services/key-vault/main.js +28 -3
  90. package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
  91. package/dist/src/lib/azure/services/monitor/main.d.ts +3 -1
  92. package/dist/src/lib/azure/services/monitor/main.js +3 -2
  93. package/dist/src/lib/azure/services/operational-insights/main.d.ts +13 -2
  94. package/dist/src/lib/azure/services/operational-insights/main.js +17 -3
  95. package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -1
  96. package/dist/src/lib/azure/services/portal/error.d.ts +5 -0
  97. package/dist/src/lib/azure/services/portal/error.js +10 -0
  98. package/dist/src/lib/azure/services/portal/index.d.ts +4 -0
  99. package/dist/src/lib/azure/services/portal/index.js +4 -0
  100. package/dist/src/lib/azure/services/portal/main.d.ts +33 -0
  101. package/dist/src/lib/azure/services/portal/main.js +51 -0
  102. package/dist/src/lib/azure/services/portal/renderer.d.ts +11 -0
  103. package/dist/src/lib/azure/services/portal/renderer.js +156 -0
  104. package/dist/src/lib/azure/services/portal/types.d.ts +40 -0
  105. package/dist/src/lib/azure/services/portal/types.js +1 -0
  106. package/dist/src/lib/azure/services/redis/main.d.ts +4 -2
  107. package/dist/src/lib/azure/services/redis/main.js +3 -2
  108. package/dist/src/lib/azure/services/redis/types.d.ts +1 -1
  109. package/dist/src/lib/azure/services/resource-group/main.d.ts +10 -1
  110. package/dist/src/lib/azure/services/resource-group/main.js +17 -3
  111. package/dist/src/lib/azure/services/security-center/index.d.ts +2 -0
  112. package/dist/src/lib/azure/services/security-center/index.js +2 -0
  113. package/dist/src/lib/azure/services/security-center/main.d.ts +31 -0
  114. package/dist/src/lib/azure/services/security-center/main.js +33 -0
  115. package/dist/src/lib/azure/services/security-center/types.d.ts +3 -0
  116. package/dist/src/lib/azure/services/security-center/types.js +1 -0
  117. package/dist/src/lib/azure/services/servicebus/main.d.ts +28 -22
  118. package/dist/src/lib/azure/services/servicebus/main.js +31 -26
  119. package/dist/src/lib/azure/services/servicebus/types.d.ts +4 -4
  120. package/dist/src/lib/azure/services/storage/main.d.ts +26 -5
  121. package/dist/src/lib/azure/services/storage/main.js +51 -9
  122. package/dist/src/lib/azure/services/storage/types.d.ts +7 -2
  123. package/dist/src/lib/cloudflare/common/construct.js +1 -1
  124. package/dist/src/lib/cloudflare/common/stack.d.ts +2 -2
  125. package/dist/src/lib/cloudflare/common/stack.js +25 -25
  126. package/dist/src/lib/cloudflare/services/worker/main.js +8 -1
  127. package/dist/src/lib/cloudflare/services/worker/types.d.ts +1 -0
  128. package/package.json +26 -23
  129. package/src/lib/azure/common/constants.ts +83 -0
  130. package/src/lib/azure/common/construct.ts +50 -7
  131. package/src/lib/azure/common/stack.ts +26 -43
  132. package/src/lib/azure/common/types.ts +14 -2
  133. package/src/lib/azure/construct/event-handler/index.ts +2 -0
  134. package/src/lib/azure/construct/event-handler/main.ts +183 -0
  135. package/src/lib/azure/construct/event-handler/types.ts +49 -0
  136. package/src/lib/azure/construct/function-app/index.ts +2 -0
  137. package/src/lib/azure/construct/function-app/main.ts +410 -0
  138. package/src/lib/azure/construct/function-app/types.ts +45 -0
  139. package/src/lib/azure/construct/index.ts +6 -0
  140. package/src/lib/azure/construct/rest-api/index.ts +2 -0
  141. package/src/lib/azure/construct/rest-api/main.ts +205 -0
  142. package/src/lib/azure/construct/rest-api/types.ts +33 -0
  143. package/src/lib/azure/construct/rest-api-function/index.ts +2 -0
  144. package/src/lib/azure/construct/rest-api-function/main.ts +297 -0
  145. package/src/lib/azure/construct/rest-api-function/types.ts +39 -0
  146. package/src/lib/azure/construct/rest-api-with-cache/index.ts +2 -0
  147. package/src/lib/azure/construct/rest-api-with-cache/main.ts +75 -0
  148. package/src/lib/azure/construct/rest-api-with-cache/types.ts +15 -0
  149. package/src/lib/azure/construct/site-with-webapp/index.ts +2 -0
  150. package/src/lib/azure/construct/site-with-webapp/main.ts +160 -0
  151. package/src/lib/azure/construct/site-with-webapp/types.ts +33 -0
  152. package/src/lib/azure/index.ts +1 -0
  153. package/src/lib/azure/services/api-management/main.ts +168 -152
  154. package/src/lib/azure/services/api-management/types.ts +30 -1
  155. package/src/lib/azure/services/app-configuration/main.ts +29 -2
  156. package/src/lib/azure/services/app-service/main.ts +23 -4
  157. package/src/lib/azure/services/application-insights/main.ts +46 -7
  158. package/src/lib/azure/services/application-insights/types.ts +6 -2
  159. package/src/lib/azure/services/authorisation/constants.ts +13 -0
  160. package/src/lib/azure/services/authorisation/index.ts +3 -0
  161. package/src/lib/azure/services/authorisation/main.ts +202 -0
  162. package/src/lib/azure/services/authorisation/types.ts +3 -0
  163. package/src/lib/azure/services/cosmosdb/constants.ts +9 -0
  164. package/src/lib/azure/services/cosmosdb/index.ts +1 -0
  165. package/src/lib/azure/services/cosmosdb/main.ts +158 -8
  166. package/src/lib/azure/services/cosmosdb/types.ts +3 -0
  167. package/src/lib/azure/services/dns/main.ts +33 -8
  168. package/src/lib/azure/services/eventgrid/main.ts +41 -23
  169. package/src/lib/azure/services/function/main.ts +155 -9
  170. package/src/lib/azure/services/function/types.ts +3 -4
  171. package/src/lib/azure/services/index.ts +3 -0
  172. package/src/lib/azure/services/key-vault/main.ts +47 -4
  173. package/src/lib/azure/services/key-vault/types.ts +4 -4
  174. package/src/lib/azure/services/monitor/main.ts +5 -2
  175. package/src/lib/azure/services/operational-insights/main.ts +30 -4
  176. package/src/lib/azure/services/operational-insights/types.ts +3 -1
  177. package/src/lib/azure/services/portal/error.ts +12 -0
  178. package/src/lib/azure/services/portal/index.ts +4 -0
  179. package/src/lib/azure/services/portal/main.ts +81 -0
  180. package/src/lib/azure/services/portal/renderer.ts +182 -0
  181. package/src/lib/azure/services/portal/types.ts +45 -0
  182. package/src/lib/azure/services/redis/main.ts +10 -3
  183. package/src/lib/azure/services/redis/types.ts +1 -1
  184. package/src/lib/azure/services/resource-group/main.ts +34 -3
  185. package/src/lib/azure/services/security-center/index.ts +2 -0
  186. package/src/lib/azure/services/security-center/main.ts +42 -0
  187. package/src/lib/azure/services/security-center/types.ts +3 -0
  188. package/src/lib/azure/services/servicebus/main.ts +61 -30
  189. package/src/lib/azure/services/servicebus/types.ts +4 -4
  190. package/src/lib/azure/services/storage/main.ts +91 -9
  191. package/src/lib/azure/services/storage/types.ts +11 -2
  192. package/src/lib/cloudflare/common/construct.ts +1 -1
  193. package/src/lib/cloudflare/common/stack.ts +25 -25
  194. package/src/lib/cloudflare/services/worker/main.ts +10 -1
  195. package/src/lib/cloudflare/services/worker/types.ts +8 -1
  196. package/dist/lib/lambda.d.ts +0 -17
  197. package/dist/lib/lambda.d.ts.map +0 -1
  198. package/dist/lib/lambda.js +0 -28
  199. package/dist/lib/lambda.js.map +0 -1
  200. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,18 +1,29 @@
1
1
  import {
2
2
  Blob,
3
3
  BlobContainer,
4
+ BlobServiceProperties,
4
5
  HttpProtocol,
5
6
  Kind,
6
7
  listStorageAccountSAS,
8
+ ManagementPolicy,
7
9
  Permissions,
8
10
  Services,
9
11
  SignedResourceTypes,
10
12
  SkuName,
11
13
  StorageAccount,
14
+ Table,
12
15
  } from '@pulumi/azure-native/storage/index.js'
13
16
  import * as pulumi from '@pulumi/pulumi'
17
+ import { ResourceOptions } from '@pulumi/pulumi'
14
18
  import { CommonAzureConstruct } from '../../common/index.js'
15
- import { ContainerSasTokenProps, StorageAccountProps, StorageBlobProps, StorageContainerProps } from './types.js'
19
+ import {
20
+ ContainerSasTokenProps,
21
+ ManagementPolicyProps,
22
+ StorageAccountProps,
23
+ StorageBlobProps,
24
+ StorageContainerProps,
25
+ StorageTableProps,
26
+ } from './types.js'
16
27
 
17
28
  /**
18
29
  * @classdesc Provides operations on Azure Storage using Pulumi
@@ -37,16 +48,22 @@ export class AzureStorageManager {
37
48
  * @param id scoped id of the resource
38
49
  * @param scope scope in which this resource is defined
39
50
  * @param props storage account properties
51
+ * @param resourceOptions Optional settings to control resource behaviour
40
52
  * @see [Pulumi Azure Native Storage Account]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/storageaccount/}
41
53
  */
42
- public createStorageAccount(id: string, scope: CommonAzureConstruct, props: StorageAccountProps) {
54
+ public createStorageAccount(
55
+ id: string,
56
+ scope: CommonAzureConstruct,
57
+ props: StorageAccountProps,
58
+ resourceOptions?: ResourceOptions
59
+ ) {
43
60
  if (!props) throw `Props undefined for ${id}`
44
61
 
45
62
  const resourceGroupName = scope.props.resourceGroupName
46
63
  ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
47
64
  : `${props.resourceGroupName}`
48
65
 
49
- return new StorageAccount(
66
+ const storageAccount = new StorageAccount(
50
67
  `${id}-sa`,
51
68
  {
52
69
  ...props,
@@ -54,6 +71,7 @@ export class AzureStorageManager {
54
71
  .format(props.accountName?.toString(), scope.props.resourceNameOptions?.storageAccount)
55
72
  .replace(/\W/g, '')
56
73
  .toLowerCase(),
74
+ allowBlobPublicAccess: props.allowBlobPublicAccess ?? false,
57
75
  resourceGroupName,
58
76
  sku: props.sku ?? {
59
77
  name: SkuName.Standard_LRS,
@@ -64,8 +82,23 @@ export class AzureStorageManager {
64
82
  environment: scope.props.stage,
65
83
  },
66
84
  },
67
- { parent: scope }
85
+ { parent: scope, ...resourceOptions }
68
86
  )
87
+
88
+ new BlobServiceProperties(`${id}-blob-props`, {
89
+ ...props.blobProperties,
90
+ accountName: scope.resourceNameFormatter
91
+ .format(props.accountName?.toString(), scope.props.resourceNameOptions?.storageAccount)
92
+ .replace(/\W/g, '')
93
+ .toLowerCase(),
94
+ resourceGroupName,
95
+ deleteRetentionPolicy: props.blobProperties?.deleteRetentionPolicy ?? {
96
+ enabled: true,
97
+ days: 7,
98
+ },
99
+ })
100
+
101
+ return storageAccount
69
102
  }
70
103
 
71
104
  /**
@@ -73,9 +106,15 @@ export class AzureStorageManager {
73
106
  * @param id scoped id of the resource
74
107
  * @param scope scope in which this resource is defined
75
108
  * @param props storage container properties
109
+ * @param resourceOptions Optional settings to control resource behaviour
76
110
  * @see [Pulumi Azure Native Blob Container]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/blobcontainer/}
77
111
  */
78
- public createStorageContainer(id: string, scope: CommonAzureConstruct, props: StorageContainerProps) {
112
+ public createStorageContainer(
113
+ id: string,
114
+ scope: CommonAzureConstruct,
115
+ props: StorageContainerProps,
116
+ resourceOptions?: ResourceOptions
117
+ ) {
79
118
  if (!props) throw `Props undefined for ${id}`
80
119
 
81
120
  const resourceGroupName = scope.props.resourceGroupName
@@ -93,7 +132,7 @@ export class AzureStorageManager {
93
132
  accountName: props.accountName,
94
133
  resourceGroupName,
95
134
  },
96
- { parent: scope }
135
+ { parent: scope, ...resourceOptions }
97
136
  )
98
137
  }
99
138
 
@@ -102,9 +141,15 @@ export class AzureStorageManager {
102
141
  * @param id scoped id of the resource
103
142
  * @param scope scope in which this resource is defined
104
143
  * @param props storage blob properties
144
+ * @param resourceOptions Optional settings to control resource behaviour
105
145
  * @see [Pulumi Azure Native Blob]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/blob/}
106
146
  */
107
- public createStorageBlob(id: string, scope: CommonAzureConstruct, props: StorageBlobProps) {
147
+ public createStorageBlob(
148
+ id: string,
149
+ scope: CommonAzureConstruct,
150
+ props: StorageBlobProps,
151
+ resourceOptions?: ResourceOptions
152
+ ) {
108
153
  if (!props) throw `Props undefined for ${id}`
109
154
 
110
155
  const resourceGroupName = scope.props.resourceGroupName
@@ -123,7 +168,7 @@ export class AzureStorageManager {
123
168
  containerName: `${props.containerName}-${scope.props.stage}`,
124
169
  resourceGroupName,
125
170
  },
126
- { parent: scope }
171
+ { parent: scope, ...resourceOptions }
127
172
  )
128
173
  }
129
174
 
@@ -140,7 +185,6 @@ export class AzureStorageManager {
140
185
  * - start: Optional start date in the format 'YYYY-MM-DD'. Defaults to today's date.
141
186
  * - expiry: Optional expiry date in the format 'YYYY-MM-DD'. Defaults to 7 days from current date.
142
187
  * @param storageAccount - The storage account resource
143
- * @param storageContainer - Optional blob container resource
144
188
  *
145
189
  * @returns A Pulumi Output containing the SAS token
146
190
  *
@@ -173,4 +217,42 @@ export class AzureStorageManager {
173
217
  })
174
218
  .apply(result => result.accountSasToken)
175
219
  }
220
+
221
+ /**
222
+ * @summary Method to create a new storage management policy
223
+ * @param id scoped id of the resource
224
+ * @param scope scope in which this resource is defined
225
+ * @param props storage management policy properties
226
+ * @param resourceOptions Optional settings to control resource behaviour
227
+ * @see [Pulumi Azure Native Storage Management Policy]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/managementpolicy/}
228
+ */
229
+ public createManagementPolicy(
230
+ id: string,
231
+ scope: CommonAzureConstruct,
232
+ props: ManagementPolicyProps,
233
+ resourceOptions?: ResourceOptions
234
+ ) {
235
+ if (!props) throw `Props undefined for ${id}`
236
+
237
+ return new ManagementPolicy(`${id}`, props, { parent: scope, ...resourceOptions })
238
+ }
239
+
240
+ /**
241
+ * @summary Method to create a new storage table
242
+ * @param id scoped id of the resource
243
+ * @param scope scope in which this resource is defined
244
+ * @param props storage table properties
245
+ * @param resourceOptions Optional settings to control resource behaviour
246
+ * @see [Pulumi Azure Native Storage Table]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/storage/table/}
247
+ */
248
+ public createTable(
249
+ id: string,
250
+ scope: CommonAzureConstruct,
251
+ props: StorageTableProps,
252
+ resourceOptions?: ResourceOptions
253
+ ) {
254
+ if (!props) throw `Props undefined for ${id}`
255
+
256
+ return new Table(`${id}`, props, { parent: scope, ...resourceOptions })
257
+ }
176
258
  }
@@ -1,17 +1,26 @@
1
1
  import {
2
2
  BlobArgs,
3
3
  BlobContainerArgs,
4
+ BlobServicePropertiesArgs,
4
5
  ListStorageAccountSASArgs,
6
+ ManagementPolicyArgs,
5
7
  StorageAccountArgs,
8
+ TableArgs,
6
9
  } from '@pulumi/azure-native/storage/index.js'
7
10
  import { BaseAzureConfigProps } from '../../types/index.js'
8
11
 
9
- export interface StorageAccountProps extends StorageAccountArgs {}
12
+ export interface StorageAccountProps extends StorageAccountArgs {
13
+ blobProperties?: BlobServicePropertiesArgs
14
+ }
10
15
 
11
- export interface StorageContainerProps extends BaseAzureConfigProps, BlobContainerArgs {}
16
+ export interface StorageContainerProps extends BlobContainerArgs, BaseAzureConfigProps {}
12
17
 
13
18
  export interface StorageBlobProps extends BaseAzureConfigProps, BlobArgs {}
14
19
 
20
+ export interface ManagementPolicyProps extends ManagementPolicyArgs {}
21
+
22
+ export interface StorageTableProps extends TableArgs {}
23
+
15
24
  export interface ContainerSasTokenProps extends ListStorageAccountSASArgs {
16
25
  resourceGroupName: string
17
26
  containerName?: string
@@ -34,7 +34,7 @@ export class CommonCloudflareConstruct extends ComponentResource {
34
34
  provider: CloudflareProvider
35
35
 
36
36
  constructor(name: string, props: CommonCloudflareStackProps, options?: ComponentResourceOptions) {
37
- super(`custom:cloudflare:Construct:${name}`, name, props, options)
37
+ super(`cloudflare:${name}`, name, props, options)
38
38
  this.props = props
39
39
  this.options = options
40
40
  this.id = name
@@ -48,17 +48,12 @@ export class CommonCloudflareStack extends ComponentResource {
48
48
  }
49
49
 
50
50
  return {
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),
51
+ ...props,
52
+ extraContexts: this.config.getObject('extraContexts'),
53
+ stage: this.config.require('stage'),
54
+ stageContextPath: this.config.require('stageContextPath'),
55
+ ...this.determineExtraContexts(),
56
+ ...this.determineStageContexts(),
62
57
  }
63
58
  }
64
59
 
@@ -67,22 +62,24 @@ export class CommonCloudflareStack extends ComponentResource {
67
62
  * - Sets the properties from the extra contexts into cdk node context
68
63
  * - Primary use is to have layered config in separate files to enable easier maintenance and readability
69
64
  */
70
- protected determineExtraContexts(props: CommonCloudflareStackProps) {
71
- if (!props.extraContexts) {
72
- if (props.debug) console.debug(`No additional contexts provided. Using default context properties`)
65
+ protected determineExtraContexts() {
66
+ const extraContexts = this.config.getObject('extraContexts')
67
+ const debug = this.config.getBoolean('debug')
68
+ if (!extraContexts) {
69
+ if (debug) console.debug(`No additional contexts provided. Using default context properties`)
73
70
  return {}
74
71
  }
75
72
 
76
73
  let extraContextProps: Record<string, any> = {}
77
- _.forEach(props.extraContexts, (context: string) => {
74
+ _.forEach(extraContexts, (context: string) => {
78
75
  const extraContextPath = path.join(appRoot.path, context)
79
76
 
80
- /* scenario where extra context is configured in cdk.json but absent in file system */
77
+ /* scenario where extra context is configured but absent in file system */
81
78
  if (!fs.existsSync(extraContextPath)) throw `Extra context properties unavailable in path:${extraContextPath}`
82
79
 
83
80
  /* read the extra properties */
84
81
  const extraContextPropsBuffer = fs.readFileSync(extraContextPath)
85
- if (props.debug) console.debug(`Adding additional contexts provided in ${extraContextPath}`)
82
+ if (debug) console.debug(`Adding additional contexts provided in ${extraContextPath}`)
86
83
 
87
84
  /* parse as JSON properties */
88
85
  extraContextProps = {
@@ -98,23 +95,26 @@ export class CommonCloudflareStack extends ComponentResource {
98
95
  * - Sets the properties from the extra stage contexts into cdk node context
99
96
  * - Primary use is to have layered config for each environment which is injected into the context
100
97
  */
101
- protected determineStageContexts(props: CommonCloudflareStackProps) {
102
- const stageContextFilePath = path.join(appRoot.path, props.stageContextPath ?? 'env', `${props.stage}.json`)
103
-
104
- if (isDevStage(props.stage)) {
105
- if (props.debug) console.debug(`Development stage. Using default stage context properties`)
98
+ protected determineStageContexts() {
99
+ const debug = this.config.getBoolean('debug')
100
+ const stage = this.config.require('stage')
101
+ const stageContextPath = this.config.get('stageContextPath')
102
+ const stageContextFilePath = path.join(appRoot.path, stageContextPath ?? 'env', `${stage}.json`)
103
+
104
+ if (isDevStage(stage)) {
105
+ if (debug) console.debug(`Development stage. Using default stage context properties`)
106
106
  }
107
107
 
108
108
  /* alert default context usage when extra stage config is missing */
109
109
  if (!fs.existsSync(stageContextFilePath)) {
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`)
110
+ if (debug) console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`)
111
+ if (debug) console.debug(`Using default stage context properties for ${stage} stage`)
112
112
  return {}
113
113
  }
114
114
 
115
115
  /* read the extra properties */
116
116
  const stageContextPropsBuffer = fs.readFileSync(stageContextFilePath)
117
- if (props.debug) console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`)
117
+ if (debug) console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`)
118
118
 
119
119
  /* parse as JSON properties */
120
120
  return JSON.parse(stageContextPropsBuffer.toString('utf-8'))
@@ -6,6 +6,7 @@ import {
6
6
  WorkersRoute,
7
7
  WorkersScript,
8
8
  } from '@pulumi/cloudflare'
9
+ import _ from 'lodash'
9
10
  import { CommonCloudflareConstruct } from '../../common/index.js'
10
11
  import {
11
12
  WorkerCronTriggerProps,
@@ -93,7 +94,7 @@ export class CloudflareWorkerManager {
93
94
  public createWorkerScript(id: string, scope: CommonCloudflareConstruct, props: WorkerScriptProps) {
94
95
  if (!props) throw `Props undefined for ${id}`
95
96
 
96
- return new WorkersScript(
97
+ const script = new WorkersScript(
97
98
  id,
98
99
  {
99
100
  ...props,
@@ -102,6 +103,14 @@ export class CloudflareWorkerManager {
102
103
  },
103
104
  { parent: scope }
104
105
  )
106
+
107
+ if (props.routes) {
108
+ _.forEach(props.routes, (route: WorkerRouteProps) => {
109
+ this.createWorkerRoute(`${id}-route-${route.pattern}`, scope, route)
110
+ })
111
+ }
112
+
113
+ return script
105
114
  }
106
115
 
107
116
  /**
@@ -8,8 +8,15 @@ import {
8
8
  } from '@pulumi/cloudflare'
9
9
 
10
10
  export interface WorkerDomainProps extends WorkersCustomDomainArgs {}
11
+
11
12
  export interface WorkerRouteProps extends WorkersRouteArgs {}
12
- export interface WorkerScriptProps extends WorkersScriptArgs {}
13
+
14
+ export interface WorkerScriptProps extends WorkersScriptArgs {
15
+ routes?: WorkerRouteProps[]
16
+ }
17
+
13
18
  export interface WorkersKvNamespaceProps extends WorkersKvNamespaceArgs {}
19
+
14
20
  export interface WorkersKvProps extends WorkersKvArgs {}
21
+
15
22
  export interface WorkerCronTriggerProps extends WorkersCronTriggerArgs {}
@@ -1,17 +0,0 @@
1
- export declare const processEvent: (event: any) => {
2
- body: {
3
- event: any;
4
- };
5
- httpMethod: any;
6
- id: string;
7
- message: string;
8
- origin: any;
9
- path: any;
10
- referer: any;
11
- resource: any;
12
- source: string;
13
- sourceId: string | undefined;
14
- statusCode: number;
15
- success: boolean;
16
- };
17
- //# sourceMappingURL=lambda.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda.d.ts","sourceRoot":"","sources":["../../app/api-destined-function/src/lib/lambda.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG;;;;;;;;;;;;;;;CAmBtC,CAAA"}
@@ -1,28 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- export const processEvent = (event) => {
3
- if (!event)
4
- throw new Error('Invalid Event');
5
- return {
6
- body: {
7
- event: event,
8
- },
9
- httpMethod: event.httpMethod,
10
- id: uuidv4(),
11
- message: 'Webhook call successful',
12
- origin: event.headers?.origin,
13
- path: event.path,
14
- referer: event.headers?.referer,
15
- resource: event.resource,
16
- source: 'custom:api-destined-lambda',
17
- sourceId: process.env.SOURCE_ID,
18
- statusCode: 200,
19
- success: true,
20
- };
21
- };
22
- exports.handler = async (event, context, callback) => {
23
- console.log('Event:', JSON.stringify(event));
24
- console.log('Context:', JSON.stringify(context));
25
- console.log('Event Records:', JSON.stringify(event.Records));
26
- return callback(null, processEvent(event));
27
- };
28
- //# sourceMappingURL=lambda.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambda.js","sourceRoot":"","sources":["../../app/api-destined-function/src/lib/lambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE;IACzC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IAE5C,OAAO;QACL,IAAI,EAAE;YACJ,KAAK,EAAE,KAAK;SACb;QACD,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,yBAAyB;QAClC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM;QAC7B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO;QAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,MAAM,EAAE,4BAA4B;QACpC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;QAC/B,UAAU,EAAE,GAAG;QACf,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAA;AAED,OAAO,CAAC,OAAO,GAAG,KAAK,EAAE,KAAU,EAAE,OAAY,EAAE,QAAa,EAAE,EAAE;IAClE,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAChD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5D,OAAO,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;AAC5C,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"root":["../app/api-destined-function/src/lib/lambda.ts","../app/api-destined-function/src/test/lambda.test.ts"],"version":"5.9.3"}