@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
@@ -0,0 +1,49 @@
1
+ import { EventSubscription } from '@pulumi/azure-native/eventgrid/index.js'
2
+ import { Namespace, Queue } from '@pulumi/azure-native/servicebus/index.js'
3
+ import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js'
4
+ import {
5
+ DefenderForStorageProps,
6
+ EventgridEventSubscriptionProps,
7
+ EventgridTopicProps,
8
+ ServiceBusNamespaceProps,
9
+ ServiceBusQueueProps,
10
+ StorageAccountProps,
11
+ StorageContainerProps,
12
+ } from '../../services/index.js'
13
+ import { AzureFunctionAppProps } from '../function-app/index.js'
14
+
15
+ export interface EventHandlerEventGridSubscriptionProps {
16
+ dlqStorageAccount: StorageAccountProps
17
+ dlqStorageContainer: StorageContainerProps
18
+ }
19
+
20
+ export interface EventHandlerEventGridSubscription {
21
+ dlqStorageAccount: StorageAccount
22
+ dlqStorageContainer: BlobContainer
23
+ eventSubscription: EventSubscription
24
+ }
25
+
26
+ export interface EventHandlerServiceBusProps {
27
+ namespace: ServiceBusNamespaceProps
28
+ queue: ServiceBusQueueProps
29
+ }
30
+
31
+ export interface EventHandlerServiceBus {
32
+ namespace: Namespace
33
+ queue: Queue
34
+ }
35
+
36
+ export interface EventHandlerEventGridTopicProps extends EventgridTopicProps {
37
+ useExistingTopic: boolean
38
+ existingSubscriptionId?: string
39
+ existingTopicName?: string
40
+ existingResourceGroupName?: string
41
+ }
42
+
43
+ export interface AzureEventHandlerProps extends AzureFunctionAppProps {
44
+ defender?: DefenderForStorageProps
45
+ eventGridEventSubscription: EventgridEventSubscriptionProps
46
+ eventGridSubscription: EventHandlerEventGridSubscriptionProps
47
+ eventGridTopic: EventHandlerEventGridTopicProps
48
+ serviceBus: EventHandlerServiceBusProps
49
+ }
@@ -0,0 +1,2 @@
1
+ export * from './main.js'
2
+ export * from './types.js'
@@ -0,0 +1,410 @@
1
+ import * as archive from '@pulumi/archive'
2
+ import {
3
+ ConfigurationStore,
4
+ getConfigurationStoreOutput,
5
+ GetConfigurationStoreResult,
6
+ } from '@pulumi/azure-native/appconfiguration/index.js'
7
+ import { getComponentOutput, GetComponentResult } from '@pulumi/azure-native/applicationinsights/index.js'
8
+ import { SkuFamily, SkuName } from '@pulumi/azure-native/keyvault/index.js'
9
+ import { Dashboard } from '@pulumi/azure-native/portal/index.js'
10
+ import { BlobContainer, listStorageAccountKeysOutput, StorageAccount } from '@pulumi/azure-native/storage/index.js'
11
+ import {
12
+ AppServicePlan,
13
+ AuthenticationType,
14
+ FunctionsDeploymentStorageType,
15
+ WebApp,
16
+ } from '@pulumi/azure-native/web/index.js'
17
+ import * as pulumi from '@pulumi/pulumi'
18
+ import { Output, ResourceOptions } from '@pulumi/pulumi'
19
+ import fs from 'fs'
20
+ import _ from 'lodash'
21
+ import * as path from 'path'
22
+ import { CommonAzureConstruct } from '../../common/index.js'
23
+ import { CosmosRoleDefinition } from '../../services/cosmosdb/constants.js'
24
+ import { AzureAppConfigurationManager, RoleDefinitionId } from '../../services/index.js'
25
+ import { AzureFunctionAppProps } from './types.js'
26
+
27
+ export class AzureFunctionApp extends CommonAzureConstruct {
28
+ props: AzureFunctionAppProps
29
+ app: WebApp
30
+ appServicePlan: AppServicePlan
31
+ appEnvironmentVariables: Record<string, any> = {}
32
+ appStorageAccount: StorageAccount
33
+ appDeploymentStorageContainer: BlobContainer
34
+ appStorageContainer: BlobContainer
35
+ appConfig: ConfigurationStore | Output<GetConfigurationStoreResult>
36
+ appCodeArchiveFile: Output<archive.GetFileResult>
37
+ appConfigHash: string
38
+ appKeyVaultsByResourceGroup: Map<string, Set<string>>
39
+ appConnectionStrings: any[]
40
+ appConfigPrefix?: string
41
+ appConfigurationsParsedConfig: any
42
+ appConfigurationsOriginalParsedConfig: any
43
+
44
+ dataStorageAccount: StorageAccount
45
+ dataStorageContainer: BlobContainer
46
+
47
+ applicationInsights: Output<GetComponentResult>
48
+ functionDashboard: Dashboard
49
+
50
+ constructor(id: string, props: AzureFunctionAppProps) {
51
+ super(id, props)
52
+ this.props = props
53
+ this.id = id
54
+ }
55
+
56
+ public initResources() {
57
+ this.createResourceGroup()
58
+ this.resolveCommonLogAnalyticsWorkspace()
59
+ this.resolveApplicationInsights()
60
+ this.createAppServicePlan()
61
+ this.createdParsedAppConfigurations()
62
+ this.createAppConfiguration()
63
+ this.createAppConfigurations()
64
+ this.createStorageAccount()
65
+ this.createStorageDeploymentContainer()
66
+ this.createStorageContainer()
67
+ this.createDataStorageAccount()
68
+ this.createDataStorageContainer()
69
+ this.generateStorageContainerSas()
70
+ this.createFunctionHosts()
71
+ this.createCodePackage()
72
+ this.createFunctionAppSiteConfig()
73
+ this.createFunctionApp()
74
+ this.createRoleAssignments()
75
+ this.createFunctionDashboard()
76
+ }
77
+
78
+ protected resolveApplicationInsights() {
79
+ if (!this.props.commonApplicationInsights || !this.props.commonApplicationInsights.resourceName) return
80
+
81
+ this.applicationInsights = getComponentOutput({
82
+ resourceName: this.props.commonApplicationInsights.resourceName,
83
+ resourceGroupName: this.props.commonApplicationInsights.resourceGroupName,
84
+ })
85
+ }
86
+
87
+ protected createAppServicePlan() {
88
+ this.appServicePlan = this.appServiceManager.createAppServicePlan(`${this.id}-app-service-plan`, this, {
89
+ ...this.props.functionApp.servicePlan,
90
+ name: this.id,
91
+ resourceGroupName: this.resourceGroup.name,
92
+ location: this.resourceGroup.location,
93
+ })
94
+ }
95
+
96
+ protected createdParsedAppConfigurations() {}
97
+
98
+ protected createAppConfiguration() {
99
+ if (this.props.functionApp.appConfiguration) {
100
+ this.appConfig = this.appConfigurationManager.createConfigurationStore(`${this.id}-app-configuration`, this, {
101
+ ...this.props.functionApp.appConfiguration,
102
+ resourceGroupName: this.resourceGroup.name,
103
+ location: this.resourceGroup.location,
104
+ })
105
+ } else if (!this.props.useConfigOverride) {
106
+ this.appConfig = getConfigurationStoreOutput({
107
+ configStoreName: this.props.existingConfigStoreName,
108
+ resourceGroupName: this.props.existingConfigStoreResourceGroupName,
109
+ })
110
+ }
111
+ this.appConfigPrefix = _.camelCase(this.id)
112
+ }
113
+
114
+ protected createAppConfigurations() {}
115
+
116
+ protected createStorageAccount() {
117
+ this.appStorageAccount = this.storageManager.createStorageAccount(`${this.id}-storage-account`, this, {
118
+ ...this.props.functionApp.storageAccount,
119
+ location: this.resourceGroup.location,
120
+ resourceGroupName: this.resourceGroup.name,
121
+ })
122
+ }
123
+
124
+ protected createStorageDeploymentContainer() {
125
+ this.appDeploymentStorageContainer = this.storageManager.createStorageContainer(
126
+ `${this.id}-storage-deployment-container`,
127
+ this,
128
+ {
129
+ ...this.props.functionApp.deploymentStorageContainer,
130
+ accountName: this.appStorageAccount.name,
131
+ resourceGroupName: this.resourceGroup.name,
132
+ }
133
+ )
134
+ }
135
+
136
+ protected createStorageContainer() {
137
+ if (!this.props.functionApp.storageContainer) return
138
+
139
+ this.appStorageContainer = this.storageManager.createStorageContainer(`${this.id}-storage-container`, this, {
140
+ ...this.props.functionApp.storageContainer,
141
+ accountName: this.appStorageAccount.name,
142
+ resourceGroupName: this.resourceGroup.name,
143
+ })
144
+
145
+ this.appEnvironmentVariables = {
146
+ ...this.appEnvironmentVariables,
147
+ AZURE_STORAGE_ACCOUNT_NAME: this.appStorageAccount.name,
148
+ }
149
+ }
150
+
151
+ protected createDataStorageAccount() {
152
+ if (!this.props.dataStorageAccount) return
153
+
154
+ this.dataStorageAccount = this.storageManager.createStorageAccount(`${this.id}-data-storage-account`, this, {
155
+ ...this.props.dataStorageAccount,
156
+ resourceGroupName: this.resourceGroup.name,
157
+ location: this.resourceGroup.location,
158
+ })
159
+
160
+ this.appEnvironmentVariables = {
161
+ ...this.appEnvironmentVariables,
162
+ AZURE_STORAGE_ACCOUNT_NAME: this.dataStorageAccount.name,
163
+ }
164
+ }
165
+
166
+ protected createDataStorageContainer() {
167
+ if (!this.props.dataStorageContainer) return
168
+
169
+ this.dataStorageContainer = this.storageManager.createStorageContainer(`${this.id}-data-storage-container`, this, {
170
+ ...this.props.dataStorageContainer,
171
+ accountName: this.dataStorageAccount.name,
172
+ resourceGroupName: this.resourceGroup.name,
173
+ })
174
+ }
175
+
176
+ protected generateStorageContainerSas() {
177
+ if (!this.props.dataStorageContainerSas) return
178
+
179
+ const sasToken = this.storageManager.generateContainerSasToken(
180
+ `${this.id}-storage-container`,
181
+ this,
182
+ this.props.dataStorageContainerSas,
183
+ this.dataStorageAccount
184
+ )
185
+
186
+ const keyVault = this.keyVaultManager.createKeyVault(
187
+ `${this.id}`,
188
+ this,
189
+ {
190
+ vaultName: this.props.dataKeyVaultName,
191
+ location: this.resourceGroup.location,
192
+ resourceGroupName: this.resourceGroup.name,
193
+ properties: {
194
+ sku: {
195
+ name: SkuName.Standard,
196
+ family: SkuFamily.A,
197
+ },
198
+ tenantId: this.props.tenantId ?? '',
199
+ },
200
+ },
201
+ { ignoreChanges: ['location'] }
202
+ )
203
+
204
+ this.monitorManager.createMonitorDiagnosticSettings(`${this.id}-${this.props.dataKeyVaultName}`, this, {
205
+ name: `${this.props.dataKeyVaultName}-keyvault`,
206
+ resourceUri: keyVault.id,
207
+ workspaceId: this.commonLogAnalyticsWorkspace.id,
208
+ logAnalyticsDestinationType: 'Dedicated',
209
+ logs: [
210
+ {
211
+ categoryGroup: 'allLogs',
212
+ enabled: true,
213
+ },
214
+ ],
215
+ metrics: [
216
+ {
217
+ category: 'AllMetrics',
218
+ enabled: true,
219
+ },
220
+ ],
221
+ })
222
+
223
+ this.keyVaultManager.createKeyVaultSecret(`${this.id}-sas-token-secret`, this, {
224
+ vaultName: keyVault.name,
225
+ secretName: this.props.dataKeyVaultSecretName,
226
+ resourceGroupName: this.resourceGroup.name,
227
+ properties: {
228
+ value: sasToken,
229
+ },
230
+ })
231
+ }
232
+
233
+ protected createFunctionHosts() {
234
+ const currentDirectory = path.resolve()
235
+ const hostsJsonFile = `${currentDirectory}/${this.props.functionApp.deploySource}/host.json`
236
+ if (!fs.existsSync(hostsJsonFile)) return
237
+
238
+ const sourceHostsConfig = JSON.parse(fs.readFileSync(hostsJsonFile).toString('utf-8'))
239
+ const hostsConfig = _.merge(
240
+ sourceHostsConfig,
241
+ this.props.hostsConfiguration,
242
+ this.props.functionApp.hostsConfiguration
243
+ )
244
+ fs.writeFileSync(hostsJsonFile, JSON.stringify(hostsConfig, null, 2))
245
+ }
246
+
247
+ protected createCodePackage() {
248
+ const currentDirectory = path.resolve()
249
+ this.appCodeArchiveFile = archive.getFileOutput({
250
+ type: 'zip',
251
+ sourceDir: `${currentDirectory}/${this.props.functionApp.deploySource}`,
252
+ outputPath: `${currentDirectory}/${this.props.functionApp.deploySource}/${this.props.functionApp.packageName}`,
253
+ excludes: ['*.zip'],
254
+ })
255
+ }
256
+
257
+ protected createFunctionAppSiteConfig() {}
258
+
259
+ protected createFunctionApp(resourceOptions?: ResourceOptions) {
260
+ this.app = this.functionManager.createFunctionAppFlexConsumption(
261
+ `${this.id}-function-app-flex`,
262
+ this,
263
+ {
264
+ ...this.props.functionApp,
265
+ name: this.props.functionApp.app.name ?? this.id,
266
+ serverFarmId: this.appServicePlan.id,
267
+ resourceGroupName: this.resourceGroup.name,
268
+ functionAppConfig: {
269
+ deployment: {
270
+ storage: {
271
+ type: FunctionsDeploymentStorageType.BlobContainer,
272
+ value: pulumi.interpolate`${this.appStorageAccount.primaryEndpoints.apply(e => e?.blob)}${this.appDeploymentStorageContainer.name}`,
273
+ authentication: {
274
+ type: AuthenticationType.StorageAccountConnectionString,
275
+ storageAccountConnectionStringName: 'AzureWebJobsStorage',
276
+ },
277
+ },
278
+ },
279
+ },
280
+ siteConfig: {
281
+ appSettings: [
282
+ ..._.map(this.appEnvironmentVariables, (value, name) => ({ name, value })),
283
+ {
284
+ name: 'APPLICATIONINSIGHTS_CONNECTION_STRING',
285
+ value: this.applicationInsights.connectionString,
286
+ },
287
+ {
288
+ name: 'APPINSIGHTS_INSTRUMENTATIONKEY',
289
+ value: this.applicationInsights.instrumentationKey,
290
+ },
291
+ {
292
+ name: 'AzureWebJobsStorage',
293
+ value: pulumi.interpolate`DefaultEndpointsProtocol=https;AccountName=${this.appStorageAccount.name};AccountKey=${
294
+ listStorageAccountKeysOutput({
295
+ resourceGroupName: this.resourceGroup.name,
296
+ accountName: this.appStorageAccount.name,
297
+ }).keys[0].value
298
+ };EndpointSuffix=core.windows.net`,
299
+ },
300
+ ],
301
+ connectionStrings: Object.fromEntries(
302
+ this.appConnectionStrings.map(cs => [cs.name, { type: cs.type, value: cs.value }])
303
+ ),
304
+ },
305
+ httpsOnly: this.props.functionApp.app.httpsOnly ?? true,
306
+ },
307
+ { ...resourceOptions }
308
+ )
309
+ }
310
+
311
+ protected getFunctionAppPrincipalId(): Output<string> {
312
+ return this.app.identity.apply(identity => (identity?.principalId ? identity.principalId : ''))
313
+ }
314
+
315
+ protected createRoleAssignments() {
316
+ if (this.props.dataStorageAccount) {
317
+ this.authorisationManager.grantRoleAssignmentToStorageAccount(
318
+ `${this.id}-data`,
319
+ this,
320
+ this.dataStorageAccount.id,
321
+ this.getFunctionAppPrincipalId(),
322
+ RoleDefinitionId.STORAGE_BLOB_DATA_CONTRIBUTOR
323
+ )
324
+ }
325
+
326
+ this.authorisationManager.grantRoleAssignmentToStorageAccount(
327
+ this.id,
328
+ this,
329
+ this.appStorageAccount.id,
330
+ this.getFunctionAppPrincipalId(),
331
+ RoleDefinitionId.STORAGE_BLOB_DATA_CONTRIBUTOR
332
+ )
333
+
334
+ if (!this.props.useConfigOverride) {
335
+ this.authorisationManager.grantRoleAssignmentToApplicationConfiguration(
336
+ this.id,
337
+ this,
338
+ this.appConfig.id,
339
+ this.getFunctionAppPrincipalId(),
340
+ RoleDefinitionId.APP_CONFIGURATION_DATA_READER
341
+ )
342
+ }
343
+
344
+ if (
345
+ this.appConfigurationsParsedConfig &&
346
+ AzureAppConfigurationManager.hasCosmosDependencies(this.appConfigurationsParsedConfig)
347
+ ) {
348
+ this.cosmosDbManager.grantSqlRoleDefinitionToAccount(
349
+ this.id,
350
+ this,
351
+ this.props.existingCosmosAccountName,
352
+ this.props.existingCosmosAccountResourceGroupName,
353
+ this.getFunctionAppPrincipalId(),
354
+ [CosmosRoleDefinition.CONTRIBUTOR, CosmosRoleDefinition.READER]
355
+ )
356
+ }
357
+
358
+ if (this.appKeyVaultsByResourceGroup && this.appKeyVaultsByResourceGroup.size > 0) {
359
+ this.appKeyVaultsByResourceGroup.forEach((keyVaultNames, resourceGroup) => {
360
+ keyVaultNames.forEach(keyVaultName => {
361
+ this.authorisationManager.grantRoleAssignmentToKeyVault(
362
+ this.id,
363
+ this,
364
+ keyVaultName,
365
+ resourceGroup,
366
+ this.getFunctionAppPrincipalId(),
367
+ RoleDefinitionId.KEY_VAULT_SECRETS_USER
368
+ )
369
+ })
370
+ })
371
+ }
372
+
373
+ if (AzureAppConfigurationManager.hasEventGridTargets(this.appConfigurationsParsedConfig)) {
374
+ this.authorisationManager.grantRoleAssignmentToEventgridTopic(
375
+ this.id,
376
+ this,
377
+ this.props.existingTopicName,
378
+ this.props.existingTopicResourceGroupName,
379
+ this.getFunctionAppPrincipalId(),
380
+ RoleDefinitionId.EVENTGRID_DATA_SENDER
381
+ )
382
+ }
383
+ }
384
+
385
+ protected dashboardVariables(): Record<string, any> {
386
+ return {
387
+ displayName: this.props.functionApp.dashboard.displayName,
388
+ name: this.id,
389
+ subscriptionId: this.props.subscriptionId,
390
+ functionAppName: this.app.name,
391
+ functionAppResourceGroupName: this.resourceGroup.name,
392
+ insightsAppName: this.applicationInsights.name,
393
+ insightsAppResourceGroupName: this.props.commonLogAnalyticsWorkspace?.resourceGroupName,
394
+ }
395
+ }
396
+
397
+ protected createFunctionDashboard(): void {
398
+ if (!this.props.functionApp.dashboard?.enabled) return
399
+
400
+ this.functionDashboard = this.portalManager.createDashBoard(`${this.id}-dsh`, this, {
401
+ displayName: this.props.functionApp.dashboard.displayName,
402
+ location: this.props.locationConfig?.[this.props.location].name,
403
+ dashboardName: this.id,
404
+ resourceGroupName: this.resourceGroup.name,
405
+ variables: this.dashboardVariables(),
406
+ panes: this.props.functionApp.dashboard.panes,
407
+ properties: this.appConfigurationsOriginalParsedConfig.appConfig,
408
+ })
409
+ }
410
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ AppConfigurationProps,
3
+ CommonAzureStackProps,
4
+ ContainerSasTokenProps,
5
+ FunctionAppFlexConsumptionProps,
6
+ PortalDashboardProps,
7
+ ServicePlanProps,
8
+ StorageAccountProps,
9
+ StorageContainerProps,
10
+ } from '../../index.js'
11
+
12
+ export interface OtelProps {
13
+ otelTracesSamplerArg: string
14
+ }
15
+
16
+ export interface FunctionAppProperties {
17
+ app: FunctionAppFlexConsumptionProps
18
+ appConfiguration: AppConfigurationProps
19
+ dashboard: PortalDashboardProps
20
+ deploymentStorageContainer: StorageContainerProps
21
+ deploySource: string
22
+ hostsConfiguration?: string
23
+ packageName: string
24
+ servicePlan: ServicePlanProps
25
+ storageAccount: StorageAccountProps
26
+ storageContainer: StorageContainerProps
27
+ timerTriggerCronExpression: string
28
+ }
29
+
30
+ export interface AzureFunctionAppProps extends CommonAzureStackProps {
31
+ existingTopicName: string
32
+ existingTopicResourceGroupName: string
33
+ existingCosmosAccountResourceGroupName: string
34
+ existingCosmosAccountName: string
35
+ hostsConfiguration: any
36
+ existingConfigStoreResourceGroupName: string
37
+ existingConfigStoreName: string
38
+ functionApp: FunctionAppProperties
39
+ useConfigOverride?: boolean
40
+ dataStorageContainer: StorageContainerProps
41
+ dataStorageAccount: StorageAccountProps
42
+ dataStorageContainerSas: ContainerSasTokenProps
43
+ dataKeyVaultName: string
44
+ dataKeyVaultSecretName: string
45
+ }
@@ -0,0 +1,6 @@
1
+ export * from './event-handler/index.js'
2
+ export * from './function-app/index.js'
3
+ export * from './rest-api-function/index.js'
4
+ export * from './rest-api-with-cache/index.js'
5
+ export * from './rest-api/index.js'
6
+ export * from './site-with-webapp/index.js'
@@ -0,0 +1,2 @@
1
+ export * from './main.js'
2
+ export * from './types.js'