@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,160 @@
1
+ import * as archive from '@pulumi/archive'
2
+ import { getComponentOutput, GetComponentResult } from '@pulumi/azure-native/applicationinsights/index.js'
3
+ import { Output, ResourceOptions } from '@pulumi/pulumi'
4
+ import { writeFileSync } from 'fs'
5
+ import _ from 'lodash'
6
+ import * as path from 'path'
7
+ import { CommonAzureConstruct } from '../../common/index.js'
8
+ import { Site, SiteWithWebAppProps } from './types.js'
9
+
10
+ export class SiteWithWebApp extends CommonAzureConstruct {
11
+ props: SiteWithWebAppProps
12
+ applicationInsights: Output<GetComponentResult>
13
+ site: Site
14
+
15
+ constructor(id: string, props: SiteWithWebAppProps) {
16
+ super(id, props)
17
+ this.props = props
18
+ this.id = id
19
+ }
20
+
21
+ public initResources() {
22
+ this.createResourceGroup()
23
+ this.resolveCommonLogAnalyticsWorkspace()
24
+ this.resolveApplicationInsights()
25
+ this.createSiteAppServicePlan()
26
+ this.createSiteStorageAccount()
27
+ this.createSiteStorageContainer()
28
+ this.createCodePackage()
29
+ this.createWebAppSiteConfig()
30
+ this.createWebApp()
31
+ this.createDiagnosticLog()
32
+ }
33
+
34
+ protected resolveApplicationInsights() {
35
+ if (!this.props.commonApplicationInsights || !this.props.commonApplicationInsights.resourceName) return
36
+
37
+ this.applicationInsights = getComponentOutput({
38
+ resourceName: this.props.commonApplicationInsights.resourceName,
39
+ resourceGroupName: this.props.commonApplicationInsights.resourceGroupName,
40
+ })
41
+ }
42
+
43
+ protected createSiteAppServicePlan() {
44
+ this.site.appServicePlan = this.appServiceManager.createAppServicePlan(`${this.id}-app-service-plan`, this, {
45
+ ...this.props.site.appServicePlan,
46
+ location: this.resourceGroup.location,
47
+ resourceGroupName: this.resourceGroup.name,
48
+ })
49
+ }
50
+
51
+ protected createSiteStorageAccount() {
52
+ this.site.storageAccount = this.storageManager.createStorageAccount(`${this.id}-storage-account`, this, {
53
+ ...this.props.site.storageAccount,
54
+ location: this.resourceGroup.location,
55
+ resourceGroupName: this.resourceGroup.name,
56
+ })
57
+ }
58
+
59
+ protected createSiteStorageContainer() {
60
+ this.site.storageContainer = this.storageManager.createStorageContainer(
61
+ `${this.id}-storage-deployment-container`,
62
+ this,
63
+ {
64
+ ...this.props.site.storageContainer,
65
+ accountName: this.site.storageAccount.id,
66
+ resourceGroupName: this.resourceGroup.name,
67
+ }
68
+ )
69
+ }
70
+
71
+ protected createCodePackage() {
72
+ const currentDirectory = path.resolve()
73
+
74
+ if (this.props.startCommand) {
75
+ const packageJson = {
76
+ description: 'Generated',
77
+ name: this.id,
78
+ private: true,
79
+ scripts: {
80
+ start: this.props.startCommand,
81
+ },
82
+ version: '1.0.0',
83
+ }
84
+
85
+ const packageJsonFile = `${currentDirectory}/${this.props.deploySource}/package.json`
86
+ writeFileSync(packageJsonFile, JSON.stringify(packageJson))
87
+ }
88
+
89
+ this.site.codeArchiveFile = archive.getFileOutput({
90
+ ...this.props.site.codeArchiveFile,
91
+ excludes: this.props.site.codeArchiveFile.excludes ?? ['*.zip'],
92
+ outputPath: `${currentDirectory}/${this.props.deploySource}/${this.props.packageName}`,
93
+ sourceDir: `${currentDirectory}/${this.props.deploySource}`,
94
+ type: this.props.site.codeArchiveFile.type ?? 'zip',
95
+ })
96
+ }
97
+
98
+ protected createWebAppSiteConfig() {
99
+ this.site.environmentVariables = {
100
+ APPINSIGHTS_INSTRUMENTATIONKEY: this.applicationInsights.instrumentationKey,
101
+ APPLICATIONINSIGHTS_CONNECTION_STRING: this.applicationInsights.connectionString,
102
+ ApplicationInsightsAgent_EXTENSION_VERSION: '~3',
103
+ OTEL_SDK_DISABLED: 'false',
104
+ BUILD_VERSION: '0.0.0',
105
+ STAGE: this.props.stage,
106
+ NODE_OPTIONS: this.props.nodeOptions,
107
+ NODE_ENV: this.props.nodeEnv ?? 'production',
108
+ }
109
+ }
110
+
111
+ protected createWebApp(resourceOptions?: ResourceOptions) {
112
+ this.site.webApp = this.appServiceManager.createLinuxWebApp(
113
+ `${this.id}-web-app`,
114
+ this,
115
+ {
116
+ ...this.props.site.webApp,
117
+ location: this.resourceGroup.location,
118
+ resourceGroupName: this.resourceGroup.name,
119
+ serverFarmId: this.site.appServicePlan.id,
120
+ siteConfig: _.merge(this.props.site.webApp.siteConfig, {
121
+ appSettings: _.map(this.site.environmentVariables, (value, name) => ({ name, value })),
122
+ }),
123
+ },
124
+ { ...resourceOptions }
125
+ )
126
+ }
127
+
128
+ protected createDiagnosticLog() {
129
+ this.monitorManager.createMonitorDiagnosticSettings(this.id, this, {
130
+ name: `${this.props.site.webApp.name}-webapp`,
131
+ resourceUri: this.site.webApp.id,
132
+ workspaceId: this.commonLogAnalyticsWorkspace.id,
133
+ logAnalyticsDestinationType: 'Dedicated',
134
+ logs: [
135
+ {
136
+ category: 'AppServiceAppLogs',
137
+ enabled: true,
138
+ },
139
+ {
140
+ category: 'AppServiceConsoleLogs',
141
+ enabled: true,
142
+ },
143
+ {
144
+ category: 'AppServiceHTTPLogs',
145
+ enabled: true,
146
+ },
147
+ {
148
+ category: 'AppServicePlatformLogs',
149
+ enabled: true,
150
+ },
151
+ ],
152
+ metrics: [
153
+ {
154
+ category: 'AllMetrics',
155
+ enabled: true,
156
+ },
157
+ ],
158
+ })
159
+ }
160
+ }
@@ -0,0 +1,33 @@
1
+ import * as archive from '@pulumi/archive'
2
+ import { GetFileOutputArgs } from '@pulumi/archive'
3
+ import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js'
4
+ import { AppServicePlan, WebApp } from '@pulumi/azure-native/web/index.js'
5
+ import { Output } from '@pulumi/pulumi'
6
+ import { CommonAzureStackProps } from '../../common/index.js'
7
+ import { LinuxWebAppProps, ServicePlanProps, StorageAccountProps, StorageContainerProps } from '../../services/index.js'
8
+
9
+ export interface SiteProps {
10
+ appServicePlan: ServicePlanProps
11
+ codeArchiveFile: GetFileOutputArgs
12
+ storageAccount: StorageAccountProps
13
+ storageContainer: StorageContainerProps
14
+ webApp: LinuxWebAppProps
15
+ }
16
+
17
+ export interface SiteWithWebAppProps extends CommonAzureStackProps {
18
+ deploySource: string
19
+ nodeOptions: string
20
+ nodeEnv?: string
21
+ packageName: string
22
+ site: SiteProps
23
+ startCommand: string
24
+ }
25
+
26
+ export interface Site {
27
+ appServicePlan: AppServicePlan
28
+ codeArchiveFile: Output<archive.GetFileResult>
29
+ environmentVariables: Record<string, any>
30
+ storageAccount: StorageAccount
31
+ storageContainer: BlobContainer
32
+ webApp: WebApp
33
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './common/index.js'
2
+ export * from './construct/index.js'
2
3
  export * from './services/index.js'
3
4
  export * from './types/index.js'
@@ -1,25 +1,36 @@
1
1
  import {
2
2
  Api,
3
+ ApiDiagnostic,
3
4
  ApiManagementService,
4
5
  ApiOperation,
5
6
  ApiOperationPolicy,
7
+ ApiPolicy,
6
8
  Backend,
7
9
  BackendProtocol,
8
10
  Cache,
9
11
  getApiManagementServiceOutput,
10
12
  Logger,
11
13
  LoggerType,
12
- PolicyContentFormat,
14
+ NamedValue,
13
15
  Protocol,
16
+ Subscription,
14
17
  } from '@pulumi/azure-native/apimanagement/index.js'
15
18
  import * as redis from '@pulumi/azure-native/redis/index.js'
16
- import _ from 'lodash'
19
+ import { ResourceOptions } from '@pulumi/pulumi'
17
20
  import { CommonAzureConstruct } from '../../common/index.js'
18
21
  import {
22
+ ApiDiagnosticProps,
19
23
  ApiManagementApiProps,
20
24
  ApiManagementBackendProps,
21
25
  ApiManagementCustomDomainProps,
22
26
  ApiManagementProps,
27
+ ApiOperationPolicyProps,
28
+ ApiOperationProps,
29
+ ApiPolicyProps,
30
+ ApiSubscriptionProps,
31
+ CacheProps,
32
+ LoggerProps,
33
+ NamedValueProps,
23
34
  ResolveApiManagementProps,
24
35
  } from './types.js'
25
36
 
@@ -48,6 +59,7 @@ export class AzureApiManagementManager {
48
59
  * @param props API Management properties
49
60
  * @param applicationInsightsKey Optional Application Insights instrumentation key for logging
50
61
  * @param externalRedisCache Optional external Redis cache for API Management caching
62
+ * @param resourceOptions Optional settings to control resource behaviour
51
63
  * @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
52
64
  */
53
65
  public createApiManagementService(
@@ -55,7 +67,8 @@ export class AzureApiManagementManager {
55
67
  scope: CommonAzureConstruct,
56
68
  props: ApiManagementProps,
57
69
  applicationInsightsKey?: string,
58
- externalRedisCache?: redis.Redis
70
+ externalRedisCache?: redis.Redis,
71
+ resourceOptions?: ResourceOptions
59
72
  ) {
60
73
  if (!props) throw `Props undefined for ${id}`
61
74
 
@@ -82,7 +95,7 @@ export class AzureApiManagementManager {
82
95
  environment: scope.props.stage,
83
96
  },
84
97
  },
85
- { parent: scope }
98
+ { parent: scope, ...resourceOptions }
86
99
  )
87
100
 
88
101
  // Create logger if Application Insights key is provided
@@ -101,7 +114,7 @@ export class AzureApiManagementManager {
101
114
  instrumentationKey: applicationInsightsKey,
102
115
  },
103
116
  },
104
- { parent: scope }
117
+ { parent: scope, dependsOn: [apiManagementService] }
105
118
  )
106
119
  }
107
120
 
@@ -123,7 +136,7 @@ export class AzureApiManagementManager {
123
136
  useFromLocation: externalRedisCache.location,
124
137
  resourceId: externalRedisCache.id,
125
138
  },
126
- { parent: scope }
139
+ { parent: scope, dependsOn: apiManagementService }
127
140
  )
128
141
  }
129
142
 
@@ -135,9 +148,15 @@ export class AzureApiManagementManager {
135
148
  * @param id scoped id of the resource
136
149
  * @param scope scope in which this resource is defined
137
150
  * @param props API Management lookup properties
151
+ * @param resourceOptions Optional settings to control resource behaviour
138
152
  * @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
139
153
  */
140
- public resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps) {
154
+ public resolveApiManagementService(
155
+ id: string,
156
+ scope: CommonAzureConstruct,
157
+ props: ResolveApiManagementProps,
158
+ resourceOptions?: ResourceOptions
159
+ ) {
141
160
  if (!props) throw `Props undefined for ${id}`
142
161
 
143
162
  return getApiManagementServiceOutput(
@@ -150,7 +169,7 @@ export class AzureApiManagementManager {
150
169
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
151
170
  : props.resourceGroupName,
152
171
  },
153
- { parent: scope }
172
+ { parent: scope, ...resourceOptions }
154
173
  )
155
174
  }
156
175
 
@@ -159,9 +178,15 @@ export class AzureApiManagementManager {
159
178
  * @param id scoped id of the resource
160
179
  * @param scope scope in which this resource is defined
161
180
  * @param props API Management backend properties
181
+ * @param resourceOptions Optional settings to control resource behaviour
162
182
  * @see [Pulumi Azure Native API Management Backend]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/backend/}
163
183
  */
164
- public createBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
184
+ public createBackend(
185
+ id: string,
186
+ scope: CommonAzureConstruct,
187
+ props: ApiManagementBackendProps,
188
+ resourceOptions?: ResourceOptions
189
+ ) {
165
190
  if (!props) throw `Props undefined for ${id}`
166
191
 
167
192
  return new Backend(
@@ -175,7 +200,7 @@ export class AzureApiManagementManager {
175
200
  description: props.description ?? `Backend for ${(props as any).name || id}-${scope.props.stage}`,
176
201
  protocol: props.protocol ?? BackendProtocol.Http,
177
202
  },
178
- { parent: scope }
203
+ { parent: scope, ...resourceOptions }
179
204
  )
180
205
  }
181
206
 
@@ -184,9 +209,15 @@ export class AzureApiManagementManager {
184
209
  * @param id scoped id of the resource
185
210
  * @param scope scope in which this resource is defined
186
211
  * @param props API Management API properties
212
+ * @param resourceOptions Optional settings to control resource behaviour
187
213
  * @see [Pulumi Azure Native API Management API]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/}
188
214
  */
189
- public createApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
215
+ public createApi(
216
+ id: string,
217
+ scope: CommonAzureConstruct,
218
+ props: ApiManagementApiProps,
219
+ resourceOptions?: ResourceOptions
220
+ ) {
190
221
  if (!props) throw `Props undefined for ${id}`
191
222
 
192
223
  const api = new Api(
@@ -201,160 +232,146 @@ export class AzureApiManagementManager {
201
232
  apiRevision: props.apiRevision ?? '1',
202
233
  protocols: props.protocols ?? [Protocol.Https],
203
234
  },
204
- { parent: scope }
235
+ { parent: scope, ...resourceOptions }
205
236
  )
206
237
 
207
- // Create operations and policies
208
- _.forEach(props.operations, operation => {
209
- const operationId = `${operation.displayName}-${operation.method}`
210
- const apimOperation = new ApiOperation(
211
- `${id}-apim-api-operation-${operation.displayName}-${operation.method}`,
212
- {
213
- operationId: operationId,
214
- method: (operation.method as string)?.toUpperCase() || 'GET',
215
- serviceName: props.serviceName!,
216
- resourceGroupName: props.resourceGroupName!,
217
- apiId: api.name,
218
- displayName: operation.displayName,
219
- urlTemplate: operation.urlTemplate,
220
- templateParameters: operation.templateParameters,
221
- },
222
- { parent: scope }
223
- )
238
+ return api
239
+ }
224
240
 
225
- // Define Caching Policy if enabled
226
- let cacheSetVariablePolicy = ''
227
- let cacheInvalidateInboundPolicy = ''
228
- let cacheSetInboundPolicy = ''
229
- let cacheSetOutboundPolicy = ''
241
+ /**
242
+ * @summary Method to create a new API Diagnostic
243
+ * @param id scoped id of the resource
244
+ * @param scope scope in which this resource is defined
245
+ * @param props API Disagnostic properties
246
+ * @param resourceOptions Optional settings to control resource behaviour
247
+ * @see [Pulumi Azure Native API Management Diagnostic]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apidiagnostic/}
248
+ */
249
+ public createApiDiagnostic(
250
+ id: string,
251
+ scope: CommonAzureConstruct,
252
+ props: ApiDiagnosticProps,
253
+ resourceOptions?: ResourceOptions
254
+ ) {
255
+ if (!props) throw `Props undefined for ${id}`
230
256
 
231
- if (operation.caching) {
232
- cacheSetVariablePolicy = `<!-- Generate a comprehensive custom cache key (without query params or Accept header) -->
233
- <set-variable name="customCacheKey" value="@{
234
- // Instance identification
257
+ return new ApiDiagnostic(`${id}`, props, { parent: scope, ...resourceOptions })
258
+ }
235
259
 
236
- // API identification
237
- string apiName = context.Api.Name.Replace(" ", "").ToLower();
238
- string apiVersion = context.Api.Version ?? "v1";
260
+ /**
261
+ * @summary Method to create a new API Logger
262
+ * @param id scoped id of the resource
263
+ * @param scope scope in which this resource is defined
264
+ * @param props API Logger properties
265
+ * @param resourceOptions Optional settings to control resource behaviour
266
+ * @see [Pulumi Azure Native API Management Logger]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/logger/}
267
+ */
268
+ public createLogger(id: string, scope: CommonAzureConstruct, props: LoggerProps, resourceOptions?: ResourceOptions) {
269
+ if (!props) throw `Props undefined for ${id}`
239
270
 
240
- // Full path construction (without query parameters)
241
- string fullPath = context.Request.Url.Path.ToLower();
271
+ return new Logger(`${id}`, props, { parent: scope, ...resourceOptions })
272
+ }
242
273
 
243
- // Query parameters
244
- string query = context.Request.Url.QueryString.ToLower();
274
+ /**
275
+ * @summary Method to create a new API Named Value
276
+ * @param id scoped id of the resource
277
+ * @param scope scope in which this resource is defined
278
+ * @param props API Named Value properties
279
+ * @param resourceOptions Optional settings to control resource behaviour
280
+ * @see [Pulumi Azure Native API Management Named Value]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/namedvalue/}
281
+ */
282
+ public createNamedValue(
283
+ id: string,
284
+ scope: CommonAzureConstruct,
285
+ props: NamedValueProps,
286
+ resourceOptions?: ResourceOptions
287
+ ) {
288
+ if (!props) throw `Props undefined for ${id}`
245
289
 
246
- // Construct final cache key (no Accept header needed for JSON-only APIs)
247
- return $"{apiName}:{apiVersion}:{fullPath}:{query}";
248
- }" />
249
- <set-variable name="bypassCache" value="@(context.Request.Headers.GetValueOrDefault("X-Cache-Bypass", "false").ToLower())" />`
290
+ return new NamedValue(`${id}`, props, { parent: scope, ...resourceOptions })
291
+ }
250
292
 
251
- if (operation.caching.enableCacheSet) {
252
- cacheSetInboundPolicy = `<choose>
253
- <when condition="@((string)context.Variables["bypassCache"] != "true")">
254
- <!-- Attempt to retrieve cached response -->
255
- <cache-lookup-value key="@((string)context.Variables["customCacheKey"])" variable-name="cachedResponse" caching-type="${operation.caching.cachingType || 'prefer-external'}" />
293
+ /**
294
+ * @summary Method to create a new API Subscription
295
+ * @param id scoped id of the resource
296
+ * @param scope scope in which this resource is defined
297
+ * @param props API Subscription properties
298
+ * @param resourceOptions Optional settings to control resource behaviour
299
+ * @see [Pulumi Azure Native API Management Subscription]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/subscription/}
300
+ */
301
+ public createSubscription(
302
+ id: string,
303
+ scope: CommonAzureConstruct,
304
+ props: ApiSubscriptionProps,
305
+ resourceOptions?: ResourceOptions
306
+ ) {
307
+ if (!props) throw `Props undefined for ${id}`
256
308
 
257
- <!-- If cache hit, return cached response -->
258
- <choose>
259
- <when condition="@(context.Variables.ContainsKey("cachedResponse"))">
260
- <return-response>
261
- <set-status code="200" reason="OK" />
262
- <set-header name="Content-Type" exists-action="override">
263
- <value>application/json</value>
264
- </set-header>
265
- <set-header name="X-Apim-Cache-Status" exists-action="override">
266
- <value>HIT</value>
267
- </set-header>
268
- <set-header name="X-Apim-Cache-Key" exists-action="override">
269
- <value>@((string)context.Variables["customCacheKey"])</value>
270
- </set-header>
271
- <set-body>@((string)context.Variables["cachedResponse"])</set-body>
272
- </return-response>
273
- </when>
274
- </choose>
275
- </when>
276
- <when condition="@((string)context.Variables["bypassCache"] == "true")">
277
- <cache-remove-value key="@((string)context.Variables["customCacheKey"])" caching-type="${operation.caching.cachingType || 'prefer-external'}" />
278
- </when>
279
- </choose>`
280
- cacheSetOutboundPolicy = `<!-- Store the response body in cache -->
281
- <choose>
282
- <when condition="@(context.Response.StatusCode == 200)">
283
- <cache-store-value key="@((string)context.Variables["customCacheKey"])" value="@(context.Response.Body.As<string>(preserveContent: true))" duration="${operation.caching.ttlInSecs ?? 900}" caching-type="${operation.caching.cachingType || 'prefer-external'}" />
284
- <!-- Add cache status header -->
285
- <set-header name="X-Apim-Cache-Status" exists-action="override">
286
- <value>MISS</value>
287
- </set-header>
288
- </when>
289
- </choose>
290
- <!-- Add debug headers -->
291
- <set-header name="X-Apim-Cache-Key" exists-action="override">
292
- <value>@((string)context.Variables["customCacheKey"])</value>
293
- </set-header>
294
- <set-header name="X-Apim-API-Name" exists-action="override">
295
- <value>@(context.Api.Name)</value>
296
- </set-header>`
297
- }
309
+ return new Subscription(`${id}`, props, { parent: scope, ...resourceOptions })
310
+ }
298
311
 
299
- if (operation.caching.enableCacheInvalidation) {
300
- cacheInvalidateInboundPolicy = `<set-variable name="clearCache" value="@(context.Request.Headers.GetValueOrDefault("X-Apim-Clear-Cache", "false").ToLower())" />
301
- <!-- Allow admin to clear specific cache entries -->
302
- <choose>
303
- <when condition="@((string)context.Variables["clearCache"] == "true")">
304
- <cache-remove-value key="@((string)context.Variables["customCacheKey"])" caching-type="${operation.caching.cachingType || 'prefer-external'}" />
305
- <return-response>
306
- <set-status code="200" reason="OK" />
307
- <set-body>Cache entry removed successfully</set-body>
308
- </return-response>
309
- </when>
310
- </choose>`
311
- }
312
- }
312
+ /**
313
+ * @summary Method to create a new API cache
314
+ * @param id scoped id of the resource
315
+ * @param scope scope in which this resource is defined
316
+ * @param props API cache properties
317
+ * @param resourceOptions Optional settings to control resource behaviour
318
+ * @see [Pulumi Azure Native API Management Cache]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/cache/}
319
+ */
320
+ public createCache(id: string, scope: CommonAzureConstruct, props: CacheProps, resourceOptions?: ResourceOptions) {
321
+ if (!props) throw `Props undefined for ${id}`
313
322
 
314
- // Inject rate limiting policy (if configured)
315
- let rateLimitPolicy = ''
316
- if (props.rateLimit && scope.props.subscriptionId) {
317
- rateLimitPolicy = `<rate-limit-by-key calls="${props.rateLimit.calls}" renewal-period="${props.rateLimit.renewalPeriodInSecs}" counter-key="${scope.props.subscriptionId}-${operationId}"/>`
318
- }
323
+ return new Cache(`${id}`, props, { parent: scope, ...resourceOptions })
324
+ }
319
325
 
320
- const policyXmlContent = `<policies>
321
- <inbound>
322
- <base />
323
- ${rateLimitPolicy}
324
- ${cacheSetVariablePolicy}
325
- ${cacheInvalidateInboundPolicy}
326
- ${cacheSetInboundPolicy}
327
- ${props.commonInboundPolicyXml ?? ''}
328
- </inbound>
329
- <backend>
330
- <base />
331
- </backend>
332
- <outbound>
333
- <base />
334
- ${cacheSetOutboundPolicy}
335
- ${props.commonOutboundPolicyXml ?? ''}
336
- </outbound>
337
- <on-error>
338
- <base />
339
- </on-error>
340
- </policies>`
326
+ /**
327
+ * @summary Method to create a new API operation
328
+ * @param id scoped id of the resource
329
+ * @param scope scope in which this resource is defined
330
+ * @param props API operation properties
331
+ * @param resourceOptions Optional settings to control resource behaviour
332
+ * @see [Pulumi Azure Native API Management Operation]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apioperation/}
333
+ */
334
+ public createOperation(
335
+ id: string,
336
+ scope: CommonAzureConstruct,
337
+ props: ApiOperationProps,
338
+ resourceOptions?: ResourceOptions
339
+ ) {
340
+ return new ApiOperation(`${id}`, props, { parent: scope, ...resourceOptions })
341
+ }
341
342
 
342
- new ApiOperationPolicy(
343
- `${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`,
344
- {
345
- serviceName: props.serviceName!,
346
- resourceGroupName: props.resourceGroupName!,
347
- apiId: api.name,
348
- operationId: operationId,
349
- policyId: 'policy',
350
- value: policyXmlContent,
351
- format: PolicyContentFormat.Xml,
352
- },
353
- { parent: scope }
354
- )
355
- })
343
+ /**
344
+ * @summary Method to create a new API operation policy
345
+ * @param id scoped id of the resource
346
+ * @param scope scope in which this resource is defined
347
+ * @param props API operation policy properties
348
+ * @param resourceOptions Optional settings to control resource behaviour
349
+ * @see [Pulumi Azure Native API Management Operation Policy]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apioperationpolicy/}
350
+ */
351
+ public createOperationPolicy(
352
+ id: string,
353
+ scope: CommonAzureConstruct,
354
+ props: ApiOperationPolicyProps,
355
+ resourceOptions?: ResourceOptions
356
+ ) {
357
+ return new ApiOperationPolicy(`${id}`, props, { parent: scope, ...resourceOptions })
358
+ }
356
359
 
357
- return api
360
+ /**
361
+ * @summary Method to create a new API policy
362
+ * @param id scoped id of the resource
363
+ * @param scope scope in which this resource is defined
364
+ * @param props API policy properties
365
+ * @param resourceOptions Optional settings to control resource behaviour
366
+ * @see [Pulumi Azure Native API Management Policy]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apipolicy/}
367
+ */
368
+ public createPolicy(
369
+ id: string,
370
+ scope: CommonAzureConstruct,
371
+ props: ApiPolicyProps,
372
+ resourceOptions?: ResourceOptions
373
+ ) {
374
+ return new ApiPolicy(`${id}`, props, { parent: scope, ...resourceOptions })
358
375
  }
359
376
 
360
377
  /**
@@ -362,6 +379,7 @@ export class AzureApiManagementManager {
362
379
  * @param id scoped id of the resource
363
380
  * @param scope scope in which this resource is defined
364
381
  * @param props API Management custom domain properties
382
+ * @param resourceOptions Optional settings to control resource behaviour
365
383
  * @note In Pulumi Azure Native, custom domains are configured as part of the API Management service resource,
366
384
  * not as a separate resource. Use the hostnameConfigurations property when creating the service.
367
385
  */
@@ -370,8 +388,6 @@ export class AzureApiManagementManager {
370
388
  scope: CommonAzureConstruct,
371
389
  props: ApiManagementCustomDomainProps
372
390
  ) {
373
- if (!props) throw `Props undefined for ${id}`
374
-
375
391
  // Note: In Pulumi Azure Native, custom domains are part of the ApiManagementService
376
392
  // This method is provided for API compatibility but should be configured
377
393
  // via the hostnameConfigurations property of ApiManagementService instead