@gradientedge/cdk-utils 9.38.1 → 9.39.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/services/api-management/main.js +11 -10
- package/dist/src/lib/azure/services/api-management/types.d.ts +1 -5
- package/dist/src/lib/azure/services/eventgrid/main.js +2 -0
- package/dist/src/lib/azure/services/servicebus/main.d.ts +21 -3
- package/dist/src/lib/azure/services/servicebus/main.js +62 -2
- package/dist/src/lib/azure/services/servicebus/types.d.ts +6 -0
- package/package.json +1 -1
- package/src/lib/azure/services/api-management/main.ts +11 -10
- package/src/lib/azure/services/api-management/types.ts +1 -6
- package/src/lib/azure/services/eventgrid/main.ts +2 -0
- package/src/lib/azure/services/servicebus/main.ts +75 -3
- package/src/lib/azure/services/servicebus/types.ts +4 -0
|
@@ -140,28 +140,29 @@ class AzureApiManagementManager {
|
|
|
140
140
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
|
|
141
141
|
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiId`, scope, apiManagementApi.id);
|
|
142
142
|
lodash_1.default.forEach(props.operations, operation => {
|
|
143
|
-
const apimOperation = new api_management_api_operation_1.ApiManagementApiOperation(scope, `${id}-apim-api-operation-${operation.
|
|
144
|
-
operationId: `${operation.
|
|
143
|
+
const apimOperation = new api_management_api_operation_1.ApiManagementApiOperation(scope, `${id}-apim-api-operation-${operation.displayName}-${operation.method}`, {
|
|
144
|
+
operationId: `${operation.displayName}-${operation.method}`,
|
|
145
145
|
method: operation.method.toUpperCase(),
|
|
146
146
|
apiManagementName: apiManagementApi.apiManagementName,
|
|
147
147
|
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
148
148
|
apiName: apiManagementApi.name,
|
|
149
|
-
displayName:
|
|
150
|
-
urlTemplate:
|
|
149
|
+
displayName: operation.displayName,
|
|
150
|
+
urlTemplate: operation.urlTemplate,
|
|
151
|
+
templateParameter: operation.templateParameter,
|
|
151
152
|
});
|
|
152
|
-
(0, utils_1.createAzureTfOutput)(`${id}-${operation.
|
|
153
|
-
(0, utils_1.createAzureTfOutput)(`${id}-${operation.
|
|
154
|
-
(0, utils_1.createAzureTfOutput)(`${id}-${operation.
|
|
153
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.displayName}-${operation.method}-apimOperationOperationId`, scope, apimOperation.operationId);
|
|
154
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.displayName}-${operation.method}-apimOperationFriendlyUniqueId`, scope, apimOperation.friendlyUniqueId);
|
|
155
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.displayName}-${operation.method}-apimOperationId`, scope, apimOperation.id);
|
|
155
156
|
if (props.policyXmlContent) {
|
|
156
|
-
const apimOperationPolicy = new api_management_api_operation_policy_1.ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.
|
|
157
|
+
const apimOperationPolicy = new api_management_api_operation_policy_1.ApiManagementApiOperationPolicy(scope, `${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`, {
|
|
157
158
|
apiManagementName: apiManagementApi.apiManagementName,
|
|
158
159
|
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
159
160
|
apiName: apiManagementApi.name,
|
|
160
161
|
operationId: apimOperation.operationId,
|
|
161
162
|
xmlContent: props.policyXmlContent,
|
|
162
163
|
});
|
|
163
|
-
(0, utils_1.createAzureTfOutput)(`${id}-${operation.
|
|
164
|
-
(0, utils_1.createAzureTfOutput)(`${id}-${operation.
|
|
164
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyFriendlyUniqueId`, scope, apimOperationPolicy.friendlyUniqueId);
|
|
165
|
+
(0, utils_1.createAzureTfOutput)(`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyId`, scope, apimOperationPolicy.id);
|
|
165
166
|
}
|
|
166
167
|
});
|
|
167
168
|
return apiManagementApi;
|
|
@@ -8,10 +8,6 @@ export interface ApiManagementProps extends ApiManagementConfig {
|
|
|
8
8
|
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
9
9
|
}
|
|
10
10
|
export interface ApiManagementApiProps extends ApiManagementApiConfig {
|
|
11
|
-
operations:
|
|
11
|
+
operations: ApiManagementApiOperationConfig[];
|
|
12
12
|
policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent'];
|
|
13
13
|
}
|
|
14
|
-
export interface OperationsProps {
|
|
15
|
-
path: ApiManagementApiOperationConfig['urlTemplate'];
|
|
16
|
-
method: ApiManagementApiOperationConfig['method'];
|
|
17
|
-
}
|
|
@@ -67,6 +67,8 @@ class AzureEventgridManager {
|
|
|
67
67
|
const eventgridSubscription = new eventgrid_event_subscription_1.EventgridEventSubscription(scope, `${id}-es`, {
|
|
68
68
|
...props,
|
|
69
69
|
name: `${props.name}-${scope.props.stage}`,
|
|
70
|
+
eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
|
|
71
|
+
advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
|
|
70
72
|
});
|
|
71
73
|
(0, utils_1.createAzureTfOutput)(`${id}-eventgridSubscriptiontName`, scope, eventgridSubscription.name);
|
|
72
74
|
(0, utils_1.createAzureTfOutput)(`${id}-eventgridSubscriptionFriendlyUniqueId`, scope, eventgridSubscription.friendlyUniqueId);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ServicebusNamespace } from '@cdktf/provider-azurerm/lib/servicebus-namespace';
|
|
1
2
|
import { ServicebusTopic } from '@cdktf/provider-azurerm/lib/servicebus-topic';
|
|
2
3
|
import { ServicebusSubscription } from '@cdktf/provider-azurerm/lib/servicebus-subscription';
|
|
4
|
+
import { ServicebusQueue } from '@cdktf/provider-azurerm/lib/servicebus-queue';
|
|
3
5
|
import { CommonAzureConstruct } from '../../common';
|
|
4
|
-
import { ServicebusTopicProps, ServicebusSubscriptionProps } from './types';
|
|
6
|
+
import { ServicebusTopicProps, ServicebusSubscriptionProps, ServicebusNamespaceProps, ServicebusQueueProps } from './types';
|
|
5
7
|
/**
|
|
6
|
-
* @classdesc Provides operations on Azure
|
|
8
|
+
* @classdesc Provides operations on Azure Servicebus
|
|
7
9
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
8
10
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
9
11
|
* @example
|
|
@@ -14,12 +16,20 @@ import { ServicebusTopicProps, ServicebusSubscriptionProps } from './types';
|
|
|
14
16
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
15
17
|
* super(parent, id, props)
|
|
16
18
|
* this.props = props
|
|
17
|
-
* this.
|
|
19
|
+
* this.ServicebusManager.createServicebusTopic('MyServicebusTopic', this, props)
|
|
18
20
|
* }
|
|
19
21
|
* }
|
|
20
22
|
* ```
|
|
21
23
|
*/
|
|
22
24
|
export declare class AzureServicebusManager {
|
|
25
|
+
/**
|
|
26
|
+
* @summary Method to create a new servicebus namespace
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props servicebus namespace properties
|
|
30
|
+
* @see [CDKTF Servicebus Namespace Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusNamespace.typescript.md}
|
|
31
|
+
*/
|
|
32
|
+
createServicebusNamespace(id: string, scope: CommonAzureConstruct, props: ServicebusNamespaceProps): ServicebusNamespace;
|
|
23
33
|
/**
|
|
24
34
|
* @summary Method to create a new servicebus topic
|
|
25
35
|
* @param id scoped id of the resource
|
|
@@ -28,6 +38,14 @@ export declare class AzureServicebusManager {
|
|
|
28
38
|
* @see [CDKTF Servicebus Topic Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusTopic.typescript.md}
|
|
29
39
|
*/
|
|
30
40
|
createServicebusTopic(id: string, scope: CommonAzureConstruct, props: ServicebusTopicProps): ServicebusTopic;
|
|
41
|
+
/**
|
|
42
|
+
* @summary Method to create a new servicebus queue
|
|
43
|
+
* @param id scoped id of the resource
|
|
44
|
+
* @param scope scope in which this resource is defined
|
|
45
|
+
* @param props servicebus queue properties
|
|
46
|
+
* @see [CDKTF Servicebus Queue Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusQueue.typescript.md}
|
|
47
|
+
*/
|
|
48
|
+
createServicebusQueue(id: string, scope: CommonAzureConstruct, props: ServicebusQueueProps): ServicebusQueue;
|
|
31
49
|
/**
|
|
32
50
|
* @summary Method to create a new servicebus subscription
|
|
33
51
|
* @param id scoped id of the resource
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AzureServicebusManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const servicebus_namespace_1 = require("@cdktf/provider-azurerm/lib/servicebus-namespace");
|
|
4
6
|
const servicebus_topic_1 = require("@cdktf/provider-azurerm/lib/servicebus-topic");
|
|
5
7
|
const servicebus_subscription_1 = require("@cdktf/provider-azurerm/lib/servicebus-subscription");
|
|
8
|
+
const servicebus_queue_1 = require("@cdktf/provider-azurerm/lib/servicebus-queue");
|
|
6
9
|
const utils_1 = require("../../utils");
|
|
7
10
|
/**
|
|
8
|
-
* @classdesc Provides operations on Azure
|
|
11
|
+
* @classdesc Provides operations on Azure Servicebus
|
|
9
12
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
10
13
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
11
14
|
* @example
|
|
@@ -16,12 +19,47 @@ const utils_1 = require("../../utils");
|
|
|
16
19
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
17
20
|
* super(parent, id, props)
|
|
18
21
|
* this.props = props
|
|
19
|
-
* this.
|
|
22
|
+
* this.ServicebusManager.createServicebusTopic('MyServicebusTopic', this, props)
|
|
20
23
|
* }
|
|
21
24
|
* }
|
|
22
25
|
* ```
|
|
23
26
|
*/
|
|
24
27
|
class AzureServicebusManager {
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create a new servicebus namespace
|
|
30
|
+
* @param id scoped id of the resource
|
|
31
|
+
* @param scope scope in which this resource is defined
|
|
32
|
+
* @param props servicebus namespace properties
|
|
33
|
+
* @see [CDKTF Servicebus Namespace Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusNamespace.typescript.md}
|
|
34
|
+
*/
|
|
35
|
+
createServicebusNamespace(id, scope, props) {
|
|
36
|
+
if (!props)
|
|
37
|
+
throw `Props undefined for ${id}`;
|
|
38
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sn-rg`, {
|
|
39
|
+
name: scope.props.resourceGroupName
|
|
40
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
41
|
+
: `${props.resourceGroupName}`,
|
|
42
|
+
});
|
|
43
|
+
if (!resourceGroup)
|
|
44
|
+
throw `Resource group undefined for ${id}`;
|
|
45
|
+
const servicebusNamespace = new servicebus_namespace_1.ServicebusNamespace(scope, `${id}-sn`, {
|
|
46
|
+
...props,
|
|
47
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
48
|
+
resourceGroupName: resourceGroup.name,
|
|
49
|
+
location: resourceGroup.location,
|
|
50
|
+
identity: {
|
|
51
|
+
type: props.identity?.type || 'SystemAssigned',
|
|
52
|
+
},
|
|
53
|
+
sku: props.sku || 'Standard',
|
|
54
|
+
tags: props.tags ?? {
|
|
55
|
+
environment: scope.props.stage,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusNamespaceName`, scope, servicebusNamespace.name);
|
|
59
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusNamespaceFriendlyUniqueId`, scope, servicebusNamespace.friendlyUniqueId);
|
|
60
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusNamespaceId`, scope, servicebusNamespace.id);
|
|
61
|
+
return servicebusNamespace;
|
|
62
|
+
}
|
|
25
63
|
/**
|
|
26
64
|
* @summary Method to create a new servicebus topic
|
|
27
65
|
* @param id scoped id of the resource
|
|
@@ -35,12 +73,33 @@ class AzureServicebusManager {
|
|
|
35
73
|
const servicebusTopic = new servicebus_topic_1.ServicebusTopic(scope, `${id}-st`, {
|
|
36
74
|
...props,
|
|
37
75
|
name: `${props.name}-${scope.props.stage}`,
|
|
76
|
+
namespaceId: props.namespaceId,
|
|
38
77
|
});
|
|
39
78
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusTopicName`, scope, servicebusTopic.name);
|
|
40
79
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusTopicFriendlyUniqueId`, scope, servicebusTopic.friendlyUniqueId);
|
|
41
80
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusTopicId`, scope, servicebusTopic.id);
|
|
42
81
|
return servicebusTopic;
|
|
43
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* @summary Method to create a new servicebus queue
|
|
85
|
+
* @param id scoped id of the resource
|
|
86
|
+
* @param scope scope in which this resource is defined
|
|
87
|
+
* @param props servicebus queue properties
|
|
88
|
+
* @see [CDKTF Servicebus Queue Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusQueue.typescript.md}
|
|
89
|
+
*/
|
|
90
|
+
createServicebusQueue(id, scope, props) {
|
|
91
|
+
if (!props)
|
|
92
|
+
throw `Props undefined for ${id}`;
|
|
93
|
+
const servicebusQueue = new servicebus_queue_1.ServicebusQueue(scope, `${id}-sq`, {
|
|
94
|
+
...props,
|
|
95
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
96
|
+
namespaceId: props.namespaceId,
|
|
97
|
+
});
|
|
98
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusQueueName`, scope, servicebusQueue.name);
|
|
99
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusQueueFriendlyUniqueId`, scope, servicebusQueue.friendlyUniqueId);
|
|
100
|
+
(0, utils_1.createAzureTfOutput)(`${id}-servicebusQueueId`, scope, servicebusQueue.id);
|
|
101
|
+
return servicebusQueue;
|
|
102
|
+
}
|
|
44
103
|
/**
|
|
45
104
|
* @summary Method to create a new servicebus subscription
|
|
46
105
|
* @param id scoped id of the resource
|
|
@@ -54,6 +113,7 @@ class AzureServicebusManager {
|
|
|
54
113
|
const servicebusSubscription = new servicebus_subscription_1.ServicebusSubscription(scope, `${id}-ss`, {
|
|
55
114
|
...props,
|
|
56
115
|
name: `${props.name}-${scope.props.stage}`,
|
|
116
|
+
maxDeliveryCount: props.maxDeliveryCount || 1,
|
|
57
117
|
});
|
|
58
118
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusSubscriptionName`, scope, servicebusSubscription.name);
|
|
59
119
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusSubscriptionFriendlyUniqueId`, scope, servicebusSubscription.friendlyUniqueId);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { ServicebusNamespaceConfig } from '@cdktf/provider-azurerm/lib/servicebus-namespace';
|
|
1
2
|
import { ServicebusTopicConfig } from '@cdktf/provider-azurerm/lib/servicebus-topic';
|
|
3
|
+
import { ServicebusQueueConfig } from '@cdktf/provider-azurerm/lib/servicebus-queue';
|
|
2
4
|
import { ServicebusSubscriptionConfig } from '@cdktf/provider-azurerm/lib/servicebus-subscription';
|
|
5
|
+
export interface ServicebusNamespaceProps extends ServicebusNamespaceConfig {
|
|
6
|
+
}
|
|
3
7
|
export interface ServicebusTopicProps extends ServicebusTopicConfig {
|
|
4
8
|
}
|
|
9
|
+
export interface ServicebusQueueProps extends ServicebusQueueConfig {
|
|
10
|
+
}
|
|
5
11
|
export interface ServicebusSubscriptionProps extends ServicebusSubscriptionConfig {
|
|
6
12
|
}
|
package/package.json
CHANGED
|
@@ -163,34 +163,35 @@ export class AzureApiManagementManager {
|
|
|
163
163
|
_.forEach(props.operations, operation => {
|
|
164
164
|
const apimOperation = new ApiManagementApiOperation(
|
|
165
165
|
scope,
|
|
166
|
-
`${id}-apim-api-operation-${operation.
|
|
166
|
+
`${id}-apim-api-operation-${operation.displayName}-${operation.method}`,
|
|
167
167
|
{
|
|
168
|
-
operationId: `${operation.
|
|
168
|
+
operationId: `${operation.displayName}-${operation.method}`,
|
|
169
169
|
method: operation.method.toUpperCase(),
|
|
170
170
|
apiManagementName: apiManagementApi.apiManagementName,
|
|
171
171
|
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
172
172
|
apiName: apiManagementApi.name,
|
|
173
|
-
displayName:
|
|
174
|
-
urlTemplate:
|
|
173
|
+
displayName: operation.displayName,
|
|
174
|
+
urlTemplate: operation.urlTemplate,
|
|
175
|
+
templateParameter: operation.templateParameter,
|
|
175
176
|
}
|
|
176
177
|
)
|
|
177
178
|
|
|
178
179
|
createAzureTfOutput(
|
|
179
|
-
`${id}-${operation.
|
|
180
|
+
`${id}-${operation.displayName}-${operation.method}-apimOperationOperationId`,
|
|
180
181
|
scope,
|
|
181
182
|
apimOperation.operationId
|
|
182
183
|
)
|
|
183
184
|
createAzureTfOutput(
|
|
184
|
-
`${id}-${operation.
|
|
185
|
+
`${id}-${operation.displayName}-${operation.method}-apimOperationFriendlyUniqueId`,
|
|
185
186
|
scope,
|
|
186
187
|
apimOperation.friendlyUniqueId
|
|
187
188
|
)
|
|
188
|
-
createAzureTfOutput(`${id}-${operation.
|
|
189
|
+
createAzureTfOutput(`${id}-${operation.displayName}-${operation.method}-apimOperationId`, scope, apimOperation.id)
|
|
189
190
|
|
|
190
191
|
if (props.policyXmlContent) {
|
|
191
192
|
const apimOperationPolicy = new ApiManagementApiOperationPolicy(
|
|
192
193
|
scope,
|
|
193
|
-
`${id}-apim-api-operation-policy-${operation.
|
|
194
|
+
`${id}-apim-api-operation-policy-${operation.displayName}-${operation.method}`,
|
|
194
195
|
{
|
|
195
196
|
apiManagementName: apiManagementApi.apiManagementName,
|
|
196
197
|
resourceGroupName: apiManagementApi.resourceGroupName,
|
|
@@ -201,12 +202,12 @@ export class AzureApiManagementManager {
|
|
|
201
202
|
)
|
|
202
203
|
|
|
203
204
|
createAzureTfOutput(
|
|
204
|
-
`${id}-${operation.
|
|
205
|
+
`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyFriendlyUniqueId`,
|
|
205
206
|
scope,
|
|
206
207
|
apimOperationPolicy.friendlyUniqueId
|
|
207
208
|
)
|
|
208
209
|
createAzureTfOutput(
|
|
209
|
-
`${id}-${operation.
|
|
210
|
+
`${id}-${operation.displayName}-${operation.method}-apimOperationPolicyId`,
|
|
210
211
|
scope,
|
|
211
212
|
apimOperationPolicy.id
|
|
212
213
|
)
|
|
@@ -9,11 +9,6 @@ export interface ApiManagementProps extends ApiManagementConfig {}
|
|
|
9
9
|
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {}
|
|
10
10
|
|
|
11
11
|
export interface ApiManagementApiProps extends ApiManagementApiConfig {
|
|
12
|
-
operations:
|
|
12
|
+
operations: ApiManagementApiOperationConfig[]
|
|
13
13
|
policyXmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export interface OperationsProps {
|
|
17
|
-
path: ApiManagementApiOperationConfig['urlTemplate']
|
|
18
|
-
method: ApiManagementApiOperationConfig['method']
|
|
19
|
-
}
|
|
@@ -71,6 +71,8 @@ export class AzureEventgridManager {
|
|
|
71
71
|
const eventgridSubscription = new EventgridEventSubscription(scope, `${id}-es`, {
|
|
72
72
|
...props,
|
|
73
73
|
name: `${props.name}-${scope.props.stage}`,
|
|
74
|
+
eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
|
|
75
|
+
advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
|
|
74
76
|
})
|
|
75
77
|
|
|
76
78
|
createAzureTfOutput(`${id}-eventgridSubscriptiontName`, scope, eventgridSubscription.name)
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
+
import { ServicebusNamespace } from '@cdktf/provider-azurerm/lib/servicebus-namespace'
|
|
1
3
|
import { ServicebusTopic } from '@cdktf/provider-azurerm/lib/servicebus-topic'
|
|
2
4
|
import { ServicebusSubscription } from '@cdktf/provider-azurerm/lib/servicebus-subscription'
|
|
5
|
+
import { ServicebusQueue } from '@cdktf/provider-azurerm/lib/servicebus-queue'
|
|
3
6
|
import { CommonAzureConstruct } from '../../common'
|
|
4
7
|
import { createAzureTfOutput } from '../../utils'
|
|
5
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ServicebusTopicProps,
|
|
10
|
+
ServicebusSubscriptionProps,
|
|
11
|
+
ServicebusNamespaceProps,
|
|
12
|
+
ServicebusQueueProps,
|
|
13
|
+
} from './types'
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
|
-
* @classdesc Provides operations on Azure
|
|
16
|
+
* @classdesc Provides operations on Azure Servicebus
|
|
9
17
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
10
18
|
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
11
19
|
* @example
|
|
@@ -16,12 +24,51 @@ import { ServicebusTopicProps, ServicebusSubscriptionProps } from './types'
|
|
|
16
24
|
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
17
25
|
* super(parent, id, props)
|
|
18
26
|
* this.props = props
|
|
19
|
-
* this.
|
|
27
|
+
* this.ServicebusManager.createServicebusTopic('MyServicebusTopic', this, props)
|
|
20
28
|
* }
|
|
21
29
|
* }
|
|
22
30
|
* ```
|
|
23
31
|
*/
|
|
24
32
|
export class AzureServicebusManager {
|
|
33
|
+
/**
|
|
34
|
+
* @summary Method to create a new servicebus namespace
|
|
35
|
+
* @param id scoped id of the resource
|
|
36
|
+
* @param scope scope in which this resource is defined
|
|
37
|
+
* @param props servicebus namespace properties
|
|
38
|
+
* @see [CDKTF Servicebus Namespace Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusNamespace.typescript.md}
|
|
39
|
+
*/
|
|
40
|
+
public createServicebusNamespace(id: string, scope: CommonAzureConstruct, props: ServicebusNamespaceProps) {
|
|
41
|
+
if (!props) throw `Props undefined for ${id}`
|
|
42
|
+
|
|
43
|
+
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sn-rg`, {
|
|
44
|
+
name: scope.props.resourceGroupName
|
|
45
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
46
|
+
: `${props.resourceGroupName}`,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
50
|
+
|
|
51
|
+
const servicebusNamespace = new ServicebusNamespace(scope, `${id}-sn`, {
|
|
52
|
+
...props,
|
|
53
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
54
|
+
resourceGroupName: resourceGroup.name,
|
|
55
|
+
location: resourceGroup.location,
|
|
56
|
+
identity: {
|
|
57
|
+
type: props.identity?.type || 'SystemAssigned',
|
|
58
|
+
},
|
|
59
|
+
sku: props.sku || 'Standard',
|
|
60
|
+
tags: props.tags ?? {
|
|
61
|
+
environment: scope.props.stage,
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
createAzureTfOutput(`${id}-servicebusNamespaceName`, scope, servicebusNamespace.name)
|
|
66
|
+
createAzureTfOutput(`${id}-servicebusNamespaceFriendlyUniqueId`, scope, servicebusNamespace.friendlyUniqueId)
|
|
67
|
+
createAzureTfOutput(`${id}-servicebusNamespaceId`, scope, servicebusNamespace.id)
|
|
68
|
+
|
|
69
|
+
return servicebusNamespace
|
|
70
|
+
}
|
|
71
|
+
|
|
25
72
|
/**
|
|
26
73
|
* @summary Method to create a new servicebus topic
|
|
27
74
|
* @param id scoped id of the resource
|
|
@@ -35,6 +82,7 @@ export class AzureServicebusManager {
|
|
|
35
82
|
const servicebusTopic = new ServicebusTopic(scope, `${id}-st`, {
|
|
36
83
|
...props,
|
|
37
84
|
name: `${props.name}-${scope.props.stage}`,
|
|
85
|
+
namespaceId: props.namespaceId,
|
|
38
86
|
})
|
|
39
87
|
|
|
40
88
|
createAzureTfOutput(`${id}-servicebusTopicName`, scope, servicebusTopic.name)
|
|
@@ -44,6 +92,29 @@ export class AzureServicebusManager {
|
|
|
44
92
|
return servicebusTopic
|
|
45
93
|
}
|
|
46
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @summary Method to create a new servicebus queue
|
|
97
|
+
* @param id scoped id of the resource
|
|
98
|
+
* @param scope scope in which this resource is defined
|
|
99
|
+
* @param props servicebus queue properties
|
|
100
|
+
* @see [CDKTF Servicebus Queue Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/servicebusQueue.typescript.md}
|
|
101
|
+
*/
|
|
102
|
+
public createServicebusQueue(id: string, scope: CommonAzureConstruct, props: ServicebusQueueProps) {
|
|
103
|
+
if (!props) throw `Props undefined for ${id}`
|
|
104
|
+
|
|
105
|
+
const servicebusQueue = new ServicebusQueue(scope, `${id}-sq`, {
|
|
106
|
+
...props,
|
|
107
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
108
|
+
namespaceId: props.namespaceId,
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
createAzureTfOutput(`${id}-servicebusQueueName`, scope, servicebusQueue.name)
|
|
112
|
+
createAzureTfOutput(`${id}-servicebusQueueFriendlyUniqueId`, scope, servicebusQueue.friendlyUniqueId)
|
|
113
|
+
createAzureTfOutput(`${id}-servicebusQueueId`, scope, servicebusQueue.id)
|
|
114
|
+
|
|
115
|
+
return servicebusQueue
|
|
116
|
+
}
|
|
117
|
+
|
|
47
118
|
/**
|
|
48
119
|
* @summary Method to create a new servicebus subscription
|
|
49
120
|
* @param id scoped id of the resource
|
|
@@ -57,6 +128,7 @@ export class AzureServicebusManager {
|
|
|
57
128
|
const servicebusSubscription = new ServicebusSubscription(scope, `${id}-ss`, {
|
|
58
129
|
...props,
|
|
59
130
|
name: `${props.name}-${scope.props.stage}`,
|
|
131
|
+
maxDeliveryCount: props.maxDeliveryCount || 1,
|
|
60
132
|
})
|
|
61
133
|
|
|
62
134
|
createAzureTfOutput(`${id}-servicebusSubscriptionName`, scope, servicebusSubscription.name)
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { ServicebusNamespaceConfig } from '@cdktf/provider-azurerm/lib/servicebus-namespace'
|
|
1
2
|
import { ServicebusTopicConfig } from '@cdktf/provider-azurerm/lib/servicebus-topic'
|
|
3
|
+
import { ServicebusQueueConfig } from '@cdktf/provider-azurerm/lib/servicebus-queue'
|
|
2
4
|
import { ServicebusSubscriptionConfig } from '@cdktf/provider-azurerm/lib/servicebus-subscription'
|
|
3
5
|
|
|
6
|
+
export interface ServicebusNamespaceProps extends ServicebusNamespaceConfig {}
|
|
4
7
|
export interface ServicebusTopicProps extends ServicebusTopicConfig {}
|
|
8
|
+
export interface ServicebusQueueProps extends ServicebusQueueConfig {}
|
|
5
9
|
export interface ServicebusSubscriptionProps extends ServicebusSubscriptionConfig {}
|