@gradientedge/cdk-utils-azure 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/common/constants.d.ts +83 -0
  3. package/dist/src/common/constants.js +87 -0
  4. package/dist/src/common/construct.d.ts +80 -0
  5. package/dist/src/common/construct.js +128 -0
  6. package/dist/src/common/index.d.ts +6 -0
  7. package/dist/src/common/index.js +6 -0
  8. package/dist/src/common/resource-name-formatter.d.ts +18 -0
  9. package/dist/src/common/resource-name-formatter.js +34 -0
  10. package/dist/src/common/stack.d.ts +46 -0
  11. package/dist/src/common/stack.js +120 -0
  12. package/dist/src/common/tagging.d.ts +29 -0
  13. package/dist/src/common/tagging.js +78 -0
  14. package/dist/src/common/types.d.ts +57 -0
  15. package/dist/src/common/types.js +1 -0
  16. package/dist/src/construct/event-handler/index.d.ts +2 -0
  17. package/dist/src/construct/event-handler/index.js +2 -0
  18. package/dist/src/construct/event-handler/main.d.ts +61 -0
  19. package/dist/src/construct/event-handler/main.js +180 -0
  20. package/dist/src/construct/event-handler/types.d.ts +35 -0
  21. package/dist/src/construct/event-handler/types.js +1 -0
  22. package/dist/src/construct/function-app/index.d.ts +2 -0
  23. package/dist/src/construct/function-app/index.js +2 -0
  24. package/dist/src/construct/function-app/main.d.ts +128 -0
  25. package/dist/src/construct/function-app/main.js +374 -0
  26. package/dist/src/construct/function-app/types.d.ts +33 -0
  27. package/dist/src/construct/function-app/types.js +1 -0
  28. package/dist/src/construct/index.d.ts +6 -0
  29. package/dist/src/construct/index.js +6 -0
  30. package/dist/src/construct/rest-api/index.d.ts +2 -0
  31. package/dist/src/construct/rest-api/index.js +2 -0
  32. package/dist/src/construct/rest-api/main.d.ts +64 -0
  33. package/dist/src/construct/rest-api/main.js +216 -0
  34. package/dist/src/construct/rest-api/types.d.ts +25 -0
  35. package/dist/src/construct/rest-api/types.js +1 -0
  36. package/dist/src/construct/rest-api-function/index.d.ts +2 -0
  37. package/dist/src/construct/rest-api-function/index.js +2 -0
  38. package/dist/src/construct/rest-api-function/main.d.ts +66 -0
  39. package/dist/src/construct/rest-api-function/main.js +302 -0
  40. package/dist/src/construct/rest-api-function/types.d.ts +29 -0
  41. package/dist/src/construct/rest-api-function/types.js +1 -0
  42. package/dist/src/construct/rest-api-with-cache/index.d.ts +2 -0
  43. package/dist/src/construct/rest-api-with-cache/index.js +2 -0
  44. package/dist/src/construct/rest-api-with-cache/main.d.ts +41 -0
  45. package/dist/src/construct/rest-api-with-cache/main.js +85 -0
  46. package/dist/src/construct/rest-api-with-cache/types.d.ts +13 -0
  47. package/dist/src/construct/rest-api-with-cache/types.js +1 -0
  48. package/dist/src/construct/site-with-webapp/index.d.ts +2 -0
  49. package/dist/src/construct/site-with-webapp/index.js +2 -0
  50. package/dist/src/construct/site-with-webapp/main.d.ts +60 -0
  51. package/dist/src/construct/site-with-webapp/main.js +176 -0
  52. package/dist/src/construct/site-with-webapp/types.d.ts +30 -0
  53. package/dist/src/construct/site-with-webapp/types.js +1 -0
  54. package/dist/src/index.d.ts +4 -0
  55. package/dist/src/index.js +4 -0
  56. package/dist/src/services/api-management/index.d.ts +2 -0
  57. package/dist/src/services/api-management/index.js +2 -0
  58. package/dist/src/services/api-management/main.d.ts +143 -0
  59. package/dist/src/services/api-management/main.js +244 -0
  60. package/dist/src/services/api-management/types.d.ts +72 -0
  61. package/dist/src/services/api-management/types.js +1 -0
  62. package/dist/src/services/app-configuration/index.d.ts +2 -0
  63. package/dist/src/services/app-configuration/index.js +2 -0
  64. package/dist/src/services/app-configuration/main.d.ts +41 -0
  65. package/dist/src/services/app-configuration/main.js +71 -0
  66. package/dist/src/services/app-configuration/types.d.ts +3 -0
  67. package/dist/src/services/app-configuration/types.js +1 -0
  68. package/dist/src/services/app-service/index.d.ts +2 -0
  69. package/dist/src/services/app-service/index.js +2 -0
  70. package/dist/src/services/app-service/main.d.ts +40 -0
  71. package/dist/src/services/app-service/main.js +90 -0
  72. package/dist/src/services/app-service/types.d.ts +6 -0
  73. package/dist/src/services/app-service/types.js +1 -0
  74. package/dist/src/services/application-insights/index.d.ts +2 -0
  75. package/dist/src/services/application-insights/index.js +2 -0
  76. package/dist/src/services/application-insights/main.d.ts +40 -0
  77. package/dist/src/services/application-insights/main.js +68 -0
  78. package/dist/src/services/application-insights/types.d.ts +6 -0
  79. package/dist/src/services/application-insights/types.js +1 -0
  80. package/dist/src/services/authorisation/constants.d.ts +13 -0
  81. package/dist/src/services/authorisation/constants.js +14 -0
  82. package/dist/src/services/authorisation/index.d.ts +3 -0
  83. package/dist/src/services/authorisation/index.js +3 -0
  84. package/dist/src/services/authorisation/main.d.ts +84 -0
  85. package/dist/src/services/authorisation/main.js +120 -0
  86. package/dist/src/services/authorisation/types.d.ts +3 -0
  87. package/dist/src/services/authorisation/types.js +1 -0
  88. package/dist/src/services/cosmosdb/constants.d.ts +8 -0
  89. package/dist/src/services/cosmosdb/constants.js +10 -0
  90. package/dist/src/services/cosmosdb/index.d.ts +3 -0
  91. package/dist/src/services/cosmosdb/index.js +3 -0
  92. package/dist/src/services/cosmosdb/main.d.ts +87 -0
  93. package/dist/src/services/cosmosdb/main.js +162 -0
  94. package/dist/src/services/cosmosdb/types.d.ts +9 -0
  95. package/dist/src/services/cosmosdb/types.js +1 -0
  96. package/dist/src/services/dns/index.d.ts +2 -0
  97. package/dist/src/services/dns/index.js +2 -0
  98. package/dist/src/services/dns/main.d.ts +58 -0
  99. package/dist/src/services/dns/main.js +107 -0
  100. package/dist/src/services/dns/types.d.ts +9 -0
  101. package/dist/src/services/dns/types.js +1 -0
  102. package/dist/src/services/eventgrid/index.d.ts +2 -0
  103. package/dist/src/services/eventgrid/index.js +2 -0
  104. package/dist/src/services/eventgrid/main.d.ts +69 -0
  105. package/dist/src/services/eventgrid/main.js +136 -0
  106. package/dist/src/services/eventgrid/types.d.ts +11 -0
  107. package/dist/src/services/eventgrid/types.js +1 -0
  108. package/dist/src/services/function/index.d.ts +2 -0
  109. package/dist/src/services/function/index.js +2 -0
  110. package/dist/src/services/function/main.d.ts +60 -0
  111. package/dist/src/services/function/main.js +223 -0
  112. package/dist/src/services/function/types.d.ts +20 -0
  113. package/dist/src/services/function/types.js +1 -0
  114. package/dist/src/services/index.d.ts +18 -0
  115. package/dist/src/services/index.js +18 -0
  116. package/dist/src/services/key-vault/index.d.ts +2 -0
  117. package/dist/src/services/key-vault/index.js +2 -0
  118. package/dist/src/services/key-vault/main.d.ts +49 -0
  119. package/dist/src/services/key-vault/main.js +83 -0
  120. package/dist/src/services/key-vault/types.d.ts +5 -0
  121. package/dist/src/services/key-vault/types.js +1 -0
  122. package/dist/src/services/monitor/index.d.ts +2 -0
  123. package/dist/src/services/monitor/index.js +2 -0
  124. package/dist/src/services/monitor/main.d.ts +31 -0
  125. package/dist/src/services/monitor/main.js +36 -0
  126. package/dist/src/services/monitor/types.d.ts +3 -0
  127. package/dist/src/services/monitor/types.js +1 -0
  128. package/dist/src/services/operational-insights/index.d.ts +2 -0
  129. package/dist/src/services/operational-insights/index.js +2 -0
  130. package/dist/src/services/operational-insights/main.d.ts +40 -0
  131. package/dist/src/services/operational-insights/main.js +64 -0
  132. package/dist/src/services/operational-insights/types.d.ts +5 -0
  133. package/dist/src/services/operational-insights/types.js +1 -0
  134. package/dist/src/services/portal/error.d.ts +5 -0
  135. package/dist/src/services/portal/error.js +10 -0
  136. package/dist/src/services/portal/index.d.ts +4 -0
  137. package/dist/src/services/portal/index.js +4 -0
  138. package/dist/src/services/portal/main.d.ts +33 -0
  139. package/dist/src/services/portal/main.js +51 -0
  140. package/dist/src/services/portal/renderer.d.ts +11 -0
  141. package/dist/src/services/portal/renderer.js +156 -0
  142. package/dist/src/services/portal/types.d.ts +40 -0
  143. package/dist/src/services/portal/types.js +1 -0
  144. package/dist/src/services/redis/index.d.ts +2 -0
  145. package/dist/src/services/redis/index.js +2 -0
  146. package/dist/src/services/redis/main.d.ts +31 -0
  147. package/dist/src/services/redis/main.js +52 -0
  148. package/dist/src/services/redis/types.d.ts +3 -0
  149. package/dist/src/services/redis/types.js +1 -0
  150. package/dist/src/services/resource-group/index.d.ts +2 -0
  151. package/dist/src/services/resource-group/index.js +2 -0
  152. package/dist/src/services/resource-group/main.d.ts +38 -0
  153. package/dist/src/services/resource-group/main.js +53 -0
  154. package/dist/src/services/resource-group/types.d.ts +3 -0
  155. package/dist/src/services/resource-group/types.js +1 -0
  156. package/dist/src/services/security-center/index.d.ts +2 -0
  157. package/dist/src/services/security-center/index.js +2 -0
  158. package/dist/src/services/security-center/main.d.ts +31 -0
  159. package/dist/src/services/security-center/main.js +33 -0
  160. package/dist/src/services/security-center/types.d.ts +3 -0
  161. package/dist/src/services/security-center/types.js +1 -0
  162. package/dist/src/services/servicebus/index.d.ts +2 -0
  163. package/dist/src/services/servicebus/index.js +2 -0
  164. package/dist/src/services/servicebus/main.d.ts +67 -0
  165. package/dist/src/services/servicebus/main.js +127 -0
  166. package/dist/src/services/servicebus/types.d.ts +11 -0
  167. package/dist/src/services/servicebus/types.js +1 -0
  168. package/dist/src/services/storage/index.d.ts +2 -0
  169. package/dist/src/services/storage/index.js +2 -0
  170. package/dist/src/services/storage/main.d.ts +88 -0
  171. package/dist/src/services/storage/main.js +173 -0
  172. package/dist/src/services/storage/types.d.ts +20 -0
  173. package/dist/src/services/storage/types.js +1 -0
  174. package/dist/src/types/index.d.ts +4 -0
  175. package/dist/src/types/index.js +1 -0
  176. package/package.json +41 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Gradient Edge, https://github.com/gradientedge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ export declare enum AzureRemoteBackend {
2
+ azurerm = "azurerm",
3
+ pulumi = "pulumi",
4
+ local = "local"
5
+ }
6
+ /**
7
+ * List of Azure resources that excludes tags
8
+ */
9
+ export declare const RESOURCES_TO_EXCLUDE_TAGS: Set<string>;
10
+ /**
11
+ * @see https://learn.microsoft.com/en-us/azure/reliability/regions-list?tabs=all
12
+ */
13
+ export declare const AzureLocation: {
14
+ readonly BrazilSouth: "brazilsouth";
15
+ readonly BrazilSoutheast: "brazilsoutheast";
16
+ readonly CanadaCentral: "canadacentral";
17
+ readonly CanadaEast: "canadaeast";
18
+ readonly CentralUS: "centralus";
19
+ readonly EastUS: "eastus";
20
+ readonly EastUS2: "eastus2";
21
+ readonly MexicoCentral: "mexicocentral";
22
+ readonly NorthCentralUS: "northcentralus";
23
+ readonly SouthCentralUS: "southcentralus";
24
+ readonly USGovArizona: "usgovarizona";
25
+ readonly USGovTexas: "usgovtexas";
26
+ readonly USGovVirginia: "usgovvirginia";
27
+ readonly WestCentralUS: "westcentralus";
28
+ readonly WestUS: "westus";
29
+ readonly WestUS2: "westus2";
30
+ readonly WestUS3: "westus3";
31
+ readonly AustriaCentral: "austriacentral";
32
+ readonly BelgiumCentral: "belgiumcentral";
33
+ readonly DenmarkEast: "denmarkeast";
34
+ readonly FinlandCentral: "finlandcentral";
35
+ readonly FranceCentral: "francecentral";
36
+ readonly FranceSouth: "francesouth";
37
+ readonly GermanyNorth: "germanynorth";
38
+ readonly GermanyWestCentral: "germanywestcentral";
39
+ readonly GreeceHydra: "greecehydra";
40
+ readonly ItalyNorth: "italynorth";
41
+ readonly NorthEurope: "northeurope";
42
+ readonly NorwayEast: "norwayeast";
43
+ readonly NorwayWest: "norwaywest";
44
+ readonly PolandCentral: "polandcentral";
45
+ readonly SpainCentral: "spaincentral";
46
+ readonly SwedenCentral: "swedencentral";
47
+ readonly SwedenSouth: "swedensouth";
48
+ readonly SwitzerlandNorth: "switzerlandnorth";
49
+ readonly SwitzerlandWest: "switzerlandwest";
50
+ readonly UKSouth: "uksouth";
51
+ readonly UKWest: "ukwest";
52
+ readonly WestEurope: "westeurope";
53
+ readonly IsraelCentral: "israelcentral";
54
+ readonly QatarCentral: "qatarcentral";
55
+ readonly SouthAfricaNorth: "southafricanorth";
56
+ readonly SouthAfricaWest: "southafricawest";
57
+ readonly UAECentral: "uaecentral";
58
+ readonly UAENorth: "uaenorth";
59
+ readonly AustraliaCentral: "australiacentral";
60
+ readonly AustraliaCentral2: "australiacentral2";
61
+ readonly AustraliaEast: "australiaeast";
62
+ readonly AustraliaSoutheast: "australiasoutheast";
63
+ readonly CentralIndia: "centralindia";
64
+ readonly ChinaEast: "chinaeast";
65
+ readonly ChinaEast2: "chinaeast2";
66
+ readonly ChinaNorth: "chinanorth";
67
+ readonly ChinaNorth2: "chinanorth2";
68
+ readonly ChinaNorth3: "chinanorth3";
69
+ readonly EastAsia: "eastasia";
70
+ readonly JapanEast: "japaneast";
71
+ readonly JapanWest: "japanwest";
72
+ readonly KoreaCentral: "koreacentral";
73
+ readonly KoreaSouth: "koreasouth";
74
+ readonly MalaysiaSouth: "malaysiasouth";
75
+ readonly MalaysiaWest: "malaysiawest";
76
+ readonly NewZealandNorth: "newzealandnorth";
77
+ readonly SoutheastAsia: "southeastasia";
78
+ readonly SouthIndia: "southindia";
79
+ readonly TaiwanNorth: "taiwannorth";
80
+ readonly TaiwanNorthwest: "taiwannorthwest";
81
+ readonly WestIndia: "westindia";
82
+ };
83
+ export type AzureLocation = (typeof AzureLocation)[keyof typeof AzureLocation];
@@ -0,0 +1,87 @@
1
+ export var AzureRemoteBackend;
2
+ (function (AzureRemoteBackend) {
3
+ AzureRemoteBackend["azurerm"] = "azurerm";
4
+ AzureRemoteBackend["pulumi"] = "pulumi";
5
+ AzureRemoteBackend["local"] = "local";
6
+ })(AzureRemoteBackend || (AzureRemoteBackend = {}));
7
+ /**
8
+ * List of Azure resources that excludes tags
9
+ */
10
+ export const RESOURCES_TO_EXCLUDE_TAGS = new Set(['ApiManagementNamedValue', 'Application', 'ServicePrincipal']);
11
+ /**
12
+ * @see https://learn.microsoft.com/en-us/azure/reliability/regions-list?tabs=all
13
+ */
14
+ export const AzureLocation = {
15
+ // Americas
16
+ BrazilSouth: 'brazilsouth',
17
+ BrazilSoutheast: 'brazilsoutheast',
18
+ CanadaCentral: 'canadacentral',
19
+ CanadaEast: 'canadaeast',
20
+ CentralUS: 'centralus',
21
+ EastUS: 'eastus',
22
+ EastUS2: 'eastus2',
23
+ MexicoCentral: 'mexicocentral',
24
+ NorthCentralUS: 'northcentralus',
25
+ SouthCentralUS: 'southcentralus',
26
+ USGovArizona: 'usgovarizona',
27
+ USGovTexas: 'usgovtexas',
28
+ USGovVirginia: 'usgovvirginia',
29
+ WestCentralUS: 'westcentralus',
30
+ WestUS: 'westus',
31
+ WestUS2: 'westus2',
32
+ WestUS3: 'westus3',
33
+ // Europe
34
+ AustriaCentral: 'austriacentral',
35
+ BelgiumCentral: 'belgiumcentral',
36
+ DenmarkEast: 'denmarkeast',
37
+ FinlandCentral: 'finlandcentral',
38
+ FranceCentral: 'francecentral',
39
+ FranceSouth: 'francesouth',
40
+ GermanyNorth: 'germanynorth',
41
+ GermanyWestCentral: 'germanywestcentral',
42
+ GreeceHydra: 'greecehydra',
43
+ ItalyNorth: 'italynorth',
44
+ NorthEurope: 'northeurope',
45
+ NorwayEast: 'norwayeast',
46
+ NorwayWest: 'norwaywest',
47
+ PolandCentral: 'polandcentral',
48
+ SpainCentral: 'spaincentral',
49
+ SwedenCentral: 'swedencentral',
50
+ SwedenSouth: 'swedensouth',
51
+ SwitzerlandNorth: 'switzerlandnorth',
52
+ SwitzerlandWest: 'switzerlandwest',
53
+ UKSouth: 'uksouth',
54
+ UKWest: 'ukwest',
55
+ WestEurope: 'westeurope',
56
+ // Middle East & Africa
57
+ IsraelCentral: 'israelcentral',
58
+ QatarCentral: 'qatarcentral',
59
+ SouthAfricaNorth: 'southafricanorth',
60
+ SouthAfricaWest: 'southafricawest',
61
+ UAECentral: 'uaecentral',
62
+ UAENorth: 'uaenorth',
63
+ // Asia Pacific
64
+ AustraliaCentral: 'australiacentral',
65
+ AustraliaCentral2: 'australiacentral2',
66
+ AustraliaEast: 'australiaeast',
67
+ AustraliaSoutheast: 'australiasoutheast',
68
+ CentralIndia: 'centralindia',
69
+ ChinaEast: 'chinaeast',
70
+ ChinaEast2: 'chinaeast2',
71
+ ChinaNorth: 'chinanorth',
72
+ ChinaNorth2: 'chinanorth2',
73
+ ChinaNorth3: 'chinanorth3',
74
+ EastAsia: 'eastasia',
75
+ JapanEast: 'japaneast',
76
+ JapanWest: 'japanwest',
77
+ KoreaCentral: 'koreacentral',
78
+ KoreaSouth: 'koreasouth',
79
+ MalaysiaSouth: 'malaysiasouth',
80
+ MalaysiaWest: 'malaysiawest',
81
+ NewZealandNorth: 'newzealandnorth',
82
+ SoutheastAsia: 'southeastasia',
83
+ SouthIndia: 'southindia',
84
+ TaiwanNorth: 'taiwannorth',
85
+ TaiwanNorthwest: 'taiwannorthwest',
86
+ WestIndia: 'westindia',
87
+ };
@@ -0,0 +1,80 @@
1
+ import { GetWorkspaceResult, Workspace } from '@pulumi/azure-native/operationalinsights/index.js';
2
+ import { ResourceGroup } from '@pulumi/azure-native/resources/index.js';
3
+ import * as pulumi from '@pulumi/pulumi';
4
+ import { ComponentResource, ComponentResourceOptions, Output } from '@pulumi/pulumi';
5
+ import { AzureAuthorisationManager } from '../services/authorisation/main.js';
6
+ import { AzureApiManagementManager, AzureAppConfigurationManager, AzureApplicationInsightsManager, AzureAppServiceManager, AzureCosmosDbManager, AzureDnsManager, AzureEventgridManager, AzureFunctionManager, AzureKeyVaultManager, AzureMonitorManager, AzureOperationalInsightsManager, AzurePortalManager, AzureRedisManager, AzureResourceGroupManager, AzureSecurityCentermanager, AzureServiceBusManager, AzureStorageManager } from '../services/index.js';
7
+ import { AzureResourceNameFormatter } from './resource-name-formatter.js';
8
+ import { CommonAzureStackProps } from './types.js';
9
+ /**
10
+ * @classdesc Common Azure construct to use as a base for all higher level constructs using Pulumi
11
+ * - Provides manager instances for all Azure services
12
+ * - Handles resource naming conventions
13
+ * - Manages common properties and utilities
14
+ * @example
15
+ * ```typescript
16
+ * import { CommonAzureConstruct } from '@gradientedge/cdk-utils'
17
+ *
18
+ * class CustomConstruct extends CommonAzureConstruct {
19
+ * constructor(name: string, props: CommonAzureStackProps) {
20
+ * super(name, props)
21
+ * // provision resources using this.resourceGroupManager, etc.
22
+ * }
23
+ * }
24
+ * ```
25
+ */
26
+ export declare class CommonAzureConstruct extends ComponentResource {
27
+ props: CommonAzureStackProps;
28
+ options?: ComponentResourceOptions;
29
+ id: string;
30
+ resourceGroup: ResourceGroup;
31
+ fullyQualifiedDomainName: string;
32
+ authorisationManager: AzureAuthorisationManager;
33
+ apiManagementManager: AzureApiManagementManager;
34
+ appConfigurationManager: AzureAppConfigurationManager;
35
+ appServiceManager: AzureAppServiceManager;
36
+ applicationInsightsManager: AzureApplicationInsightsManager;
37
+ cosmosDbManager: AzureCosmosDbManager;
38
+ dnsManager: AzureDnsManager;
39
+ eventgridManager: AzureEventgridManager;
40
+ functionManager: AzureFunctionManager;
41
+ keyVaultManager: AzureKeyVaultManager;
42
+ operationalInsightsManager: AzureOperationalInsightsManager;
43
+ portalManager: AzurePortalManager;
44
+ monitorManager: AzureMonitorManager;
45
+ redisManager: AzureRedisManager;
46
+ resourceGroupManager: AzureResourceGroupManager;
47
+ resourceNameFormatter: AzureResourceNameFormatter;
48
+ securityCentermanager: AzureSecurityCentermanager;
49
+ serviceBusManager: AzureServiceBusManager;
50
+ storageManager: AzureStorageManager;
51
+ commonLogAnalyticsWorkspace: Workspace | Output<GetWorkspaceResult>;
52
+ constructor(name: string, props: CommonAzureStackProps, options?: ComponentResourceOptions);
53
+ protected resolveStack(stackName: string): pulumi.StackReference;
54
+ protected createResourceGroup(): void;
55
+ protected resolveCommonLogAnalyticsWorkspace(): void;
56
+ /**
57
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
58
+ */
59
+ protected determineFullyQualifiedDomain(): void;
60
+ /**
61
+ * @summary Utility method to determine if the initialisation is in development (dev) stage
62
+ * This is determined by the stage property injected via cdk context
63
+ */
64
+ isDevelopmentStage: () => boolean;
65
+ /**
66
+ * @summary Utility method to determine if the initialisation is in test (tst) stage
67
+ * This is determined by the stage property injected via cdk context
68
+ */
69
+ isTestStage: () => boolean;
70
+ /**
71
+ * @summary Utility method to determine if the initialisation is in uat (uat) stage
72
+ * This is determined by the stage property injected via cdk context
73
+ */
74
+ isUatStage: () => boolean;
75
+ /**
76
+ * @summary Utility method to determine if the initialisation is in production (prd) stage
77
+ * This is determined by the stage property injected via cdk context
78
+ */
79
+ isProductionStage: () => boolean;
80
+ }
@@ -0,0 +1,128 @@
1
+ import { getWorkspaceOutput } from '@pulumi/azure-native/operationalinsights/index.js';
2
+ import * as pulumi from '@pulumi/pulumi';
3
+ import { ComponentResource } from '@pulumi/pulumi';
4
+ import { isDevStage, isPrdStage, isTestStage, isUatStage } from '@gradientedge/cdk-utils-common';
5
+ import { AzureAuthorisationManager } from '../services/authorisation/main.js';
6
+ import { AzureApiManagementManager, AzureAppConfigurationManager, AzureApplicationInsightsManager, AzureAppServiceManager, AzureCosmosDbManager, AzureDnsManager, AzureEventgridManager, AzureFunctionManager, AzureKeyVaultManager, AzureMonitorManager, AzureOperationalInsightsManager, AzurePortalManager, AzureRedisManager, AzureResourceGroupManager, AzureSecurityCentermanager, AzureServiceBusManager, AzureStorageManager, } from '../services/index.js';
7
+ import { AzureResourceNameFormatter } from './resource-name-formatter.js';
8
+ /**
9
+ * @classdesc Common Azure construct to use as a base for all higher level constructs using Pulumi
10
+ * - Provides manager instances for all Azure services
11
+ * - Handles resource naming conventions
12
+ * - Manages common properties and utilities
13
+ * @example
14
+ * ```typescript
15
+ * import { CommonAzureConstruct } from '@gradientedge/cdk-utils'
16
+ *
17
+ * class CustomConstruct extends CommonAzureConstruct {
18
+ * constructor(name: string, props: CommonAzureStackProps) {
19
+ * super(name, props)
20
+ * // provision resources using this.resourceGroupManager, etc.
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ export class CommonAzureConstruct extends ComponentResource {
26
+ id;
27
+ resourceGroup;
28
+ fullyQualifiedDomainName;
29
+ authorisationManager;
30
+ apiManagementManager;
31
+ appConfigurationManager;
32
+ appServiceManager;
33
+ applicationInsightsManager;
34
+ cosmosDbManager;
35
+ dnsManager;
36
+ eventgridManager;
37
+ functionManager;
38
+ keyVaultManager;
39
+ operationalInsightsManager;
40
+ portalManager;
41
+ monitorManager;
42
+ redisManager;
43
+ resourceGroupManager;
44
+ resourceNameFormatter;
45
+ securityCentermanager;
46
+ serviceBusManager;
47
+ storageManager;
48
+ commonLogAnalyticsWorkspace;
49
+ constructor(name, props, options) {
50
+ super(`azure:${name}`, name, props, options);
51
+ this.props = props;
52
+ this.options = options;
53
+ this.id = name;
54
+ this.authorisationManager = new AzureAuthorisationManager();
55
+ this.apiManagementManager = new AzureApiManagementManager();
56
+ this.appConfigurationManager = new AzureAppConfigurationManager();
57
+ this.appServiceManager = new AzureAppServiceManager();
58
+ this.applicationInsightsManager = new AzureApplicationInsightsManager();
59
+ this.cosmosDbManager = new AzureCosmosDbManager();
60
+ this.dnsManager = new AzureDnsManager();
61
+ this.eventgridManager = new AzureEventgridManager();
62
+ this.functionManager = new AzureFunctionManager();
63
+ this.keyVaultManager = new AzureKeyVaultManager();
64
+ this.operationalInsightsManager = new AzureOperationalInsightsManager();
65
+ this.portalManager = new AzurePortalManager();
66
+ this.monitorManager = new AzureMonitorManager();
67
+ this.redisManager = new AzureRedisManager();
68
+ this.resourceGroupManager = new AzureResourceGroupManager();
69
+ this.resourceNameFormatter = new AzureResourceNameFormatter(props);
70
+ this.securityCentermanager = new AzureSecurityCentermanager();
71
+ this.serviceBusManager = new AzureServiceBusManager();
72
+ this.storageManager = new AzureStorageManager();
73
+ this.determineFullyQualifiedDomain();
74
+ }
75
+ resolveStack(stackName) {
76
+ if (!stackName)
77
+ throw 'Stack name undefined';
78
+ return new pulumi.StackReference(stackName);
79
+ }
80
+ createResourceGroup() {
81
+ if (this.resourceGroup)
82
+ return;
83
+ this.resourceGroup = this.resourceGroupManager.createResourceGroup(`${this.id}`, this, {
84
+ resourceGroupName: this.props.stackName,
85
+ location: this.props.location,
86
+ });
87
+ this.registerOutputs({
88
+ resourceGroupId: this.resourceGroup.id,
89
+ resourceGroupName: this.resourceGroup.name,
90
+ });
91
+ }
92
+ resolveCommonLogAnalyticsWorkspace() {
93
+ if (!this.props.commonLogAnalyticsWorkspace || !this.props.commonLogAnalyticsWorkspace.workspaceName)
94
+ throw 'Props undefined for commonLogAnalyticsWorkspace';
95
+ this.commonLogAnalyticsWorkspace = getWorkspaceOutput({
96
+ workspaceName: this.props.commonLogAnalyticsWorkspace.workspaceName,
97
+ resourceGroupName: this.props.commonLogAnalyticsWorkspace.resourceGroupName,
98
+ });
99
+ }
100
+ /**
101
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
102
+ */
103
+ determineFullyQualifiedDomain() {
104
+ this.fullyQualifiedDomainName = this.props.subDomain
105
+ ? `${this.props.subDomain}.${this.props.domainName}`
106
+ : this.props.domainName;
107
+ }
108
+ /**
109
+ * @summary Utility method to determine if the initialisation is in development (dev) stage
110
+ * This is determined by the stage property injected via cdk context
111
+ */
112
+ isDevelopmentStage = () => isDevStage(this.props.stage);
113
+ /**
114
+ * @summary Utility method to determine if the initialisation is in test (tst) stage
115
+ * This is determined by the stage property injected via cdk context
116
+ */
117
+ isTestStage = () => isTestStage(this.props.stage);
118
+ /**
119
+ * @summary Utility method to determine if the initialisation is in uat (uat) stage
120
+ * This is determined by the stage property injected via cdk context
121
+ */
122
+ isUatStage = () => isUatStage(this.props.stage);
123
+ /**
124
+ * @summary Utility method to determine if the initialisation is in production (prd) stage
125
+ * This is determined by the stage property injected via cdk context
126
+ */
127
+ isProductionStage = () => isPrdStage(this.props.stage);
128
+ }
@@ -0,0 +1,6 @@
1
+ export * from './constants.js';
2
+ export * from './construct.js';
3
+ export * from './resource-name-formatter.js';
4
+ export * from './stack.js';
5
+ export * from './tagging.js';
6
+ export * from './types.js';
@@ -0,0 +1,6 @@
1
+ export * from './constants.js';
2
+ export * from './construct.js';
3
+ export * from './resource-name-formatter.js';
4
+ export * from './stack.js';
5
+ export * from './tagging.js';
6
+ export * from './types.js';
@@ -0,0 +1,18 @@
1
+ import { AzureResourceNameFormatterProps, CommonAzureStackProps } from '../index.js';
2
+ /**
3
+ * @classdesc Formats Azure resource names according to naming conventions
4
+ * - Applies global/resource prefixes and suffixes
5
+ * - Automatically appends stage to resource names
6
+ * - Supports per-resource customization via options
7
+ */
8
+ export declare class AzureResourceNameFormatter {
9
+ props: CommonAzureStackProps;
10
+ constructor(props: CommonAzureStackProps);
11
+ /**
12
+ * @summary Helper method to format azure resource name based on the provided options
13
+ * @param resourceName The azure resource name to format
14
+ * @param options Options to control the formatting of the resource name
15
+ * @returns The formatted Azure-compliant resource name
16
+ */
17
+ format(resourceName: string | undefined, options?: AzureResourceNameFormatterProps): string;
18
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @classdesc Formats Azure resource names according to naming conventions
3
+ * - Applies global/resource prefixes and suffixes
4
+ * - Automatically appends stage to resource names
5
+ * - Supports per-resource customization via options
6
+ */
7
+ export class AzureResourceNameFormatter {
8
+ props;
9
+ constructor(props) {
10
+ this.props = props;
11
+ }
12
+ /**
13
+ * @summary Helper method to format azure resource name based on the provided options
14
+ * @param resourceName The azure resource name to format
15
+ * @param options Options to control the formatting of the resource name
16
+ * @returns The formatted Azure-compliant resource name
17
+ */
18
+ format(resourceName, options) {
19
+ const azureResourceNameElements = [];
20
+ if (!options?.exclude) {
21
+ azureResourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined);
22
+ azureResourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
23
+ }
24
+ azureResourceNameElements.push(resourceName || '');
25
+ if (!options?.exclude) {
26
+ azureResourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
27
+ azureResourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined);
28
+ }
29
+ azureResourceNameElements.push(this.props.stage);
30
+ return azureResourceNameElements
31
+ .filter(azureResourceNameElements => azureResourceNameElements != undefined)
32
+ .join('-');
33
+ }
34
+ }
@@ -0,0 +1,46 @@
1
+ import { ComponentResource, ComponentResourceOptions, Config } from '@pulumi/pulumi';
2
+ import { CommonAzureConstruct } from './construct.js';
3
+ import { CommonAzureStackProps } from './types.js';
4
+ /**
5
+ * @classdesc Common stack to use as a base for all higher level constructs using Pulumi
6
+ * @example
7
+ * ```typescript
8
+ * import { CommonAzureStack } from '@gradientedge/cdk-utils'
9
+ *
10
+ * class CustomStack extends CommonAzureStack {
11
+ * constructor(name: string, props: CommonAzureStackProps) {
12
+ * super(name, props)
13
+ * // provision resources
14
+ * }
15
+ * }
16
+ * ```
17
+ */
18
+ export declare class CommonAzureStack extends ComponentResource {
19
+ static NODEJS_RUNTIME: string;
20
+ construct: CommonAzureConstruct;
21
+ props: CommonAzureStackProps;
22
+ config: Config;
23
+ constructor(name: string, props: CommonAzureStackProps, options?: ComponentResourceOptions);
24
+ /**
25
+ * @summary Method to determine the core construct properties injected via context
26
+ * @param props The stack properties
27
+ * @returns The stack properties
28
+ */
29
+ protected determineConstructProps(props: CommonAzureStackProps): any;
30
+ /**
31
+ * @summary Method to determine extra contexts apart from the main context
32
+ * - Sets the properties from the extra contexts
33
+ * - Primary use is to have layered config in separate files to enable easier maintenance and readability
34
+ */
35
+ protected determineExtraContexts(): Record<string, any>;
36
+ /**
37
+ * @summary Method to determine extra stage contexts apart from the main context
38
+ * - Sets the properties from the extra stage contexts
39
+ * - Primary use is to have layered config for each environment which is injected into the context
40
+ */
41
+ protected determineStageContexts(): any;
42
+ /**
43
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
44
+ */
45
+ protected fullyQualifiedDomain(): string;
46
+ }
@@ -0,0 +1,120 @@
1
+ import { ComponentResource, Config } from '@pulumi/pulumi';
2
+ import appRoot from 'app-root-path';
3
+ import fs from 'fs';
4
+ import _ from 'lodash';
5
+ import path from 'path';
6
+ import { isDevStage } from '@gradientedge/cdk-utils-common';
7
+ import { registerTagTransformation } from './tagging.js';
8
+ /**
9
+ * @classdesc Common stack to use as a base for all higher level constructs using Pulumi
10
+ * @example
11
+ * ```typescript
12
+ * import { CommonAzureStack } from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomStack extends CommonAzureStack {
15
+ * constructor(name: string, props: CommonAzureStackProps) {
16
+ * super(name, props)
17
+ * // provision resources
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export class CommonAzureStack extends ComponentResource {
23
+ static NODEJS_RUNTIME = '22';
24
+ construct;
25
+ props;
26
+ config;
27
+ constructor(name, props, options) {
28
+ super(`custom:azure:Stack:${name}`, name, props, options);
29
+ /* initialise config */
30
+ this.config = new Config();
31
+ this.props = this.determineConstructProps(props);
32
+ /* register tag transformation for automatic tag application */
33
+ if (this.props.defaultTags) {
34
+ registerTagTransformation(this.props.defaultTags);
35
+ }
36
+ }
37
+ /**
38
+ * @summary Method to determine the core construct properties injected via context
39
+ * @param props The stack properties
40
+ * @returns The stack properties
41
+ */
42
+ determineConstructProps(props) {
43
+ return {
44
+ ...props,
45
+ extraContexts: this.config.getObject('extraContexts'),
46
+ stage: this.config.require('stage'),
47
+ stageContextPath: this.config.require('stageContextPath'),
48
+ ...this.determineExtraContexts(),
49
+ ...this.determineStageContexts(),
50
+ };
51
+ }
52
+ /**
53
+ * @summary Method to determine extra contexts apart from the main context
54
+ * - Sets the properties from the extra contexts
55
+ * - Primary use is to have layered config in separate files to enable easier maintenance and readability
56
+ */
57
+ determineExtraContexts() {
58
+ const extraContexts = this.config.getObject('extraContexts');
59
+ const debug = this.config.getBoolean('debug');
60
+ if (!extraContexts) {
61
+ if (debug)
62
+ console.debug(`No additional contexts provided. Using default context properties`);
63
+ return {};
64
+ }
65
+ let extraContextProps = {};
66
+ _.forEach(extraContexts, (context) => {
67
+ const extraContextPath = path.join(appRoot.path, context);
68
+ /* scenario where extra context is configured but absent in file system */
69
+ if (!fs.existsSync(extraContextPath))
70
+ throw `Extra context properties unavailable in path:${extraContextPath}`;
71
+ /* read the extra properties */
72
+ const extraContextPropsBuffer = fs.readFileSync(extraContextPath);
73
+ if (debug)
74
+ console.debug(`Adding additional contexts provided in ${extraContextPath}`);
75
+ /* parse as JSON properties */
76
+ extraContextProps = {
77
+ ...extraContextProps,
78
+ ...JSON.parse(extraContextPropsBuffer.toString('utf-8')),
79
+ };
80
+ });
81
+ return extraContextProps;
82
+ }
83
+ /**
84
+ * @summary Method to determine extra stage contexts apart from the main context
85
+ * - Sets the properties from the extra stage contexts
86
+ * - Primary use is to have layered config for each environment which is injected into the context
87
+ */
88
+ determineStageContexts() {
89
+ const debug = this.config.getBoolean('debug');
90
+ const stage = this.config.require('stage');
91
+ const stageContextPath = this.config.get('stageContextPath');
92
+ const stageContextFilePath = path.join(appRoot.path, stageContextPath ?? 'env', `${stage}.json`);
93
+ if (isDevStage(stage)) {
94
+ if (debug)
95
+ console.debug(`Development stage. Using default stage context properties`);
96
+ }
97
+ /* alert default context usage when extra stage config is missing */
98
+ if (!fs.existsSync(stageContextFilePath)) {
99
+ if (debug)
100
+ console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`);
101
+ if (debug)
102
+ console.debug(`Using default stage context properties for ${stage} stage`);
103
+ return {};
104
+ }
105
+ /* read the extra properties */
106
+ const stageContextPropsBuffer = fs.readFileSync(stageContextFilePath);
107
+ if (debug)
108
+ console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`);
109
+ /* parse as JSON properties */
110
+ return JSON.parse(stageContextPropsBuffer.toString('utf-8'));
111
+ }
112
+ /**
113
+ * @summary Determine the fully qualified domain name based on domainName & subDomain
114
+ */
115
+ fullyQualifiedDomain() {
116
+ const domainName = this.props.domainName;
117
+ const subDomain = this.props.subDomain;
118
+ return subDomain ? `${subDomain}.${domainName}` : domainName;
119
+ }
120
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @summary Check if a resource type is taggable
3
+ * @param resourceType The Pulumi resource type (e.g., 'azure-native:resources:ResourceGroup')
4
+ * @returns True if the resource supports tags, false otherwise
5
+ */
6
+ export declare function isTaggableResource(resourceType: string): boolean;
7
+ /**
8
+ * @summary Register a stack transformation to automatically apply tags to Azure resources
9
+ * @param defaultTags The default tags to apply to all resources
10
+ * @param tagsToIgnore Optional list of tag keys to ignore in lifecycle management
11
+ * @example
12
+ * ```typescript
13
+ * registerTagTransformation({ environment: 'production', team: 'platform' })
14
+ * ```
15
+ */
16
+ export declare function registerTagTransformation(defaultTags: Record<string, string>, tagsToIgnore?: string[]): void;
17
+ /**
18
+ * @summary Helper function to apply tags to a specific resource's properties
19
+ * @param props The resource properties
20
+ * @param defaultTags The default tags to merge with existing tags
21
+ * @returns The properties with merged tags
22
+ * @example
23
+ * ```typescript
24
+ * const resourceGroupProps = applyTags(props, { environment: 'dev' })
25
+ * ```
26
+ */
27
+ export declare function applyTags<T extends {
28
+ tags?: Record<string, string>;
29
+ }>(props: T, defaultTags: Record<string, string>): T;