@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,41 +1,39 @@
1
- import { ApiManagementApiOperationPolicy } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy/index.js'
2
- import { ApiManagementApiOperation } from '@cdktf/provider-azurerm/lib/api-management-api-operation/index.js'
3
- import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api/index.js'
4
- import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend/index.js'
5
- import { ApiManagementCustomDomain } from '@cdktf/provider-azurerm/lib/api-management-custom-domain/index.js'
6
1
  import {
7
- ApiManagementLogger,
8
- ApiManagementLoggerApplicationInsights,
9
- } from '@cdktf/provider-azurerm/lib/api-management-logger/index.js'
10
- import { ApiManagementRedisCache } from '@cdktf/provider-azurerm/lib/api-management-redis-cache/index.js'
11
- import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management/index.js'
12
- import {
13
- DataAzurermApiManagement,
14
- DataAzurermApiManagementConfig,
15
- } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management/index.js'
16
- import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
17
- import { ManagedRedis } from '@cdktf/provider-azurerm/lib/managed-redis/index.js'
2
+ Api,
3
+ ApiManagementService,
4
+ ApiOperation,
5
+ ApiOperationPolicy,
6
+ Backend,
7
+ BackendProtocol,
8
+ Cache,
9
+ getApiManagementServiceOutput,
10
+ Logger,
11
+ LoggerType,
12
+ PolicyContentFormat,
13
+ Protocol,
14
+ } from '@pulumi/azure-native/apimanagement/index.js'
15
+ import * as redis from '@pulumi/azure-native/redis/index.js'
18
16
  import _ from 'lodash'
19
17
  import { CommonAzureConstruct } from '../../common/index.js'
20
- import { createAzureTfOutput } from '../../utils/index.js'
21
18
  import {
22
19
  ApiManagementApiProps,
23
20
  ApiManagementBackendProps,
24
21
  ApiManagementCustomDomainProps,
25
22
  ApiManagementProps,
23
+ ResolveApiManagementProps,
26
24
  } from './types.js'
27
25
 
28
26
  /**
29
- * @classdesc Provides operations on Azure Api Management
27
+ * @classdesc Provides operations on Azure API Management using Pulumi
30
28
  * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
31
29
  * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
32
30
  * @example
33
- * ```
31
+ * ```typescript
34
32
  * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
35
33
  *
36
34
  * class CustomConstruct extends CommonAzureConstruct {
37
- * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
38
- * super(parent, id, props)
35
+ * constructor(name: string, props: CommonAzureStackProps) {
36
+ * super(name, props)
39
37
  * this.props = props
40
38
  * this.apiManagementManager.createApiManagement('MyApiManagement', this, props)
41
39
  * }
@@ -44,168 +42,185 @@ import {
44
42
  */
45
43
  export class AzureApiManagementManager {
46
44
  /**
47
- * @summary Method to create a new api management
45
+ * @summary Method to create a new API Management service
48
46
  * @param id scoped id of the resource
49
47
  * @param scope scope in which this resource is defined
50
- * @param props api management properties
51
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
48
+ * @param props API Management properties
49
+ * @param applicationInsightsKey Optional Application Insights instrumentation key for logging
50
+ * @param externalRedisCache Optional external Redis cache for API Management caching
51
+ * @see [Pulumi Azure Native API Management]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
52
52
  */
53
- public createApiManagement(
53
+ public createApiManagementService(
54
54
  id: string,
55
55
  scope: CommonAzureConstruct,
56
56
  props: ApiManagementProps,
57
- applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey'],
58
- externalRedisCache?: ManagedRedis
57
+ applicationInsightsKey?: string,
58
+ externalRedisCache?: redis.Redis
59
59
  ) {
60
60
  if (!props) throw `Props undefined for ${id}`
61
61
 
62
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
63
- name: scope.props.resourceGroupName
64
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
65
- : `${props.resourceGroupName}`,
66
- })
67
-
68
- if (!resourceGroup) throw `Resource group undefined for ${id}`
69
-
70
- const apiManagement = new ApiManagement(scope, `${id}-am`, {
71
- ...props,
72
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagement),
73
- resourceGroupName: resourceGroup.name,
74
- tags: props.tags ?? {
75
- environment: scope.props.stage,
62
+ // Get resource group name
63
+ const resourceGroupName = scope.props.resourceGroupName
64
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
65
+ : props.resourceGroupName
66
+
67
+ if (!resourceGroupName) throw `Resource group name undefined for ${id}`
68
+
69
+ const apiManagementService = new ApiManagementService(
70
+ `${id}-am`,
71
+ {
72
+ ...props,
73
+ serviceName: scope.resourceNameFormatter.format(
74
+ props.serviceName?.toString(),
75
+ scope.props.resourceNameOptions?.apiManagement
76
+ ),
77
+ resourceGroupName: resourceGroupName,
78
+ location: props.location ?? scope.props.location,
79
+ publisherEmail: props.publisherEmail ?? 'noreply@example.com',
80
+ publisherName: props.publisherName ?? 'Default Publisher',
81
+ tags: props.tags ?? {
82
+ environment: scope.props.stage,
83
+ },
76
84
  },
77
- })
85
+ { parent: scope }
86
+ )
78
87
 
88
+ // Create logger if Application Insights key is provided
79
89
  if (applicationInsightsKey) {
80
- new ApiManagementLogger(scope, `${id}-am-logger`, {
81
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementLogger),
82
- resourceGroupName: resourceGroup.name,
83
- apiManagementName: apiManagement.name,
84
- applicationInsights: {
85
- instrumentationKey: applicationInsightsKey,
90
+ new Logger(
91
+ `${id}-am-logger`,
92
+ {
93
+ loggerId: scope.resourceNameFormatter.format(
94
+ props.serviceName?.toString(),
95
+ scope.props.resourceNameOptions?.apiManagementLogger
96
+ ),
97
+ resourceGroupName: resourceGroupName,
98
+ serviceName: apiManagementService.name,
99
+ loggerType: LoggerType.ApplicationInsights,
100
+ credentials: {
101
+ instrumentationKey: applicationInsightsKey,
102
+ },
86
103
  },
87
- })
104
+ { parent: scope }
105
+ )
88
106
  }
89
107
 
108
+ // Create Redis cache connection if external Redis is provided
90
109
  if (externalRedisCache) {
91
- new ApiManagementRedisCache(scope, `${id}-am-redis-cache`, {
92
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementRedisCache),
93
- apiManagementId: apiManagement.id,
94
- connectionString: `${externalRedisCache.name}:10000,password=${externalRedisCache.defaultDatabase.primaryAccessKey},ssl=True,abortConnect=False`,
95
- cacheLocation: externalRedisCache.location,
96
- redisCacheId: externalRedisCache.id,
97
- })
110
+ new Cache(
111
+ `${id}-am-redis-cache`,
112
+ {
113
+ cacheId: scope.resourceNameFormatter.format(
114
+ props.serviceName?.toString(),
115
+ scope.props.resourceNameOptions?.apiManagementRedisCache
116
+ ),
117
+ serviceName: apiManagementService.name,
118
+ resourceGroupName: resourceGroupName,
119
+ connectionString: externalRedisCache.hostName.apply(
120
+ hostName =>
121
+ `${hostName}:10000,password=${externalRedisCache.accessKeys.apply(k => k?.primaryKey)},ssl=True,abortConnect=False`
122
+ ),
123
+ useFromLocation: externalRedisCache.location,
124
+ resourceId: externalRedisCache.id,
125
+ },
126
+ { parent: scope }
127
+ )
98
128
  }
99
129
 
100
- createAzureTfOutput(`${id}-apiManagementName`, scope, apiManagement.name)
101
- createAzureTfOutput(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId)
102
- createAzureTfOutput(`${id}-apiManagementId`, scope, apiManagement.id)
103
-
104
- return apiManagement
130
+ return apiManagementService
105
131
  }
106
132
 
107
133
  /**
108
- * @summary Method to resolve an api management
134
+ * @summary Method to resolve an existing API Management service
109
135
  * @param id scoped id of the resource
110
136
  * @param scope scope in which this resource is defined
111
- * @param props api management properties
112
- * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
137
+ * @param props API Management lookup properties
138
+ * @see [Pulumi Azure Native API Management Lookup]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/apimanagementservice/}
113
139
  */
114
- public resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig) {
140
+ public resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps) {
115
141
  if (!props) throw `Props undefined for ${id}`
116
142
 
117
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
118
- name: scope.props.resourceGroupName
119
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
120
- : `${props.resourceGroupName}`,
121
- })
122
-
123
- if (!resourceGroup) throw `Resource group undefined for ${id}`
124
-
125
- const apiManagement = new DataAzurermApiManagement(scope, `${id}-am`, {
126
- ...props,
127
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.dataAzurermApiManagement),
128
- resourceGroupName: scope.props.resourceGroupName
129
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
130
- : `${props.resourceGroupName}`,
131
- })
132
-
133
- return apiManagement
143
+ return getApiManagementServiceOutput(
144
+ {
145
+ serviceName: scope.resourceNameFormatter.format(
146
+ props.serviceName?.toString(),
147
+ scope.props.resourceNameOptions?.dataAzurermApiManagement
148
+ ),
149
+ resourceGroupName: scope.props.resourceGroupName
150
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
151
+ : props.resourceGroupName,
152
+ },
153
+ { parent: scope }
154
+ )
134
155
  }
135
156
 
136
157
  /**
137
- * @summary Method to create a new api management backend
158
+ * @summary Method to create a new API Management backend
138
159
  * @param id scoped id of the resource
139
160
  * @param scope scope in which this resource is defined
140
- * @param props api management backend properties
141
- * @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
161
+ * @param props API Management backend properties
162
+ * @see [Pulumi Azure Native API Management Backend]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/backend/}
142
163
  */
143
- public createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
164
+ public createBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
144
165
  if (!props) throw `Props undefined for ${id}`
145
166
 
146
- const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
147
- ...props,
148
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
149
- description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
150
- protocol: props.protocol ?? 'http',
151
- })
152
-
153
- createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name)
154
- createAzureTfOutput(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId)
155
- createAzureTfOutput(`${id}-apiManagementBackendId`, scope, apiManagementBackend.id)
156
-
157
- return apiManagementBackend
167
+ return new Backend(
168
+ `${id}-am-be`,
169
+ {
170
+ ...props,
171
+ backendId: scope.resourceNameFormatter.format(
172
+ props.backendId?.toString(),
173
+ scope.props.resourceNameOptions?.apiManagementBackend
174
+ ),
175
+ description: props.description ?? `Backend for ${(props as any).name || id}-${scope.props.stage}`,
176
+ protocol: props.protocol ?? BackendProtocol.Http,
177
+ },
178
+ { parent: scope }
179
+ )
158
180
  }
159
181
 
160
182
  /**
161
- * @summary Method to create a new api management api
183
+ * @summary Method to create a new API Management API with operations and policies
162
184
  * @param id scoped id of the resource
163
185
  * @param scope scope in which this resource is defined
164
- * @param props api management api properties
165
- * @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
186
+ * @param props API Management API properties
187
+ * @see [Pulumi Azure Native API Management API]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/}
166
188
  */
167
- public createApiManagementApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
189
+ public createApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
168
190
  if (!props) throw `Props undefined for ${id}`
169
191
 
170
- const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
171
- ...props,
172
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementApi),
173
- displayName: props.displayName ?? props.name,
174
- revision: props.revision ?? '1',
175
- protocols: props.protocols ?? ['https'],
176
- })
177
-
178
- createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
179
- createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId)
180
- createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id)
192
+ const api = new Api(
193
+ `${id}-am-api`,
194
+ {
195
+ ...props,
196
+ apiId: scope.resourceNameFormatter.format(
197
+ props.apiId?.toString(),
198
+ scope.props.resourceNameOptions?.apiManagementApi
199
+ ),
200
+ displayName: props.displayName ?? props.apiId,
201
+ apiRevision: props.apiRevision ?? '1',
202
+ protocols: props.protocols ?? [Protocol.Https],
203
+ },
204
+ { parent: scope }
205
+ )
181
206
 
207
+ // Create operations and policies
182
208
  _.forEach(props.operations, operation => {
183
- const apimOperation = new ApiManagementApiOperation(
184
- scope,
209
+ const operationId = `${operation.displayName}-${operation.method}`
210
+ const apimOperation = new ApiOperation(
185
211
  `${id}-apim-api-operation-${operation.displayName}-${operation.method}`,
186
212
  {
187
- operationId: `${operation.displayName}-${operation.method}`,
188
- method: operation.method.toUpperCase(),
189
- apiManagementName: apiManagementApi.apiManagementName,
190
- resourceGroupName: apiManagementApi.resourceGroupName,
191
- apiName: apiManagementApi.name,
213
+ operationId: operationId,
214
+ method: (operation.method as string)?.toUpperCase() || 'GET',
215
+ serviceName: props.serviceName!,
216
+ resourceGroupName: props.resourceGroupName!,
217
+ apiId: api.name,
192
218
  displayName: operation.displayName,
193
219
  urlTemplate: operation.urlTemplate,
194
- templateParameter: operation.templateParameter,
195
- }
196
- )
197
-
198
- createAzureTfOutput(
199
- `${id}-${operation.displayName}-${operation.method}-apimOperationOperationId`,
200
- scope,
201
- apimOperation.operationId
202
- )
203
- createAzureTfOutput(
204
- `${id}-${operation.displayName}-${operation.method}-apimOperationFriendlyUniqueId`,
205
- scope,
206
- apimOperation.friendlyUniqueId
220
+ templateParameters: operation.templateParameters,
221
+ },
222
+ { parent: scope }
207
223
  )
208
- createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationId`, scope, apimOperation.id)
209
224
 
210
225
  // Define Caching Policy if enabled
211
226
  let cacheSetVariablePolicy = ''
@@ -217,11 +232,11 @@ export class AzureApiManagementManager {
217
232
  cacheSetVariablePolicy = `<!-- Generate a comprehensive custom cache key (without query params or Accept header) -->
218
233
  <set-variable name="customCacheKey" value="@{
219
234
  // Instance identification
220
-
235
+
221
236
  // API identification
222
237
  string apiName = context.Api.Name.Replace(" ", "").ToLower();
223
238
  string apiVersion = context.Api.Version ?? "v1";
224
-
239
+
225
240
  // Full path construction (without query parameters)
226
241
  string fullPath = context.Request.Url.Path.ToLower();
227
242
 
@@ -299,7 +314,7 @@ export class AzureApiManagementManager {
299
314
  // Inject rate limiting policy (if configured)
300
315
  let rateLimitPolicy = ''
301
316
  if (props.rateLimit && scope.props.subscriptionId) {
302
- rateLimitPolicy = `<rate-limit-by-key calls="${props.rateLimit.calls}" renewal-period="${props.rateLimit.renewalPeriodInSecs}" counter-key="${scope.props.subscriptionId}-${apimOperation.operationId}"/>`
317
+ rateLimitPolicy = `<rate-limit-by-key calls="${props.rateLimit.calls}" renewal-period="${props.rateLimit.renewalPeriodInSecs}" counter-key="${scope.props.subscriptionId}-${operationId}"/>`
303
318
  }
304
319
 
305
320
  const policyXmlContent = `<policies>
@@ -324,39 +339,31 @@ export class AzureApiManagementManager {
324
339
  </on-error>
325
340
  </policies>`
326
341
 
327
- const apimOperationPolicy = new ApiManagementApiOperationPolicy(
328
- scope,
342
+ new ApiOperationPolicy(
329
343
  `${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`,
330
344
  {
331
- apiManagementName: apiManagementApi.apiManagementName,
332
- resourceGroupName: apiManagementApi.resourceGroupName,
333
- apiName: apiManagementApi.name,
334
- operationId: apimOperation.operationId,
335
- xmlContent: policyXmlContent,
336
- }
337
- )
338
-
339
- createAzureTfOutput(
340
- `${id}-${operation.displayName}-${operation.method}-apimOperationPolicyFriendlyUniqueId`,
341
- scope,
342
- apimOperationPolicy.friendlyUniqueId
343
- )
344
- createAzureTfOutput(
345
- `${id}-${operation.displayName}-${operation.method}-apimOperationPolicyId`,
346
- scope,
347
- apimOperationPolicy.id
345
+ serviceName: props.serviceName!,
346
+ resourceGroupName: props.resourceGroupName!,
347
+ apiId: api.name,
348
+ operationId: operationId,
349
+ policyId: 'policy',
350
+ value: policyXmlContent,
351
+ format: PolicyContentFormat.Xml,
352
+ },
353
+ { parent: scope }
348
354
  )
349
355
  })
350
356
 
351
- return apiManagementApi
357
+ return api
352
358
  }
353
359
 
354
360
  /**
355
- * @summary Method to create a new api management custom domain
361
+ * @summary Method to create a new API Management custom domain
356
362
  * @param id scoped id of the resource
357
363
  * @param scope scope in which this resource is defined
358
- * @param props api management custom domain properties
359
- * @see [CDKTF Api management Custom Domain Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/createApiManagementCustomDomain.typescript.md}
364
+ * @param props API Management custom domain properties
365
+ * @note In Pulumi Azure Native, custom domains are configured as part of the API Management service resource,
366
+ * not as a separate resource. Use the hostnameConfigurations property when creating the service.
360
367
  */
361
368
  public createApiManagementCustomDomain(
362
369
  id: string,
@@ -365,15 +372,11 @@ export class AzureApiManagementManager {
365
372
  ) {
366
373
  if (!props) throw `Props undefined for ${id}`
367
374
 
368
- const apiManagementCustomDomain = new ApiManagementCustomDomain(scope, `${id}-am-cd`, props)
369
-
370
- createAzureTfOutput(
371
- `${id}-apiManagementCustomDomainFriendlyUniqueId`,
372
- scope,
373
- apiManagementCustomDomain.friendlyUniqueId
375
+ // Note: In Pulumi Azure Native, custom domains are part of the ApiManagementService
376
+ // This method is provided for API compatibility but should be configured
377
+ // via the hostnameConfigurations property of ApiManagementService instead
378
+ throw new Error(
379
+ 'Custom domains should be configured via the hostnameConfigurations property of ApiManagementService in Pulumi Azure Native'
374
380
  )
375
- createAzureTfOutput(`${id}-apiManagementCustomDomainId`, scope, apiManagementCustomDomain.id)
376
-
377
- return apiManagementCustomDomain
378
381
  }
379
382
  }
@@ -1,28 +1,44 @@
1
- import { ApiManagementConfig } from '@cdktf/provider-azurerm/lib/api-management/index.js'
2
- import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-management-backend/index.js'
3
- import { ApiManagementCustomDomainConfig } from '@cdktf/provider-azurerm/lib/api-management-custom-domain/index.js'
4
- import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api/index.js'
5
- import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation/index.js'
6
- import { ApiManagementRedisCacheConfig } from '@cdktf/provider-azurerm/lib/api-management-redis-cache/index.js'
1
+ import {
2
+ ApiArgs,
3
+ ApiManagementServiceArgs,
4
+ ApiOperationArgs,
5
+ BackendArgs,
6
+ GetApiManagementServiceOutputArgs,
7
+ } from '@pulumi/azure-native/apimanagement/index.js'
7
8
 
8
- export interface ApiManagementProps extends ApiManagementConfig {}
9
+ export interface ApiManagementProps extends ApiManagementServiceArgs {}
9
10
 
10
- export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
11
+ export interface ApiManagementBackendProps extends BackendArgs {
11
12
  backendUrlPath?: string
12
- apiManagementId: string
13
- circuitBreaker: any
13
+ apiManagementId?: string
14
+ circuitBreaker?: any
14
15
  }
15
16
 
16
- export interface ApiManagementCustomDomainProps extends ApiManagementCustomDomainConfig {}
17
+ export interface ApiManagementCustomDomainProps {
18
+ apiManagementId: string
19
+ gateway?: Array<{
20
+ hostName: string
21
+ certificateId?: string
22
+ negotiateClientCertificate?: boolean
23
+ }>
24
+ developerPortal?: Array<{
25
+ hostName: string
26
+ certificateId?: string
27
+ }>
28
+ management?: Array<{
29
+ hostName: string
30
+ certificateId?: string
31
+ }>
32
+ }
17
33
 
18
- export interface ApiManagementApiProps extends ApiManagementApiConfig {
34
+ export interface ApiManagementApiProps extends ApiArgs {
19
35
  operations: ApiManagementApiOperationProps[]
20
- commonInboundPolicyXml: string
21
- commonOutboundPolicyXml: string
36
+ commonInboundPolicyXml?: string
37
+ commonOutboundPolicyXml?: string
22
38
  rateLimit?: ApiManagementApiRateLimit
23
39
  }
24
40
 
25
- export interface ApiManagementApiOperationProps extends ApiManagementApiOperationConfig {
41
+ export interface ApiManagementApiOperationProps extends ApiOperationArgs {
26
42
  caching?: ApiManagementApiCaching
27
43
  }
28
44
 
@@ -38,4 +54,11 @@ export interface ApiManagementApiRateLimit {
38
54
  renewalPeriodInSecs: number
39
55
  }
40
56
 
41
- export interface ApiManagementRedisCacheProps extends ApiManagementRedisCacheConfig {}
57
+ export interface ApiManagementRedisCacheProps {
58
+ apiManagementId: string
59
+ connectionString: string
60
+ cacheLocation: string
61
+ redisCacheId: string
62
+ }
63
+
64
+ export interface ResolveApiManagementProps extends GetApiManagementServiceOutputArgs {}
@@ -1,20 +1,18 @@
1
- import { AppConfiguration } from '@cdktf/provider-azurerm/lib/app-configuration/index.js'
2
- import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group/index.js'
1
+ import { ConfigurationStore, IdentityType } from '@pulumi/azure-native/appconfiguration/index.js'
3
2
  import { CommonAzureConstruct } from '../../common/index.js'
4
- import { createAzureTfOutput } from '../../utils/index.js'
5
3
  import { AppConfigurationProps } from './types.js'
6
4
 
7
5
  /**
8
- * @classdesc Provides operations on Azure App Configuration
6
+ * @classdesc Provides operations on Azure App Configuration 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
17
  * this.appConfigurationManager.createAppConfiguration('MyAppConfiguration', this, props)
20
18
  * }
@@ -27,35 +25,39 @@ export class AzureAppConfigurationManager {
27
25
  * @param id scoped id of the resource
28
26
  * @param scope scope in which this resource is defined
29
27
  * @param props app configuration properties
30
- * @see [CDKTF App Configuration plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appConfiguration.typescript.md}
28
+ * @see [Pulumi Azure Native App Configuration]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/appconfiguration/configurationstore/}
31
29
  */
32
- public createAppConfiguration(id: string, scope: CommonAzureConstruct, props: AppConfigurationProps) {
30
+ public createConfigurationStore(id: string, scope: CommonAzureConstruct, props: AppConfigurationProps) {
33
31
  if (!props) throw `Props undefined for ${id}`
34
32
 
35
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-ac-rg`, {
36
- name: scope.props.resourceGroupName
37
- ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
38
- : `${props.resourceGroupName}`,
39
- })
33
+ // Get resource group name
34
+ const resourceGroupName = scope.props.resourceGroupName
35
+ ? scope.resourceNameFormatter.format(scope.props.resourceGroupName)
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 appConfiguration = new AppConfiguration(scope, `${id}-ac`, {
44
- ...props,
45
- name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appConfiguration),
46
- resourceGroupName: resourceGroup.name,
47
- identity: {
48
- type: 'SystemAssigned',
49
- },
50
- tags: props.tags ?? {
51
- environment: scope.props.stage,
40
+ return new ConfigurationStore(
41
+ `${id}-ac`,
42
+ {
43
+ ...props,
44
+ configStoreName: scope.resourceNameFormatter.format(
45
+ props.configStoreName?.toString(),
46
+ scope.props.resourceNameOptions?.appConfiguration
47
+ ),
48
+ resourceGroupName: resourceGroupName,
49
+ location: props.location ?? scope.props.location,
50
+ identity: props.identity ?? {
51
+ type: IdentityType.SystemAssigned,
52
+ },
53
+ sku: props.sku ?? {
54
+ name: 'standard',
55
+ },
56
+ tags: props.tags ?? {
57
+ environment: scope.props.stage,
58
+ },
52
59
  },
53
- })
54
-
55
- createAzureTfOutput(`${id}-appConfigurationName`, scope, appConfiguration.name)
56
- createAzureTfOutput(`${id}-appConfigurationFriendlyUniqueId`, scope, appConfiguration.friendlyUniqueId)
57
- createAzureTfOutput(`${id}-appConfigurationId`, scope, appConfiguration.id)
58
-
59
- return appConfiguration
60
+ { parent: scope }
61
+ )
60
62
  }
61
63
  }
@@ -1,3 +1,3 @@
1
- import { AppConfigurationConfig } from '@cdktf/provider-azurerm/lib/app-configuration/index.js'
1
+ import { ConfigurationStoreArgs } from '@pulumi/azure-native/appconfiguration/index.js'
2
2
 
3
- export interface AppConfigurationProps extends AppConfigurationConfig {}
3
+ export interface AppConfigurationProps extends ConfigurationStoreArgs {}