@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.
- package/dist/src/lib/azure/common/constants.d.ts +3 -2
- package/dist/src/lib/azure/common/constants.js +2 -1
- package/dist/src/lib/azure/common/construct.d.ts +26 -12
- package/dist/src/lib/azure/common/construct.js +31 -45
- package/dist/src/lib/azure/common/resource-name-formatter.d.ts +9 -4
- package/dist/src/lib/azure/common/resource-name-formatter.js +9 -5
- package/dist/src/lib/azure/common/stack.d.ts +18 -32
- package/dist/src/lib/azure/common/stack.js +77 -74
- package/dist/src/lib/azure/common/tagging.d.ts +29 -8
- package/dist/src/lib/azure/common/tagging.js +72 -26
- package/dist/src/lib/azure/common/types.d.ts +19 -4
- package/dist/src/lib/azure/services/api-management/main.d.ts +29 -32
- package/dist/src/lib/azure/services/api-management/main.js +100 -121
- package/dist/src/lib/azure/services/api-management/types.d.ts +33 -18
- package/dist/src/lib/azure/services/app-configuration/main.d.ts +6 -7
- package/dist/src/lib/azure/services/app-configuration/main.js +23 -26
- package/dist/src/lib/azure/services/app-configuration/types.d.ts +2 -2
- package/dist/src/lib/azure/services/app-service/main.d.ts +10 -12
- package/dist/src/lib/azure/services/app-service/main.js +37 -49
- package/dist/src/lib/azure/services/app-service/types.d.ts +4 -4
- package/dist/src/lib/azure/services/application-insights/main.d.ts +7 -8
- package/dist/src/lib/azure/services/application-insights/main.js +20 -26
- package/dist/src/lib/azure/services/application-insights/types.d.ts +2 -4
- package/dist/src/lib/azure/services/cosmosdb/main.d.ts +12 -15
- package/dist/src/lib/azure/services/cosmosdb/main.js +42 -61
- package/dist/src/lib/azure/services/cosmosdb/types.d.ts +4 -6
- package/dist/src/lib/azure/services/dns/main.d.ts +13 -17
- package/dist/src/lib/azure/services/dns/main.js +33 -51
- package/dist/src/lib/azure/services/dns/types.d.ts +5 -8
- package/dist/src/lib/azure/services/eventgrid/main.d.ts +20 -22
- package/dist/src/lib/azure/services/eventgrid/main.js +61 -89
- package/dist/src/lib/azure/services/eventgrid/types.d.ts +7 -8
- package/dist/src/lib/azure/services/function/main.d.ts +15 -15
- package/dist/src/lib/azure/services/function/main.js +54 -59
- package/dist/src/lib/azure/services/function/types.d.ts +18 -6
- package/dist/src/lib/azure/services/index.d.ts +1 -1
- package/dist/src/lib/azure/services/index.js +1 -1
- package/dist/src/lib/azure/services/key-vault/main.d.ts +6 -7
- package/dist/src/lib/azure/services/key-vault/main.js +29 -28
- package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -2
- package/dist/src/lib/azure/services/monitor/main.d.ts +7 -8
- package/dist/src/lib/azure/services/monitor/main.js +10 -15
- package/dist/src/lib/azure/services/monitor/types.d.ts +2 -2
- package/dist/src/lib/azure/services/operational-insights/main.d.ts +29 -0
- package/dist/src/lib/azure/services/operational-insights/main.js +50 -0
- package/dist/src/lib/azure/services/operational-insights/types.d.ts +3 -0
- package/dist/src/lib/azure/services/redis/main.d.ts +8 -9
- package/dist/src/lib/azure/services/redis/main.js +24 -26
- package/dist/src/lib/azure/services/redis/types.d.ts +2 -2
- package/dist/src/lib/azure/services/resource-group/main.d.ts +6 -7
- package/dist/src/lib/azure/services/resource-group/main.js +9 -14
- package/dist/src/lib/azure/services/resource-group/types.d.ts +2 -2
- package/dist/src/lib/azure/services/servicebus/main.d.ts +17 -22
- package/dist/src/lib/azure/services/servicebus/main.js +47 -70
- package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -10
- package/dist/src/lib/azure/services/storage/main.d.ts +24 -27
- package/dist/src/lib/azure/services/storage/main.js +70 -88
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -8
- package/dist/src/lib/azure/types/index.d.ts +2 -1
- package/dist/src/lib/azure/utils/index.d.ts +19 -3
- package/dist/src/lib/azure/utils/index.js +19 -13
- package/dist/src/lib/cloudflare/common/stack.js +1 -1
- package/package.json +2 -1
- package/src/lib/azure/common/constants.ts +2 -1
- package/src/lib/azure/common/construct.ts +32 -48
- package/src/lib/azure/common/resource-name-formatter.ts +10 -6
- package/src/lib/azure/common/stack.ts +78 -78
- package/src/lib/azure/common/tagging.ts +78 -29
- package/src/lib/azure/common/types.ts +21 -4
- package/src/lib/azure/services/api-management/main.ts +172 -169
- package/src/lib/azure/services/api-management/types.ts +39 -16
- package/src/lib/azure/services/app-configuration/main.ts +33 -31
- package/src/lib/azure/services/app-configuration/types.ts +2 -2
- package/src/lib/azure/services/app-service/main.ts +61 -62
- package/src/lib/azure/services/app-service/types.ts +4 -4
- package/src/lib/azure/services/application-insights/main.ts +29 -30
- package/src/lib/azure/services/application-insights/types.ts +2 -5
- package/src/lib/azure/services/cosmosdb/main.ts +78 -77
- package/src/lib/azure/services/cosmosdb/types.ts +10 -6
- package/src/lib/azure/services/dns/main.ts +65 -72
- package/src/lib/azure/services/dns/types.ts +9 -9
- package/src/lib/azure/services/eventgrid/main.ts +120 -122
- package/src/lib/azure/services/eventgrid/types.ts +13 -8
- package/src/lib/azure/services/function/main.ts +75 -72
- package/src/lib/azure/services/function/types.ts +21 -6
- package/src/lib/azure/services/index.ts +1 -1
- package/src/lib/azure/services/key-vault/main.ts +38 -32
- package/src/lib/azure/services/key-vault/types.ts +4 -2
- package/src/lib/azure/services/monitor/main.ts +17 -21
- package/src/lib/azure/services/monitor/types.ts +2 -2
- package/src/lib/azure/services/operational-insights/main.ts +61 -0
- package/src/lib/azure/services/operational-insights/types.ts +3 -0
- package/src/lib/azure/services/redis/main.ts +30 -30
- package/src/lib/azure/services/redis/types.ts +2 -2
- package/src/lib/azure/services/resource-group/main.ts +20 -20
- package/src/lib/azure/services/resource-group/types.ts +2 -2
- package/src/lib/azure/services/servicebus/main.ts +103 -94
- package/src/lib/azure/services/servicebus/types.ts +17 -11
- package/src/lib/azure/services/storage/main.ts +113 -114
- package/src/lib/azure/services/storage/types.ts +16 -8
- package/src/lib/azure/types/index.ts +2 -1
- package/src/lib/azure/utils/index.ts +20 -22
- package/src/lib/cloudflare/common/stack.ts +1 -1
- package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +0 -30
- package/dist/src/lib/azure/services/log-analytics-workspace/main.js +0 -55
- package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +0 -3
- package/src/lib/azure/services/log-analytics-workspace/main.ts +0 -61
- package/src/lib/azure/services/log-analytics-workspace/types.ts +0 -3
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.d.ts +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/index.js +0 -0
- /package/dist/src/lib/azure/services/{log-analytics-workspace → operational-insights}/types.js +0 -0
- /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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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(
|
|
38
|
-
* super(
|
|
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
|
|
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
|
|
51
|
-
* @
|
|
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
|
|
53
|
+
public createApiManagementService(
|
|
54
54
|
id: string,
|
|
55
55
|
scope: CommonAzureConstruct,
|
|
56
56
|
props: ApiManagementProps,
|
|
57
|
-
applicationInsightsKey?:
|
|
58
|
-
externalRedisCache?:
|
|
57
|
+
applicationInsightsKey?: string,
|
|
58
|
+
externalRedisCache?: redis.Redis
|
|
59
59
|
) {
|
|
60
60
|
if (!props) throw `Props undefined for ${id}`
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
112
|
-
* @see [
|
|
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
|
|
140
|
+
public resolveApiManagementService(id: string, scope: CommonAzureConstruct, props: ResolveApiManagementProps) {
|
|
115
141
|
if (!props) throw `Props undefined for ${id}`
|
|
116
142
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
|
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
|
|
141
|
-
* @see [
|
|
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
|
|
164
|
+
public createBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
|
|
144
165
|
if (!props) throw `Props undefined for ${id}`
|
|
145
166
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
|
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
|
|
165
|
-
* @see [
|
|
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
|
|
189
|
+
public createApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
|
|
168
190
|
if (!props) throw `Props undefined for ${id}`
|
|
169
191
|
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
|
184
|
-
|
|
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:
|
|
188
|
-
method: operation.method
|
|
189
|
-
|
|
190
|
-
resourceGroupName:
|
|
191
|
-
|
|
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
|
-
|
|
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}-${
|
|
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
|
-
|
|
328
|
-
scope,
|
|
342
|
+
new ApiOperationPolicy(
|
|
329
343
|
`${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`,
|
|
330
344
|
{
|
|
331
|
-
|
|
332
|
-
resourceGroupName:
|
|
333
|
-
|
|
334
|
-
operationId:
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
|
357
|
+
return api
|
|
352
358
|
}
|
|
353
359
|
|
|
354
360
|
/**
|
|
355
|
-
* @summary Method to create a new
|
|
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
|
|
359
|
-
* @
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
9
|
+
export interface ApiManagementProps extends ApiManagementServiceArgs {}
|
|
9
10
|
|
|
10
|
-
export interface ApiManagementBackendProps extends
|
|
11
|
+
export interface ApiManagementBackendProps extends BackendArgs {
|
|
11
12
|
backendUrlPath?: string
|
|
12
|
-
apiManagementId
|
|
13
|
-
circuitBreaker
|
|
13
|
+
apiManagementId?: string
|
|
14
|
+
circuitBreaker?: any
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export interface ApiManagementCustomDomainProps
|
|
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
|
|
34
|
+
export interface ApiManagementApiProps extends ApiArgs {
|
|
19
35
|
operations: ApiManagementApiOperationProps[]
|
|
20
|
-
commonInboundPolicyXml
|
|
21
|
-
commonOutboundPolicyXml
|
|
36
|
+
commonInboundPolicyXml?: string
|
|
37
|
+
commonOutboundPolicyXml?: string
|
|
22
38
|
rateLimit?: ApiManagementApiRateLimit
|
|
23
39
|
}
|
|
24
40
|
|
|
25
|
-
export interface ApiManagementApiOperationProps extends
|
|
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
|
|
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 {
|
|
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(
|
|
17
|
-
* super(
|
|
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 [
|
|
28
|
+
* @see [Pulumi Azure Native App Configuration]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/appconfiguration/configurationstore/}
|
|
31
29
|
*/
|
|
32
|
-
public
|
|
30
|
+
public createConfigurationStore(id: string, scope: CommonAzureConstruct, props: AppConfigurationProps) {
|
|
33
31
|
if (!props) throw `Props undefined for ${id}`
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 (!
|
|
38
|
+
if (!resourceGroupName) throw `Resource group name undefined for ${id}`
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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 {
|
|
1
|
+
import { ConfigurationStoreArgs } from '@pulumi/azure-native/appconfiguration/index.js'
|
|
2
2
|
|
|
3
|
-
export interface AppConfigurationProps extends
|
|
3
|
+
export interface AppConfigurationProps extends ConfigurationStoreArgs {}
|