@gradientedge/cdk-utils-azure 2.52.1 → 2.53.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.
|
@@ -29,6 +29,13 @@ export declare class AzureServiceBusManager {
|
|
|
29
29
|
* @see [Pulumi Azure Native Service Bus Namespace]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/service bus/namespace/}
|
|
30
30
|
*/
|
|
31
31
|
createServiceBusNamespace(id: string, scope: CommonAzureConstruct, props: ServiceBusNamespaceProps, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/servicebus/namespace.js").Namespace;
|
|
32
|
+
/**
|
|
33
|
+
* Provisions the geo-replication topology for a Service Bus namespace via an ARM
|
|
34
|
+
* deployment. The deployment PATCHes the existing namespace using the 2024-01-01
|
|
35
|
+
* Service Bus API version, which exposes the `geoDataReplication` property that is
|
|
36
|
+
* not yet surfaced by `@pulumi/azure-native`'s strongly-typed `Namespace` resource.
|
|
37
|
+
*/
|
|
38
|
+
private createServiceBusGeoReplicationDeployment;
|
|
32
39
|
/**
|
|
33
40
|
* @summary Method to create a new service bus topic
|
|
34
41
|
* @param id scoped id of the resource
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Deployment, DeploymentMode } from '@pulumi/azure-native/resources/index.js';
|
|
1
2
|
import { getQueueOutput, ManagedServiceIdentityType, Namespace, Queue, QueueAuthorizationRule, SkuName, Subscription, Topic, } from '@pulumi/azure-native/servicebus/index.js';
|
|
3
|
+
import { all, output } from '@pulumi/pulumi';
|
|
2
4
|
/**
|
|
3
5
|
* Provides operations on Azure Servicebus using Pulumi
|
|
4
6
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -29,25 +31,89 @@ export class AzureServiceBusManager {
|
|
|
29
31
|
createServiceBusNamespace(id, scope, props, resourceOptions) {
|
|
30
32
|
if (!props)
|
|
31
33
|
throw new Error(`Props undefined for ${id}`);
|
|
34
|
+
const { enableGeoReplication, geoReplication, ...namespaceProps } = props;
|
|
35
|
+
if (enableGeoReplication && !geoReplication) {
|
|
36
|
+
throw new Error(`enableGeoReplication is true but geoReplication config is missing for ${id}`);
|
|
37
|
+
}
|
|
32
38
|
// Get resource group name
|
|
33
|
-
const resourceGroupName =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
const resourceGroupName = namespaceProps.resourceGroupName ?? scope.resourceNameFormatter.format(scope.props.resourceGroupName);
|
|
40
|
+
const sku = namespaceProps.sku ?? { name: SkuName.Standard };
|
|
41
|
+
if (enableGeoReplication) {
|
|
42
|
+
// Geo-replication requires Premium. Callers pass `sku` as a literal SBSkuArgs in
|
|
43
|
+
// practice; validate synchronously so misconfiguration fails at construct time
|
|
44
|
+
// rather than during preview/up.
|
|
45
|
+
const skuName = sku.name;
|
|
46
|
+
if (skuName !== SkuName.Premium) {
|
|
47
|
+
throw new Error(`Service Bus geo-replication requires the Premium SKU, but ${id} was configured with "${String(skuName)}"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const namespace = new Namespace(`${id}-sn`, {
|
|
51
|
+
...namespaceProps,
|
|
52
|
+
namespaceName: scope.resourceNameFormatter.format(namespaceProps.namespaceName?.toString(), scope.props.resourceNameOptions?.serviceBusNamespace),
|
|
37
53
|
resourceGroupName,
|
|
38
|
-
location:
|
|
39
|
-
identity:
|
|
54
|
+
location: namespaceProps.location ?? scope.props.location,
|
|
55
|
+
identity: namespaceProps.identity ?? {
|
|
40
56
|
type: ManagedServiceIdentityType.SystemAssigned,
|
|
41
57
|
},
|
|
42
|
-
sku
|
|
43
|
-
name: SkuName.Standard,
|
|
44
|
-
},
|
|
58
|
+
sku,
|
|
45
59
|
tags: {
|
|
46
60
|
environment: scope.props.stage,
|
|
47
61
|
...scope.props.defaultTags,
|
|
48
|
-
...
|
|
62
|
+
...namespaceProps.tags,
|
|
49
63
|
},
|
|
50
64
|
}, { parent: scope, ...resourceOptions });
|
|
65
|
+
if (enableGeoReplication && geoReplication) {
|
|
66
|
+
this.createServiceBusGeoReplicationDeployment(id, scope, namespace, resourceGroupName, sku, geoReplication, resourceOptions);
|
|
67
|
+
}
|
|
68
|
+
return namespace;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Provisions the geo-replication topology for a Service Bus namespace via an ARM
|
|
72
|
+
* deployment. The deployment PATCHes the existing namespace using the 2024-01-01
|
|
73
|
+
* Service Bus API version, which exposes the `geoDataReplication` property that is
|
|
74
|
+
* not yet surfaced by `@pulumi/azure-native`'s strongly-typed `Namespace` resource.
|
|
75
|
+
*/
|
|
76
|
+
createServiceBusGeoReplicationDeployment(id, scope, namespace, resourceGroupName, sku, geoReplication, resourceOptions) {
|
|
77
|
+
const template = all([
|
|
78
|
+
namespace.name,
|
|
79
|
+
namespace.location,
|
|
80
|
+
output(sku),
|
|
81
|
+
output(geoReplication.maxReplicationLagDurationInSeconds ?? 0),
|
|
82
|
+
output(geoReplication.locations),
|
|
83
|
+
]).apply(([namespaceName, location, resolvedSku, maxLagSeconds, locations]) => ({
|
|
84
|
+
$schema: 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#',
|
|
85
|
+
contentVersion: '1.0.0.0',
|
|
86
|
+
resources: [
|
|
87
|
+
{
|
|
88
|
+
type: 'Microsoft.ServiceBus/namespaces',
|
|
89
|
+
apiVersion: '2024-01-01',
|
|
90
|
+
name: namespaceName,
|
|
91
|
+
location,
|
|
92
|
+
sku: {
|
|
93
|
+
name: resolvedSku.name,
|
|
94
|
+
tier: resolvedSku.tier ?? resolvedSku.name,
|
|
95
|
+
capacity: resolvedSku.capacity ?? 1,
|
|
96
|
+
},
|
|
97
|
+
properties: {
|
|
98
|
+
geoDataReplication: {
|
|
99
|
+
maxReplicationLagDurationInSeconds: maxLagSeconds,
|
|
100
|
+
locations: locations.map(location => ({
|
|
101
|
+
locationName: location.locationName,
|
|
102
|
+
roleType: location.roleType,
|
|
103
|
+
})),
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}));
|
|
109
|
+
return new Deployment(`${id}-sn-geo`, {
|
|
110
|
+
resourceGroupName,
|
|
111
|
+
deploymentName: scope.resourceNameFormatter.format(`${id}-sn-geo`),
|
|
112
|
+
properties: {
|
|
113
|
+
mode: DeploymentMode.Incremental,
|
|
114
|
+
template,
|
|
115
|
+
},
|
|
116
|
+
}, { ...resourceOptions, parent: namespace, dependsOn: [namespace] });
|
|
51
117
|
}
|
|
52
118
|
/**
|
|
53
119
|
* @summary Method to create a new service bus topic
|
|
@@ -1,10 +1,55 @@
|
|
|
1
1
|
import { GetQueueOutputArgs, NamespaceArgs, QueueArgs, QueueAuthorizationRuleArgs, SubscriptionArgs, TopicArgs } from '@pulumi/azure-native/servicebus/index.js';
|
|
2
|
+
import { Input } from '@pulumi/pulumi';
|
|
3
|
+
/**
|
|
4
|
+
* Role of a replica within a Service Bus geo-replication topology. Mirrors the
|
|
5
|
+
* `roleType` values accepted by the Service Bus ARM API. Declared locally because
|
|
6
|
+
* `@pulumi/azure-native` does not yet surface a strongly-typed enum for this field;
|
|
7
|
+
* swap to the upstream enum once it ships.
|
|
8
|
+
* @category Enum
|
|
9
|
+
*/
|
|
10
|
+
export declare const ServiceBusGeoReplicationRoleType: {
|
|
11
|
+
readonly Primary: "Primary";
|
|
12
|
+
readonly Secondary: "Secondary";
|
|
13
|
+
};
|
|
14
|
+
export type ServiceBusGeoReplicationRoleType = (typeof ServiceBusGeoReplicationRoleType)[keyof typeof ServiceBusGeoReplicationRoleType];
|
|
15
|
+
/**
|
|
16
|
+
* Geo-replication replica configuration for a Service Bus namespace.
|
|
17
|
+
* @category Interface
|
|
18
|
+
*/
|
|
19
|
+
export interface ServiceBusGeoReplicationLocation {
|
|
20
|
+
/** Azure region name (e.g. "westeurope"). */
|
|
21
|
+
locationName: Input<string>;
|
|
22
|
+
/** Replica role — exactly one entry must be `Primary`, the rest `Secondary`. */
|
|
23
|
+
roleType: Input<ServiceBusGeoReplicationRoleType>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Geo-replication configuration for a Service Bus namespace.
|
|
27
|
+
* Provisioned via an ARM deployment using the 2024-01-01 Service Bus API version,
|
|
28
|
+
* which is the first stable version that exposes the `geoDataReplication` block.
|
|
29
|
+
* @category Interface
|
|
30
|
+
*/
|
|
31
|
+
export interface ServiceBusGeoReplicationProps {
|
|
32
|
+
/**
|
|
33
|
+
* Replication lag tolerance in seconds. `0` means synchronous replication.
|
|
34
|
+
* Async values typically sit in the 60–1440 range.
|
|
35
|
+
*/
|
|
36
|
+
maxReplicationLagDurationInSeconds?: Input<number>;
|
|
37
|
+
/** Primary + one or more secondary regions. */
|
|
38
|
+
locations: Input<Input<ServiceBusGeoReplicationLocation>[]>;
|
|
39
|
+
}
|
|
2
40
|
/**
|
|
3
41
|
* Properties for creating a Service Bus namespace
|
|
4
42
|
* @see [Pulumi Azure Native Service Bus Namespace]{@link https://www.pulumi.com/registry/packages/azure-native/api-docs/servicebus/namespace/}
|
|
5
43
|
* @category Interface
|
|
6
44
|
*/
|
|
7
45
|
export interface ServiceBusNamespaceProps extends NamespaceArgs {
|
|
46
|
+
/**
|
|
47
|
+
* Enables Service Bus geo-replication. Requires the namespace SKU to be `Premium`.
|
|
48
|
+
* When `true`, {@link geoReplication} must be supplied.
|
|
49
|
+
*/
|
|
50
|
+
enableGeoReplication?: boolean;
|
|
51
|
+
/** Geo-replication topology. Only consumed when {@link enableGeoReplication} is `true`. */
|
|
52
|
+
geoReplication?: ServiceBusGeoReplicationProps;
|
|
8
53
|
}
|
|
9
54
|
/**
|
|
10
55
|
* Properties for creating a Service Bus topic
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Role of a replica within a Service Bus geo-replication topology. Mirrors the
|
|
3
|
+
* `roleType` values accepted by the Service Bus ARM API. Declared locally because
|
|
4
|
+
* `@pulumi/azure-native` does not yet surface a strongly-typed enum for this field;
|
|
5
|
+
* swap to the upstream enum once it ships.
|
|
6
|
+
* @category Enum
|
|
7
|
+
*/
|
|
8
|
+
export const ServiceBusGeoReplicationRoleType = {
|
|
9
|
+
Primary: 'Primary',
|
|
10
|
+
Secondary: 'Secondary',
|
|
11
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils-azure",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.53.0",
|
|
4
4
|
"description": "Azure Pulumi utilities for @gradientedge/cdk-utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@pulumi/archive": "0.5.0",
|
|
18
18
|
"@pulumi/azure-native": "3.19.0",
|
|
19
19
|
"@pulumi/azuread": "6.9.1",
|
|
20
|
-
"@pulumi/pulumi": "3.
|
|
20
|
+
"@pulumi/pulumi": "3.245.0",
|
|
21
21
|
"@types/lodash": "4.17.24",
|
|
22
22
|
"app-root-path": "3.1.0",
|
|
23
23
|
"lodash": "4.18.1",
|