@gradientedge/cdk-utils 10.1.0 → 10.2.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 (112) hide show
  1. package/dist/src/lib/azure/common/constants.d.ts +3 -2
  2. package/dist/src/lib/azure/common/constants.js +2 -1
  3. package/dist/src/lib/azure/common/construct.d.ts +26 -12
  4. package/dist/src/lib/azure/common/construct.js +31 -45
  5. package/dist/src/lib/azure/common/resource-name-formatter.d.ts +9 -4
  6. package/dist/src/lib/azure/common/resource-name-formatter.js +9 -5
  7. package/dist/src/lib/azure/common/stack.d.ts +18 -32
  8. package/dist/src/lib/azure/common/stack.js +77 -74
  9. package/dist/src/lib/azure/common/tagging.d.ts +29 -8
  10. package/dist/src/lib/azure/common/tagging.js +72 -26
  11. package/dist/src/lib/azure/common/types.d.ts +19 -4
  12. package/dist/src/lib/azure/services/api-management/main.d.ts +29 -32
  13. package/dist/src/lib/azure/services/api-management/main.js +100 -121
  14. package/dist/src/lib/azure/services/api-management/types.d.ts +33 -18
  15. package/dist/src/lib/azure/services/app-configuration/main.d.ts +6 -7
  16. package/dist/src/lib/azure/services/app-configuration/main.js +23 -26
  17. package/dist/src/lib/azure/services/app-configuration/types.d.ts +2 -2
  18. package/dist/src/lib/azure/services/app-service/main.d.ts +10 -12
  19. package/dist/src/lib/azure/services/app-service/main.js +37 -49
  20. package/dist/src/lib/azure/services/app-service/types.d.ts +4 -4
  21. package/dist/src/lib/azure/services/application-insights/main.d.ts +7 -8
  22. package/dist/src/lib/azure/services/application-insights/main.js +20 -26
  23. package/dist/src/lib/azure/services/application-insights/types.d.ts +2 -4
  24. package/dist/src/lib/azure/services/cosmosdb/main.d.ts +12 -15
  25. package/dist/src/lib/azure/services/cosmosdb/main.js +42 -61
  26. package/dist/src/lib/azure/services/cosmosdb/types.d.ts +4 -6
  27. package/dist/src/lib/azure/services/dns/main.d.ts +13 -17
  28. package/dist/src/lib/azure/services/dns/main.js +33 -51
  29. package/dist/src/lib/azure/services/dns/types.d.ts +5 -8
  30. package/dist/src/lib/azure/services/eventgrid/main.d.ts +20 -22
  31. package/dist/src/lib/azure/services/eventgrid/main.js +61 -89
  32. package/dist/src/lib/azure/services/eventgrid/types.d.ts +7 -8
  33. package/dist/src/lib/azure/services/function/main.d.ts +15 -15
  34. package/dist/src/lib/azure/services/function/main.js +54 -59
  35. package/dist/src/lib/azure/services/function/types.d.ts +18 -6
  36. package/dist/src/lib/azure/services/index.d.ts +1 -1
  37. package/dist/src/lib/azure/services/index.js +1 -1
  38. package/dist/src/lib/azure/services/key-vault/main.d.ts +6 -7
  39. package/dist/src/lib/azure/services/key-vault/main.js +29 -28
  40. package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
  41. package/dist/src/lib/azure/services/monitor/main.d.ts +7 -8
  42. package/dist/src/lib/azure/services/monitor/main.js +10 -15
  43. package/dist/src/lib/azure/services/monitor/types.d.ts +2 -2
  44. package/dist/src/lib/azure/services/operational-insights/main.d.ts +29 -0
  45. package/dist/src/lib/azure/services/operational-insights/main.js +50 -0
  46. package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -0
  47. package/dist/src/lib/azure/services/redis/main.d.ts +8 -9
  48. package/dist/src/lib/azure/services/redis/main.js +24 -26
  49. package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
  50. package/dist/src/lib/azure/services/resource-group/main.d.ts +6 -7
  51. package/dist/src/lib/azure/services/resource-group/main.js +9 -14
  52. package/dist/src/lib/azure/services/resource-group/types.d.ts +2 -2
  53. package/dist/src/lib/azure/services/servicebus/main.d.ts +17 -22
  54. package/dist/src/lib/azure/services/servicebus/main.js +47 -70
  55. package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -10
  56. package/dist/src/lib/azure/services/storage/main.d.ts +24 -27
  57. package/dist/src/lib/azure/services/storage/main.js +70 -88
  58. package/dist/src/lib/azure/services/storage/types.d.ts +10 -8
  59. package/dist/src/lib/azure/types/index.d.ts +2 -1
  60. package/dist/src/lib/azure/utils/index.d.ts +19 -3
  61. package/dist/src/lib/azure/utils/index.js +19 -13
  62. package/dist/src/lib/cloudflare/common/stack.js +1 -1
  63. package/package.json +2 -1
  64. package/src/lib/azure/common/constants.ts +2 -1
  65. package/src/lib/azure/common/construct.ts +32 -48
  66. package/src/lib/azure/common/resource-name-formatter.ts +10 -6
  67. package/src/lib/azure/common/stack.ts +78 -78
  68. package/src/lib/azure/common/tagging.ts +78 -29
  69. package/src/lib/azure/common/types.ts +21 -4
  70. package/src/lib/azure/services/api-management/main.ts +172 -169
  71. package/src/lib/azure/services/api-management/types.ts +39 -16
  72. package/src/lib/azure/services/app-configuration/main.ts +33 -31
  73. package/src/lib/azure/services/app-configuration/types.ts +2 -2
  74. package/src/lib/azure/services/app-service/main.ts +61 -62
  75. package/src/lib/azure/services/app-service/types.ts +4 -4
  76. package/src/lib/azure/services/application-insights/main.ts +29 -30
  77. package/src/lib/azure/services/application-insights/types.ts +2 -5
  78. package/src/lib/azure/services/cosmosdb/main.ts +78 -77
  79. package/src/lib/azure/services/cosmosdb/types.ts +10 -6
  80. package/src/lib/azure/services/dns/main.ts +65 -72
  81. package/src/lib/azure/services/dns/types.ts +9 -9
  82. package/src/lib/azure/services/eventgrid/main.ts +120 -122
  83. package/src/lib/azure/services/eventgrid/types.ts +13 -8
  84. package/src/lib/azure/services/function/main.ts +75 -72
  85. package/src/lib/azure/services/function/types.ts +21 -6
  86. package/src/lib/azure/services/index.ts +1 -1
  87. package/src/lib/azure/services/key-vault/main.ts +38 -32
  88. package/src/lib/azure/services/key-vault/types.ts +4 -2
  89. package/src/lib/azure/services/monitor/main.ts +17 -21
  90. package/src/lib/azure/services/monitor/types.ts +2 -2
  91. package/src/lib/azure/services/operational-insights/main.ts +61 -0
  92. package/src/lib/azure/services/operational-insights/types.ts +3 -0
  93. package/src/lib/azure/services/redis/main.ts +30 -30
  94. package/src/lib/azure/services/redis/types.ts +2 -2
  95. package/src/lib/azure/services/resource-group/main.ts +20 -20
  96. package/src/lib/azure/services/resource-group/types.ts +2 -2
  97. package/src/lib/azure/services/servicebus/main.ts +103 -94
  98. package/src/lib/azure/services/servicebus/types.ts +17 -11
  99. package/src/lib/azure/services/storage/main.ts +113 -114
  100. package/src/lib/azure/services/storage/types.ts +16 -8
  101. package/src/lib/azure/types/index.ts +2 -1
  102. package/src/lib/azure/utils/index.ts +20 -22
  103. package/src/lib/cloudflare/common/stack.ts +1 -1
  104. package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +0 -30
  105. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +0 -55
  106. package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +0 -3
  107. package/src/lib/azure/services/log-analytics-workspace/main.ts +0 -61
  108. package/src/lib/azure/services/log-analytics-workspace/types.ts +0 -3
  109. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.d.ts +0 -0
  110. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.js +0 -0
  111. /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/types.js +0 -0
  112. /package/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.ts +0 -0
@@ -1,23 +1,25 @@
1
- import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
2
- import { LinuxWebApp } from '@cdktf/provider-azurerm/lib/linux-web-app/index.js'
3
- import { ServicePlan } from '@cdktf/provider-azurerm/lib/service-plan/index.js'
1
+ import {
2
+ AppServicePlan,
3
+ ManagedServiceIdentityType,
4
+ SupportedTlsVersions,
5
+ WebApp,
6
+ } from '@pulumi/azure-native/web/index.js'
4
7
  import { CommonAzureConstruct } from '../../common/index.js'
5
- import { createAzureTfOutput } from '../../utils/index.js'
6
8
  import { LinuxWebAppProps, ServicePlanProps } from './types.js'
7
9
 
8
10
  /**
9
- * @classdesc Provides operations on Azure App Service
11
+ * @classdesc Provides operations on Azure App Service using Pulumi
10
12
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
11
13
  * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
12
14
  * @example
13
- * ```
15
+ * ```typescript
14
16
  * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
15
17
  *
16
18
  * class CustomConstruct extends CommonAzureConstruct {
17
- * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
18
- * super(parent, id, props)
19
+ * constructor(name: string, props: CommonAzureStackProps) {
20
+ * super(name, props)
19
21
  * this.props = props
20
- * this.appServiceManager.createAppService('MyAppService', this, props)
22
+ * this.appServiceManager.createAppServicePlan('MyAppService', this, props)
21
23
  * }
22
24
  * }
23
25
  * ```
@@ -28,78 +30,75 @@ export class AzureAppServiceManager {
28
30
  * @param id scoped id of the resource
29
31
  * @param scope scope in which this resource is defined
30
32
  * @param props app service plan properties
31
- * @see [CDKTF App service plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appServicePlan.typescript.md}
33
+ * @see [Pulumi Azure Native App Service Plan]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/web/appserviceplan/}
32
34
  */
33
35
  public createAppServicePlan(id: string, scope: CommonAzureConstruct, props: ServicePlanProps) {
34
36
  if (!props) throw `Props undefined for ${id}`
35
37
 
36
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-as-rg`, {
37
- name: scope.props.resourceGroupName
38
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
39
- : `${props.resourceGroupName}`,
40
- })
38
+ // Get resource group name
39
+ const resourceGroupName = scope.props.resourceGroupName
40
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
41
+ : props.resourceGroupName
41
42
 
42
- if (!resourceGroup) throw `Resource group undefined for ${id}`
43
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
43
44
 
44
- const appServicePlan = new ServicePlan(scope, `${id}-as`, {
45
- ...props,
46
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appServicePlan),
47
- resourceGroupName: resourceGroup.name,
48
- tags: props.tags ?? {
49
- environment: scope.props.stage,
45
+ return new AppServicePlan(
46
+ `${id}-as`,
47
+ {
48
+ ...props,
49
+ name: scope.resourceNameFormatter.format(
50
+ props.name?.toString(),
51
+ scope.props.resourceNameOptions?.appServicePlan
52
+ ),
53
+ resourceGroupName: resourceGroupName,
54
+ location: props.location ?? scope.props.location,
55
+ tags: props.tags ?? {
56
+ environment: scope.props.stage,
57
+ },
50
58
  },
51
- })
52
-
53
- createAzureTfOutput(`${id}-appServicePlanName`, scope, appServicePlan.name)
54
- createAzureTfOutput(`${id}-appServicePlanFriendlyUniqueId`, scope, appServicePlan.friendlyUniqueId)
55
- createAzureTfOutput(`${id}-appServicePlanId`, scope, appServicePlan.id)
56
-
57
- return appServicePlan
59
+ { parent: scope }
60
+ )
58
61
  }
59
62
 
60
63
  /**
61
- * @summary Method to create a new web app
64
+ * @summary Method to create a new Linux web app
62
65
  * @param id scoped id of the resource
63
66
  * @param scope scope in which this resource is defined
64
67
  * @param props web app properties
65
- * @see [CDKTF Web App Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/linuxWebApp.typescript.md}
68
+ * @see [Pulumi Azure Native Web App]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/web/webapp/}
66
69
  */
67
70
  public createLinuxWebApp(id: string, scope: CommonAzureConstruct, props: LinuxWebAppProps) {
68
71
  if (!props) throw `Props undefined for ${id}`
69
72
 
70
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-as-rg`, {
71
- name: scope.props.resourceGroupName
72
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
73
- : `${props.resourceGroupName}`,
74
- })
75
-
76
- if (!resourceGroup) throw `Resource group undefined for ${id}`
73
+ // Get resource group name
74
+ const resourceGroupName = scope.props.resourceGroupName
75
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
76
+ : props.resourceGroupName
77
77
 
78
- const linuxWebApp = new LinuxWebApp(scope, `${id}-lwa`, {
79
- ...props,
80
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.linuxWebApp),
81
- resourceGroupName: resourceGroup.name,
82
- httpsOnly: props.httpsOnly ?? true,
78
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
83
79
 
84
- identity: props.identity ?? {
85
- type: 'SystemAssigned',
80
+ return new WebApp(
81
+ `${id}-lwa`,
82
+ {
83
+ ...props,
84
+ name: scope.resourceNameFormatter.format(props.name?.toString(), scope.props.resourceNameOptions?.linuxWebApp),
85
+ resourceGroupName: resourceGroupName,
86
+ location: props.location ?? scope.props.location,
87
+ httpsOnly: props.httpsOnly ?? true,
88
+ kind: props.kind ?? 'app,linux',
89
+ identity: props.identity ?? {
90
+ type: ManagedServiceIdentityType.SystemAssigned,
91
+ },
92
+ siteConfig: props.siteConfig ?? {
93
+ alwaysOn: true,
94
+ linuxFxVersion: 'NODE|22-lts',
95
+ minTlsVersion: SupportedTlsVersions.SupportedTlsVersions_1_3,
96
+ },
97
+ tags: props.tags ?? {
98
+ environment: scope.props.stage,
99
+ },
86
100
  },
87
- siteConfig: {
88
- ...props.siteConfig,
89
- alwaysOn: props.siteConfig.alwaysOn ?? true,
90
- applicationStack: props.siteConfig.applicationStack ?? { nodeVersion: '22-lts' },
91
- minimumTlsVersion: props.siteConfig.minimumTlsVersion ?? '1.3',
92
- },
93
- tags: props.tags ?? {
94
- environment: scope.props.stage,
95
- },
96
- })
97
-
98
- createAzureTfOutput(`${id}-linuxWebAppName`, scope, linuxWebApp.name)
99
- createAzureTfOutput(`${id}-linuxWebAppFriendlyUniqueId`, scope, linuxWebApp.friendlyUniqueId)
100
- createAzureTfOutput(`${id}-linuxWebAppId`, scope, linuxWebApp.id)
101
- createAzureTfOutput(`${id}-linuxWebAppDefaultHostname`, scope, linuxWebApp.defaultHostname)
102
-
103
- return linuxWebApp
101
+ { parent: scope }
102
+ )
104
103
  }
105
104
  }
@@ -1,6 +1,6 @@
1
- import { ServicePlanConfig } from '@cdktf/provider-azurerm/lib/service-plan/index.js'
2
- import { LinuxWebAppConfig } from '@cdktf/provider-azurerm/lib/linux-web-app/index.js'
1
+ import { AppServicePlanArgs } from '@pulumi/azure-native/web/index.js'
2
+ import { WebAppArgs } from '@pulumi/azure-native/web/index.js'
3
3
 
4
- export interface ServicePlanProps extends ServicePlanConfig {}
4
+ export interface ServicePlanProps extends AppServicePlanArgs {}
5
5
 
6
- export interface LinuxWebAppProps extends LinuxWebAppConfig {}
6
+ export interface LinuxWebAppProps extends WebAppArgs {}
@@ -1,22 +1,20 @@
1
- import { ApplicationInsights } from '@cdktf/provider-azurerm/lib/application-insights/index.js'
2
- import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
1
+ import { ApplicationType, Component } from '@pulumi/azure-native/applicationinsights/index.js'
3
2
  import { CommonAzureConstruct } from '../../common/index.js'
4
- import { createAzureTfOutput } from '../../utils/index.js'
5
3
  import { ApplicationInsightsProps } from './types.js'
6
4
 
7
5
  /**
8
- * @classdesc Provides operations on Azure Application Insights
6
+ * @classdesc Provides operations on Azure Application Insights using Pulumi
9
7
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
10
8
  * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
11
9
  * @example
12
- * ```
10
+ * ```typescript
13
11
  * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
14
12
  *
15
13
  * class CustomConstruct extends CommonAzureConstruct {
16
- * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
17
- * super(parent, id, props)
14
+ * constructor(name: string, props: CommonAzureStackProps) {
15
+ * super(name, props)
18
16
  * this.props = props
19
- * this.applicationInsightseManager.createApplicationInsights('MyApplicationInsights', this, props)
17
+ * this.applicationInsightsManager.createApplicationInsights('MyApplicationInsights', this, props)
20
18
  * }
21
19
  * }
22
20
  * ```
@@ -27,33 +25,34 @@ export class AzureApplicationInsightsManager {
27
25
  * @param id scoped id of the resource
28
26
  * @param scope scope in which this resource is defined
29
27
  * @param props application insights properties
30
- * @see [CDKTF Application insights Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/applicationInsights.typescript.md}
28
+ * @see [Pulumi Azure Native Application Insights Component]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/insights/component/}
31
29
  */
32
- public createApplicationInsights(id: string, scope: CommonAzureConstruct, props: ApplicationInsightsProps) {
30
+ public createComponent(id: string, scope: CommonAzureConstruct, props: ApplicationInsightsProps) {
33
31
  if (!props) throw `Props undefined for ${id}`
34
32
 
35
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-ai-rg`, {
36
- name: scope.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
39
- })
33
+ // Get resource group name
34
+ const resourceGroupName = scope.props.resourceGroupName
35
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
36
+ : props.resourceGroupName
40
37
 
41
- if (!resourceGroup) throw `Resource group undefined for ${id}`
38
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
42
39
 
43
- const applicationInsights = new ApplicationInsights(scope, `${id}-ai`, {
44
- ...props,
45
- name: scope.resourceNameFormatter.format(props.name ?? '', scope.props.resourceNameOptions?.applicationInsights),
46
- resourceGroupName: resourceGroup.name,
47
- applicationType: props.applicationType ?? 'web',
48
- tags: props.tags ?? {
49
- environment: scope.props.stage,
40
+ return new Component(
41
+ `${id}-ai`,
42
+ {
43
+ ...props,
44
+ resourceName: scope.resourceNameFormatter.format(
45
+ props.resourceName?.toString(),
46
+ scope.props.resourceNameOptions?.applicationInsights
47
+ ),
48
+ resourceGroupName: resourceGroupName,
49
+ applicationType: (props.applicationType as any) ?? ApplicationType.Web,
50
+ kind: props.kind ?? 'web',
51
+ tags: props.tags ?? {
52
+ environment: scope.props.stage,
53
+ },
50
54
  },
51
- })
52
-
53
- createAzureTfOutput(`${id}-applicationInsightsName`, scope, applicationInsights.name)
54
- createAzureTfOutput(`${id}-applicationInsightsFriendlyUniqueId`, scope, applicationInsights.friendlyUniqueId)
55
- createAzureTfOutput(`${id}-applicationInsightsId`, scope, applicationInsights.id)
56
-
57
- return applicationInsights
55
+ { parent: scope }
56
+ )
58
57
  }
59
58
  }
@@ -1,6 +1,3 @@
1
- import { ApplicationInsightsConfig } from '@cdktf/provider-azurerm/lib/application-insights/index.js'
1
+ import { ComponentArgs } from '@pulumi/azure-native/applicationinsights/index.js'
2
2
 
3
- export interface ApplicationInsightsProps extends Omit<ApplicationInsightsConfig, 'applicationType' | 'name'> {
4
- name?: string | undefined
5
- applicationType?: string | undefined
6
- }
3
+ export interface ApplicationInsightsProps extends ComponentArgs {}
@@ -1,24 +1,25 @@
1
- import { CosmosdbAccount } from '@cdktf/provider-azurerm/lib/cosmosdb-account/index.js'
2
- import { CosmosdbSqlContainer } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-container/index.js'
3
- import { CosmosdbSqlDatabase } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-database/index.js'
4
- import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
1
+ import {
2
+ DatabaseAccount,
3
+ ResourceIdentityType,
4
+ SqlResourceSqlContainer,
5
+ SqlResourceSqlDatabase,
6
+ } from '@pulumi/azure-native/cosmosdb/index.js'
5
7
  import { CommonAzureConstruct } from '../../common/index.js'
6
- import { createAzureTfOutput } from '../../utils/index.js'
7
8
  import { CosmosdbAccountProps, CosmosdbSqlContainerProps, CosmosdbSqlDatabaseProps } from './types.js'
8
9
 
9
10
  /**
10
- * @classdesc Provides operations on Azure CosmosDB
11
+ * @classdesc Provides operations on Azure CosmosDB using Pulumi
11
12
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
12
13
  * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
13
14
  * @example
14
- * ```
15
+ * ```typescript
15
16
  * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
16
17
  *
17
18
  * class CustomConstruct extends CommonAzureConstruct {
18
- * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
19
- * super(parent, id, props)
19
+ * constructor(name: string, props: CommonAzureStackProps) {
20
+ * super(name, props)
20
21
  * this.props = props
21
- * this.CosmosDbManager.createCosmosAccount('MyCosmosDb', this, props)
22
+ * this.CosmosDbManager.createCosmosDbAccount('MyCosmosDb', this, props)
22
23
  * }
23
24
  * }
24
25
  * ```
@@ -29,68 +30,68 @@ export class AzureCosmosDbManager {
29
30
  * @param id scoped id of the resource
30
31
  * @param scope scope in which this resource is defined
31
32
  * @param props cosmosdb account properties
32
- * @see [CDKTF CosmosDb Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbAccount.typescript.md}
33
+ * @see [Pulumi Azure Native CosmosDB Account]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/databaseaccount/}
33
34
  */
34
35
  public createCosmosDbAccount(id: string, scope: CommonAzureConstruct, props: CosmosdbAccountProps) {
35
36
  if (!props) throw `Props undefined for ${id}`
36
37
 
37
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-ca-rg`, {
38
- name: scope.props.resourceGroupName
39
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
40
- : `${props.resourceGroupName}`,
41
- })
42
-
43
- if (!resourceGroup) throw `Resource group undefined for ${id}`
44
-
45
- const cosmosdbAccount = new CosmosdbAccount(scope, `${id}-ca`, {
46
- ...props,
47
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.cosmosDbAccount),
48
- location: resourceGroup.location,
49
- resourceGroupName: resourceGroup.name,
50
- tags: props.tags ?? {
51
- environment: scope.props.stage,
38
+ // Get resource group name
39
+ const resourceGroupName = scope.props.resourceGroupName
40
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
41
+ : props.resourceGroupName
42
+
43
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
44
+
45
+ return new DatabaseAccount(
46
+ `${id}-ca`,
47
+ {
48
+ ...props,
49
+ accountName: scope.resourceNameFormatter.format(
50
+ props.accountName?.toString(),
51
+ scope.props.resourceNameOptions?.cosmosDbAccount
52
+ ),
53
+ location: props.location ?? scope.props.location,
54
+ resourceGroupName: resourceGroupName,
55
+ tags: props.tags ?? {
56
+ environment: scope.props.stage,
57
+ },
58
+ identity: props.identity ?? {
59
+ type: ResourceIdentityType.SystemAssigned,
60
+ },
52
61
  },
53
- identity: props.identity ?? {
54
- type: 'SystemAssigned',
55
- },
56
- })
57
-
58
- createAzureTfOutput(`${id}-cosmosdbAccountName`, scope, cosmosdbAccount.name)
59
- createAzureTfOutput(`${id}-cosmosdbAccountFriendlyUniqueId`, scope, cosmosdbAccount.friendlyUniqueId)
60
- createAzureTfOutput(`${id}-cosmosdbAccountId`, scope, cosmosdbAccount.id)
61
-
62
- return cosmosdbAccount
62
+ { parent: scope }
63
+ )
63
64
  }
64
65
 
65
66
  /**
66
67
  * @summary Method to create a new cosmosdb database
67
68
  * @param id scoped id of the resource
68
69
  * @param scope scope in which this resource is defined
69
- * @param props cosmosdb container properties
70
- * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
70
+ * @param props cosmosdb database properties
71
+ * @see [Pulumi Azure Native CosmosDB SQL Database]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqldatabase/}
71
72
  */
72
73
  public createCosmosDbDatabase(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlDatabaseProps) {
73
74
  if (!props) throw `Props undefined for ${id}`
74
75
 
75
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-cd-rg`, {
76
- name: scope.props.resourceGroupName
77
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
78
- : `${props.resourceGroupName}`,
79
- })
80
-
81
- if (!resourceGroup) throw `Resource group undefined for ${id}`
82
-
83
- const cosmosdbDatatbase = new CosmosdbSqlDatabase(scope, `${id}-cd`, {
84
- ...props,
85
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.cosmosDbSqlDatabase),
86
- resourceGroupName: resourceGroup.name,
87
- })
88
-
89
- createAzureTfOutput(`${id}-cosmosdbDatatbasetName`, scope, cosmosdbDatatbase.name)
90
- createAzureTfOutput(`${id}-cosmosdbDatatbaseFriendlyUniqueId`, scope, cosmosdbDatatbase.friendlyUniqueId)
91
- createAzureTfOutput(`${id}-cosmosdbDatatbaseId`, scope, cosmosdbDatatbase.id)
92
-
93
- return cosmosdbDatatbase
76
+ // Get resource group name
77
+ const resourceGroupName = scope.props.resourceGroupName
78
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
79
+ : props.resourceGroupName
80
+
81
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
82
+
83
+ return new SqlResourceSqlDatabase(
84
+ `${id}-cd`,
85
+ {
86
+ ...props,
87
+ databaseName: scope.resourceNameFormatter.format(
88
+ props.databaseName?.toString(),
89
+ scope.props.resourceNameOptions?.cosmosDbSqlDatabase
90
+ ),
91
+ resourceGroupName: resourceGroupName,
92
+ },
93
+ { parent: scope }
94
+ )
94
95
  }
95
96
 
96
97
  /**
@@ -98,29 +99,29 @@ export class AzureCosmosDbManager {
98
99
  * @param id scoped id of the resource
99
100
  * @param scope scope in which this resource is defined
100
101
  * @param props cosmosdb container properties
101
- * @see [CDKTF CosmosDb Container Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/cosmosdbSqlContainer.typescript.md}
102
+ * @see [Pulumi Azure Native CosmosDB SQL Container]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/documentdb/sqlresourcesqlcontainer/}
102
103
  */
103
104
  public createCosmosDbContainer(id: string, scope: CommonAzureConstruct, props: CosmosdbSqlContainerProps) {
104
105
  if (!props) throw `Props undefined for ${id}`
105
106
 
106
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-cc-rg`, {
107
- name: scope.props.resourceGroupName
108
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
109
- : `${props.resourceGroupName}`,
110
- })
111
-
112
- if (!resourceGroup) throw `Resource group undefined for ${id}`
113
-
114
- const cosmosdbContainer = new CosmosdbSqlContainer(scope, `${id}-cc`, {
115
- ...props,
116
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.cosmosDbSqlContainer),
117
- resourceGroupName: resourceGroup.name,
118
- })
119
-
120
- createAzureTfOutput(`${id}-cosmosdbContainertName`, scope, cosmosdbContainer.name)
121
- createAzureTfOutput(`${id}-cosmosdbContainerFriendlyUniqueId`, scope, cosmosdbContainer.friendlyUniqueId)
122
- createAzureTfOutput(`${id}-cosmosdbContainerId`, scope, cosmosdbContainer.id)
123
-
124
- return cosmosdbContainer
107
+ // Get resource group name
108
+ const resourceGroupName = scope.props.resourceGroupName
109
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
110
+ : props.resourceGroupName
111
+
112
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
113
+
114
+ return new SqlResourceSqlContainer(
115
+ `${id}-cc`,
116
+ {
117
+ ...props,
118
+ containerName: scope.resourceNameFormatter.format(
119
+ props.containerName?.toString(),
120
+ scope.props.resourceNameOptions?.cosmosDbSqlContainer
121
+ ),
122
+ resourceGroupName: resourceGroupName,
123
+ },
124
+ { parent: scope }
125
+ )
125
126
  }
126
127
  }
@@ -1,7 +1,11 @@
1
- import { CosmosdbAccountConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-account/index.js'
2
- import { CosmosdbSqlDatabaseConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-database/index.js'
3
- import { CosmosdbSqlContainerConfig } from '@cdktf/provider-azurerm/lib/cosmosdb-sql-container/index.js'
1
+ import {
2
+ DatabaseAccountArgs,
3
+ SqlResourceSqlContainerArgs,
4
+ SqlResourceSqlDatabaseArgs,
5
+ } from '@pulumi/azure-native/cosmosdb/index.js'
4
6
 
5
- export interface CosmosdbAccountProps extends CosmosdbAccountConfig {}
6
- export interface CosmosdbSqlDatabaseProps extends CosmosdbSqlDatabaseConfig {}
7
- export interface CosmosdbSqlContainerProps extends CosmosdbSqlContainerConfig {}
7
+ export interface CosmosdbAccountProps extends DatabaseAccountArgs {}
8
+
9
+ export interface CosmosdbSqlDatabaseProps extends SqlResourceSqlDatabaseArgs {}
10
+
11
+ export interface CosmosdbSqlContainerProps extends SqlResourceSqlContainerArgs {}