@gradientedge/cdk-utils 10.7.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 (198) 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 +39 -3
  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/stack.d.ts +2 -2
  124. package/dist/src/lib/cloudflare/common/stack.js +25 -25
  125. package/dist/src/lib/cloudflare/services/worker/main.js +8 -1
  126. package/dist/src/lib/cloudflare/services/worker/types.d.ts +1 -0
  127. package/package.json +26 -23
  128. package/src/lib/azure/common/constants.ts +83 -0
  129. package/src/lib/azure/common/construct.ts +49 -6
  130. package/src/lib/azure/common/stack.ts +26 -43
  131. package/src/lib/azure/common/types.ts +14 -2
  132. package/src/lib/azure/construct/event-handler/index.ts +2 -0
  133. package/src/lib/azure/construct/event-handler/main.ts +183 -0
  134. package/src/lib/azure/construct/event-handler/types.ts +49 -0
  135. package/src/lib/azure/construct/function-app/index.ts +2 -0
  136. package/src/lib/azure/construct/function-app/main.ts +410 -0
  137. package/src/lib/azure/construct/function-app/types.ts +45 -0
  138. package/src/lib/azure/construct/index.ts +6 -0
  139. package/src/lib/azure/construct/rest-api/index.ts +2 -0
  140. package/src/lib/azure/construct/rest-api/main.ts +205 -0
  141. package/src/lib/azure/construct/rest-api/types.ts +33 -0
  142. package/src/lib/azure/construct/rest-api-function/index.ts +2 -0
  143. package/src/lib/azure/construct/rest-api-function/main.ts +297 -0
  144. package/src/lib/azure/construct/rest-api-function/types.ts +39 -0
  145. package/src/lib/azure/construct/rest-api-with-cache/index.ts +2 -0
  146. package/src/lib/azure/construct/rest-api-with-cache/main.ts +75 -0
  147. package/src/lib/azure/construct/rest-api-with-cache/types.ts +15 -0
  148. package/src/lib/azure/construct/site-with-webapp/index.ts +2 -0
  149. package/src/lib/azure/construct/site-with-webapp/main.ts +160 -0
  150. package/src/lib/azure/construct/site-with-webapp/types.ts +33 -0
  151. package/src/lib/azure/index.ts +1 -0
  152. package/src/lib/azure/services/api-management/main.ts +168 -152
  153. package/src/lib/azure/services/api-management/types.ts +30 -1
  154. package/src/lib/azure/services/app-configuration/main.ts +29 -2
  155. package/src/lib/azure/services/app-service/main.ts +23 -4
  156. package/src/lib/azure/services/application-insights/main.ts +46 -7
  157. package/src/lib/azure/services/application-insights/types.ts +6 -2
  158. package/src/lib/azure/services/authorisation/constants.ts +13 -0
  159. package/src/lib/azure/services/authorisation/index.ts +3 -0
  160. package/src/lib/azure/services/authorisation/main.ts +202 -0
  161. package/src/lib/azure/services/authorisation/types.ts +3 -0
  162. package/src/lib/azure/services/cosmosdb/constants.ts +9 -0
  163. package/src/lib/azure/services/cosmosdb/index.ts +1 -0
  164. package/src/lib/azure/services/cosmosdb/main.ts +158 -8
  165. package/src/lib/azure/services/cosmosdb/types.ts +3 -0
  166. package/src/lib/azure/services/dns/main.ts +33 -8
  167. package/src/lib/azure/services/eventgrid/main.ts +41 -23
  168. package/src/lib/azure/services/function/main.ts +155 -9
  169. package/src/lib/azure/services/function/types.ts +3 -4
  170. package/src/lib/azure/services/index.ts +3 -0
  171. package/src/lib/azure/services/key-vault/main.ts +47 -4
  172. package/src/lib/azure/services/key-vault/types.ts +4 -4
  173. package/src/lib/azure/services/monitor/main.ts +5 -2
  174. package/src/lib/azure/services/operational-insights/main.ts +30 -4
  175. package/src/lib/azure/services/operational-insights/types.ts +3 -1
  176. package/src/lib/azure/services/portal/error.ts +12 -0
  177. package/src/lib/azure/services/portal/index.ts +4 -0
  178. package/src/lib/azure/services/portal/main.ts +81 -0
  179. package/src/lib/azure/services/portal/renderer.ts +182 -0
  180. package/src/lib/azure/services/portal/types.ts +45 -0
  181. package/src/lib/azure/services/redis/main.ts +10 -3
  182. package/src/lib/azure/services/redis/types.ts +1 -1
  183. package/src/lib/azure/services/resource-group/main.ts +34 -3
  184. package/src/lib/azure/services/security-center/index.ts +2 -0
  185. package/src/lib/azure/services/security-center/main.ts +42 -0
  186. package/src/lib/azure/services/security-center/types.ts +3 -0
  187. package/src/lib/azure/services/servicebus/main.ts +61 -30
  188. package/src/lib/azure/services/servicebus/types.ts +4 -4
  189. package/src/lib/azure/services/storage/main.ts +91 -9
  190. package/src/lib/azure/services/storage/types.ts +11 -2
  191. package/src/lib/cloudflare/common/stack.ts +25 -25
  192. package/src/lib/cloudflare/services/worker/main.ts +10 -1
  193. package/src/lib/cloudflare/services/worker/types.ts +8 -1
  194. package/dist/lib/lambda.d.ts +0 -17
  195. package/dist/lib/lambda.d.ts.map +0 -1
  196. package/dist/lib/lambda.js +0 -28
  197. package/dist/lib/lambda.js.map +0 -1
  198. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,182 @@
1
+ import appRoot from 'app-root-path'
2
+ import fs from 'fs'
3
+ import _ from 'lodash'
4
+ import path from 'path'
5
+ import { parse } from 'yaml'
6
+ import { TemplateError } from './error.js'
7
+ import { DashboardRenderer, MissingKeys, PaneTemplate, RenderParams } from './types.js'
8
+
9
+ export class AzureDashboardRenderer implements DashboardRenderer {
10
+ private readonly paneTemplatePath: string
11
+ private readonly outputDir: string
12
+
13
+ constructor(basePath?: string, outputDir?: string) {
14
+ this.paneTemplatePath = basePath ?? path.join(appRoot.path, 'template', 'dashboard')
15
+ this.outputDir = outputDir ?? path.join(appRoot.path, '.artifacts')
16
+ }
17
+
18
+ private getPaneId(id: string): PaneTemplate {
19
+ const panePath = `${this.paneTemplatePath}/${id}.yaml`
20
+ const paneFileContent = fs.readFileSync(panePath, 'utf-8')
21
+ const paneTemplate = parse(paneFileContent)
22
+ return paneTemplate
23
+ }
24
+
25
+ public getMissingProperties(template: PaneTemplate, properties: RenderParams['properties'] = []): MissingKeys {
26
+ const keys = Object.keys(template.properties).filter(key => !(key in properties))
27
+ return {
28
+ keys,
29
+ hasMissingKeys: keys.length !== 0,
30
+ }
31
+ }
32
+
33
+ public getMissingVariables(template: PaneTemplate, variables: RenderParams['variables']): MissingKeys {
34
+ const keys = Object.keys(template.variables).filter(key => !(key in variables))
35
+ return {
36
+ keys,
37
+ hasMissingKeys: keys.length !== 0,
38
+ }
39
+ }
40
+
41
+ public render(params: RenderParams): string {
42
+ _.templateSettings.interpolate = /{{([\s\S]+?)}}/g
43
+
44
+ // if client is used instead of hosts
45
+ let partsIndex = 0
46
+ let yIndex = 0
47
+ const parts: Record<string, any> = {}
48
+ for (const pane of params.panes) {
49
+ try {
50
+ const paneTemplate = this.getPaneId(pane.id)
51
+ const compiled = _.template(paneTemplate.template)
52
+
53
+ function getValue(value: string | number): string | number {
54
+ try {
55
+ if (typeof value === 'number') {
56
+ return value
57
+ }
58
+
59
+ if (value.includes(':')) {
60
+ const [property, formatter] = value.split(':')
61
+ const unformattedValue = _.get(params.properties, property)
62
+ if (formatter === 'host') {
63
+ const host = new URL(unformattedValue)
64
+ const port = host.protocol.startsWith('https') ? '443' : '80'
65
+ return `${host.host}:${port}`
66
+ }
67
+
68
+ return unformattedValue
69
+ }
70
+
71
+ return value
72
+ } catch (e) {
73
+ console.error('failed to process', value, 'with error', e)
74
+
75
+ return ''
76
+ }
77
+ }
78
+
79
+ const missingVariables = this.getMissingVariables(paneTemplate, params.variables)
80
+ if (missingVariables.hasMissingKeys) {
81
+ throw new TemplateError(
82
+ `Failed to render pane ${pane.id}: Missing required variables [${missingVariables.keys.join(', ')}] for template substitution.`
83
+ )
84
+ }
85
+
86
+ const paneProperties: Record<string, string | number | Array<string | number>> = {}
87
+ for (const [key, value] of Object.entries(pane.properties ?? {})) {
88
+ if (value === undefined || value === null) {
89
+ continue
90
+ }
91
+
92
+ let resolvedValue: string | number | Array<string | number> = ''
93
+ if (typeof value === 'string') {
94
+ resolvedValue = getValue(value)
95
+ }
96
+
97
+ if (Array.isArray(value)) {
98
+ resolvedValue = value.map(v => getValue(v))
99
+ }
100
+
101
+ paneProperties[key] = resolvedValue
102
+ }
103
+
104
+ const properties = { ...params.properties, yIndex, ...paneProperties }
105
+ const missingProperties = this.getMissingProperties(paneTemplate, properties)
106
+ if (missingProperties.hasMissingKeys) {
107
+ throw new TemplateError(
108
+ `Failed to render pane ${pane.id}: Missing required properties [${missingProperties.keys.join(', ')}] for template substitution.`
109
+ )
110
+ }
111
+ const paneContent = compiled(properties)
112
+ const paneJSON = JSON.parse(paneContent)
113
+ const templateParts = paneJSON.parts
114
+
115
+ for (const part of templateParts) {
116
+ parts[`${partsIndex}`] = part
117
+ partsIndex++
118
+ }
119
+ yIndex += paneTemplate.dimensions.height
120
+ } catch (e) {
121
+ if (TemplateError.isInstance(e)) {
122
+ throw e
123
+ }
124
+ console.error('failed to render pane', pane.id, 'with error', e)
125
+ }
126
+ }
127
+
128
+ const dashboard = {
129
+ lenses: {
130
+ '0': {
131
+ order: 0,
132
+ parts,
133
+ },
134
+ },
135
+ metadata: {
136
+ model: {
137
+ timeRange: {
138
+ value: {
139
+ relative: {
140
+ duration: 24,
141
+ timeUnit: 1,
142
+ },
143
+ },
144
+ type: 'MsPortalFx.Composition.Configuration.ValueTypes.TimeRange',
145
+ },
146
+ filterLocale: {
147
+ value: params.filter?.locale ?? 'en-us',
148
+ },
149
+ filters: {
150
+ value: {
151
+ MsPortalFx_TimeRange: {
152
+ model: {
153
+ format: params.filter?.timeFormat ?? 'utc',
154
+ granularity: params.filter?.timeGranularity ?? 'auto',
155
+ relative: params.filter?.timeRelative ?? '4h',
156
+ },
157
+ displayCache: {
158
+ name: 'UTC Time',
159
+ value: 'Past 4 hours',
160
+ },
161
+ filteredPartIds: [],
162
+ },
163
+ },
164
+ },
165
+ },
166
+ },
167
+ }
168
+
169
+ return JSON.stringify(dashboard, null, 2)
170
+ }
171
+
172
+ renderToFile(filename: string, params: RenderParams): string {
173
+ const templateOutput = this.render(params)
174
+ if (!fs.existsSync(this.outputDir)) {
175
+ fs.mkdirSync(this.outputDir, { recursive: true })
176
+ }
177
+ const filePath = path.join(this.outputDir, `${filename}.tftpl`)
178
+ fs.writeFileSync(filePath, templateOutput)
179
+
180
+ return filePath
181
+ }
182
+ }
@@ -0,0 +1,45 @@
1
+ import { DashboardArgs } from '@pulumi/azure-native/portal/index.js'
2
+
3
+ export type PaneTemplate = {
4
+ dimensions: { height: number }
5
+ properties: Record<string, string>
6
+ variables: Record<string, string>
7
+ template: string
8
+ }
9
+
10
+ export type MissingKeys = {
11
+ keys: Array<string>
12
+ hasMissingKeys: boolean
13
+ }
14
+
15
+ export type Pane = {
16
+ id: string
17
+ properties?: Record<string, string | number | Array<string | number>>
18
+ }
19
+
20
+ export type Filter = {
21
+ locale?: string
22
+ timeFormat?: string
23
+ timeGranularity?: string
24
+ timeRelative?: string
25
+ }
26
+
27
+ export type RenderParams = {
28
+ panes: Array<Pane>
29
+ variables: Record<string, any>
30
+ properties?: Record<string, any>
31
+ filter?: Filter
32
+ }
33
+
34
+ export interface DashboardRenderer {
35
+ render(params: RenderParams): string
36
+ renderToFile(filename: string, params: RenderParams): string
37
+ }
38
+
39
+ export interface PortalDashboardProps extends DashboardArgs {
40
+ displayName: string
41
+ panes: Array<Pane>
42
+ variables: Record<string, string>
43
+ filter?: Filter
44
+ enabled?: boolean
45
+ }
@@ -1,6 +1,7 @@
1
1
  import { Redis, SkuFamily, SkuName } from '@pulumi/azure-native/redis/index.js'
2
+ import { ResourceOptions } from '@pulumi/pulumi'
2
3
  import { CommonAzureConstruct } from '../../common/index.js'
3
- import { ManagedRedisProps } from './types.js'
4
+ import { RedisProps } from './types.js'
4
5
 
5
6
  /**
6
7
  * @classdesc Provides operations on Azure Redis using Pulumi
@@ -25,9 +26,15 @@ export class AzureRedisManager {
25
26
  * @param id scoped id of the resource
26
27
  * @param scope scope in which this resource is defined
27
28
  * @param props redis cache properties
29
+ * @param resourceOptions Optional settings to control resource behaviour
28
30
  * @see [Pulumi Azure Native Redis]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/cache/redis/}
29
31
  */
30
- public createManagedRedis(id: string, scope: CommonAzureConstruct, props: ManagedRedisProps) {
32
+ public createManagedRedis(
33
+ id: string,
34
+ scope: CommonAzureConstruct,
35
+ props: RedisProps,
36
+ resourceOptions?: ResourceOptions
37
+ ) {
31
38
  if (!props) throw `Props undefined for ${id}`
32
39
 
33
40
  // Get resource group name
@@ -53,7 +60,7 @@ export class AzureRedisManager {
53
60
  environment: scope.props.stage,
54
61
  },
55
62
  },
56
- { parent: scope }
63
+ { parent: scope, ...resourceOptions }
57
64
  )
58
65
  }
59
66
  }
@@ -1,3 +1,3 @@
1
1
  import { RedisArgs } from '@pulumi/azure-native/redis/index.js'
2
2
 
3
- export interface ManagedRedisProps extends RedisArgs {}
3
+ export interface RedisProps extends RedisArgs {}
@@ -1,4 +1,5 @@
1
- import { ResourceGroup } from '@pulumi/azure-native/resources/index.js'
1
+ import { getResourceGroupOutput, ResourceGroup } from '@pulumi/azure-native/resources/index.js'
2
+ import { ResourceOptions } from '@pulumi/pulumi'
2
3
  import { CommonAzureConstruct } from '../../common/index.js'
3
4
  import { ResourceGroupProps } from './types.js'
4
5
 
@@ -25,9 +26,15 @@ export class AzureResourceGroupManager {
25
26
  * @param id scoped id of the resource
26
27
  * @param scope scope in which this resource is defined
27
28
  * @param props resource group properties
29
+ * @param resourceOptions Optional settings to control resource behaviour
28
30
  * @see [Pulumi Azure Native Resource Group]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/resources/resourcegroup/}
29
31
  */
30
- public createResourceGroup(id: string, scope: CommonAzureConstruct, props: ResourceGroupProps) {
32
+ public createResourceGroup(
33
+ id: string,
34
+ scope: CommonAzureConstruct,
35
+ props: ResourceGroupProps,
36
+ resourceOptions?: ResourceOptions
37
+ ) {
31
38
  if (!props) throw `Props undefined for ${id}`
32
39
 
33
40
  return new ResourceGroup(
@@ -43,7 +50,31 @@ export class AzureResourceGroupManager {
43
50
  environment: scope.props.stage,
44
51
  },
45
52
  },
46
- { parent: scope }
53
+ { parent: scope, ...resourceOptions }
54
+ )
55
+ }
56
+
57
+ /**
58
+ * @summary Method to resolve an existing resource group
59
+ * @param scope scope in which this resource is defined
60
+ * @param resourceGroupName the resource group name
61
+ * @param resourceOptions Optional settings to control resource behaviour
62
+ */
63
+ public resolveResourceGroup(
64
+ scope: CommonAzureConstruct,
65
+ resourceGroupName: string,
66
+ resourceOptions?: ResourceOptions
67
+ ) {
68
+ if (!resourceGroupName) throw `Resource Group Name undefined`
69
+
70
+ return getResourceGroupOutput(
71
+ {
72
+ resourceGroupName: scope.resourceNameFormatter.format(
73
+ resourceGroupName?.toString(),
74
+ scope.props.resourceNameOptions?.resourceGroup
75
+ ),
76
+ },
77
+ { parent: scope, ...resourceOptions }
47
78
  )
48
79
  }
49
80
  }
@@ -0,0 +1,2 @@
1
+ export * from './main.js'
2
+ export * from './types.js'
@@ -0,0 +1,42 @@
1
+ import { DefenderForStorage } from '@pulumi/azure-native/security/index.js'
2
+ import { ResourceOptions } from '@pulumi/pulumi'
3
+ import { CommonAzureConstruct } from '../../common/index.js'
4
+ import { DefenderForStorageProps } from './types.js'
5
+
6
+ /**
7
+ * @classdesc Provides operations on Azure Security Center using Pulumi
8
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
9
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
10
+ * @example
11
+ * ```typescript
12
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomConstruct extends CommonAzureConstruct {
15
+ * constructor(name: string, props: CommonAzureStackProps) {
16
+ * super(name, props)
17
+ * this.props = props
18
+ * this.securityCenterManager.createDefenderForStorage('MyDefender', this, props)
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export class AzureSecurityCentermanager {
24
+ /**
25
+ * @summary Method to create a new defender for storage account
26
+ * @param id scoped id of the resource
27
+ * @param scope scope in which this resource is defined
28
+ * @param props defender for storage account properties
29
+ * @param resourceOptions Optional settings to control resource behaviour
30
+ * @see [Pulumi Azure Native Defender For Storage]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/security/defenderforstorage/}
31
+ */
32
+ public createDefenderForStorage(
33
+ id: string,
34
+ scope: CommonAzureConstruct,
35
+ props: DefenderForStorageProps,
36
+ resourceOptions?: ResourceOptions
37
+ ) {
38
+ if (!props) throw `Props undefined for ${id}`
39
+
40
+ return new DefenderForStorage(`${id}`, props, { parent: scope, ...resourceOptions })
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ import { DefenderForStorageArgs } from '@pulumi/azure-native/security/index.js'
2
+
3
+ export interface DefenderForStorageProps extends DefenderForStorageArgs {}
@@ -7,13 +7,14 @@ import {
7
7
  Subscription,
8
8
  Topic,
9
9
  } from '@pulumi/azure-native/servicebus/index.js'
10
+ import { ResourceOptions } from '@pulumi/pulumi'
10
11
  import { CommonAzureConstruct } from '../../common/index.js'
11
12
  import {
12
13
  ResolveServicebusQueueProps,
13
- ServicebusNamespaceProps,
14
- ServicebusQueueProps,
15
- ServicebusSubscriptionProps,
16
- ServicebusTopicProps,
14
+ ServiceBusNamespaceProps,
15
+ ServiceBusQueueProps,
16
+ ServiceBusSubscriptionProps,
17
+ ServiceBusTopicProps,
17
18
  } from './types.js'
18
19
 
19
20
  /**
@@ -33,15 +34,21 @@ import {
33
34
  * }
34
35
  * ```
35
36
  */
36
- export class AzureServicebusManager {
37
+ export class AzureServiceBusManager {
37
38
  /**
38
- * @summary Method to create a new servicebus namespace
39
+ * @summary Method to create a new service bus namespace
39
40
  * @param id scoped id of the resource
40
41
  * @param scope scope in which this resource is defined
41
- * @param props servicebus namespace properties
42
- * @see [Pulumi Azure Native Service Bus Namespace]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/namespace/}
42
+ * @param props service bus namespace properties
43
+ * @param resourceOptions Optional settings to control resource behaviour
44
+ * @see [Pulumi Azure Native Service Bus Namespace]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/namespace/}
43
45
  */
44
- public createServicebusNamespace(id: string, scope: CommonAzureConstruct, props: ServicebusNamespaceProps) {
46
+ public createServiceBusNamespace(
47
+ id: string,
48
+ scope: CommonAzureConstruct,
49
+ props: ServiceBusNamespaceProps,
50
+ resourceOptions?: ResourceOptions
51
+ ) {
45
52
  if (!props) throw `Props undefined for ${id}`
46
53
 
47
54
  // Get resource group name
@@ -71,18 +78,24 @@ export class AzureServicebusManager {
71
78
  environment: scope.props.stage,
72
79
  },
73
80
  },
74
- { parent: scope }
81
+ { parent: scope, ...resourceOptions }
75
82
  )
76
83
  }
77
84
 
78
85
  /**
79
- * @summary Method to create a new servicebus topic
86
+ * @summary Method to create a new service bus topic
80
87
  * @param id scoped id of the resource
81
88
  * @param scope scope in which this resource is defined
82
- * @param props servicebus topic properties
83
- * @see [Pulumi Azure Native Service Bus Topic]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/topic/}
89
+ * @param props service bus topic properties
90
+ * @param resourceOptions Optional settings to control resource behaviour
91
+ * @see [Pulumi Azure Native Service Bus Topic]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/topic/}
84
92
  */
85
- public createServicebusTopic(id: string, scope: CommonAzureConstruct, props: ServicebusTopicProps) {
93
+ public createServiceBusTopic(
94
+ id: string,
95
+ scope: CommonAzureConstruct,
96
+ props: ServiceBusTopicProps,
97
+ resourceOptions?: ResourceOptions
98
+ ) {
86
99
  if (!props) throw `Props undefined for ${id}`
87
100
 
88
101
  return new Topic(
@@ -96,18 +109,24 @@ export class AzureServicebusManager {
96
109
  namespaceName: props.namespaceName,
97
110
  resourceGroupName: props.resourceGroupName,
98
111
  },
99
- { parent: scope }
112
+ { parent: scope, ...resourceOptions }
100
113
  )
101
114
  }
102
115
 
103
116
  /**
104
- * @summary Method to create a new servicebus queue
117
+ * @summary Method to create a new service bus queue
105
118
  * @param id scoped id of the resource
106
119
  * @param scope scope in which this resource is defined
107
- * @param props servicebus queue properties
108
- * @see [Pulumi Azure Native Service Bus Queue]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/queue/}
120
+ * @param props service bus queue properties
121
+ * @param resourceOptions Optional settings to control resource behaviour
122
+ * @see [Pulumi Azure Native Service Bus Queue]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/queue/}
109
123
  */
110
- public createServicebusQueue(id: string, scope: CommonAzureConstruct, props: ServicebusQueueProps) {
124
+ public createServiceBusQueue(
125
+ id: string,
126
+ scope: CommonAzureConstruct,
127
+ props: ServiceBusQueueProps,
128
+ resourceOptions?: ResourceOptions
129
+ ) {
111
130
  if (!props) throw `Props undefined for ${id}`
112
131
 
113
132
  return new Queue(
@@ -125,18 +144,24 @@ export class AzureServicebusManager {
125
144
  deadLetteringOnMessageExpiration: props.deadLetteringOnMessageExpiration ?? true,
126
145
  defaultMessageTimeToLive: (props as any).defaultMessageTtl ?? 'P2D',
127
146
  },
128
- { parent: scope }
147
+ { parent: scope, ...resourceOptions }
129
148
  )
130
149
  }
131
150
 
132
151
  /**
133
- * @summary Method to create a new servicebus subscription
152
+ * @summary Method to create a new service bus subscription
134
153
  * @param id scoped id of the resource
135
154
  * @param scope scope in which this resource is defined
136
- * @param props servicebus subscription properties
137
- * @see [Pulumi Azure Native Service Bus Subscription]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/subscription/}
155
+ * @param props service bus subscription properties
156
+ * @param resourceOptions Optional settings to control resource behaviour
157
+ * @see [Pulumi Azure Native Service Bus Subscription]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/subscription/}
138
158
  */
139
- public createServicebusSubscription(id: string, scope: CommonAzureConstruct, props: ServicebusSubscriptionProps) {
159
+ public createServiceBusSubscription(
160
+ id: string,
161
+ scope: CommonAzureConstruct,
162
+ props: ServiceBusSubscriptionProps,
163
+ resourceOptions?: ResourceOptions
164
+ ) {
140
165
  if (!props) throw `Props undefined for ${id}`
141
166
 
142
167
  return new Subscription(
@@ -149,18 +174,24 @@ export class AzureServicebusManager {
149
174
  ),
150
175
  maxDeliveryCount: props.maxDeliveryCount ?? 1,
151
176
  },
152
- { parent: scope }
177
+ { parent: scope, ...resourceOptions }
153
178
  )
154
179
  }
155
180
 
156
181
  /**
157
- * @summary Method to resolve an existing servicebus queue
182
+ * @summary Method to resolve an existing service bus queue
158
183
  * @param id scoped id of the resource
159
184
  * @param scope scope in which this resource is defined
160
- * @param props servicebus queue properties for lookup
161
- * @see [Pulumi Azure Native Service Bus Queue Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/queue/}
185
+ * @param props service bus queue properties for lookup
186
+ * @param resourceOptions Optional settings to control resource behaviour
187
+ * @see [Pulumi Azure Native Service Bus Queue Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/queue/}
162
188
  */
163
- public resolveServicebusQueue(id: string, scope: CommonAzureConstruct, props: ResolveServicebusQueueProps) {
189
+ public resolveServiceBusQueue(
190
+ id: string,
191
+ scope: CommonAzureConstruct,
192
+ props: ResolveServicebusQueueProps,
193
+ resourceOptions?: ResourceOptions
194
+ ) {
164
195
  if (!props) throw `Props undefined for ${id}`
165
196
 
166
197
  return getQueueOutput(
@@ -172,7 +203,7 @@ export class AzureServicebusManager {
172
203
  namespaceName: props.namespaceName,
173
204
  resourceGroupName: props.resourceGroupName,
174
205
  },
175
- { parent: scope }
206
+ { parent: scope, ...resourceOptions }
176
207
  )
177
208
  }
178
209
  }
@@ -6,12 +6,12 @@ import {
6
6
  TopicArgs,
7
7
  } from '@pulumi/azure-native/servicebus/index.js'
8
8
 
9
- export interface ServicebusNamespaceProps extends NamespaceArgs {}
9
+ export interface ServiceBusNamespaceProps extends NamespaceArgs {}
10
10
 
11
- export interface ServicebusTopicProps extends TopicArgs {}
11
+ export interface ServiceBusTopicProps extends TopicArgs {}
12
12
 
13
- export interface ServicebusQueueProps extends QueueArgs {}
13
+ export interface ServiceBusQueueProps extends QueueArgs {}
14
14
 
15
- export interface ServicebusSubscriptionProps extends SubscriptionArgs {}
15
+ export interface ServiceBusSubscriptionProps extends SubscriptionArgs {}
16
16
 
17
17
  export interface ResolveServicebusQueueProps extends GetQueueOutputArgs {}