@gradientedge/cdk-utils-azure 2.7.0 → 2.8.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.
@@ -59,4 +59,5 @@ export declare class AzureEventHandler extends AzureFunctionApp {
59
59
  * @summary Method to enable Microsoft Defender malware scanning on the data storage account
60
60
  */
61
61
  protected enableMalwareScanningOnDataStorageAccount(): void;
62
+ protected createFunctionAppSiteConfig(): void;
62
63
  }
@@ -1,5 +1,6 @@
1
1
  import { Provider } from '@pulumi/azure-native';
2
2
  import { getTopicOutput } from '@pulumi/azure-native/eventgrid/index.js';
3
+ import { getNamespaceOutput, getQueueOutput, listNamespaceKeysOutput } from '@pulumi/azure-native/servicebus/index.js';
3
4
  import { AzureFunctionApp } from '../function-app/index.js';
4
5
  /**
5
6
  * Provides a construct to create and deploy an Azure EventGrid Event Handler with Service Bus integration
@@ -47,6 +48,8 @@ export class AzureEventHandler extends AzureFunctionApp {
47
48
  * @summary Method to create the dead-letter queue storage account for EventGrid subscriptions
48
49
  */
49
50
  createEventGridSubscriptionDlqStorageAccount() {
51
+ if (this.props.serviceBus.useExisting)
52
+ return;
50
53
  this.eventGridEventSubscription.dlqStorageAccount = this.storageManager.createStorageAccount(`${this.id}-eventgrid-subscription-dlq-storage-account`, this, {
51
54
  ...this.props.eventGridSubscription.dlqStorageAccount,
52
55
  resourceGroupName: this.resourceGroup.name,
@@ -57,6 +60,8 @@ export class AzureEventHandler extends AzureFunctionApp {
57
60
  * @summary Method to create the dead-letter queue storage container for EventGrid subscriptions
58
61
  */
59
62
  createEventGridSubscriptionDlqStorageContainer() {
63
+ if (this.props.serviceBus.useExisting)
64
+ return;
60
65
  this.eventGridEventSubscription.dlqStorageContainer = this.storageManager.createStorageContainer(`${this.id}-eventgrid-subscription-dlq-container`, this, {
61
66
  ...this.props.eventGridSubscription.dlqStorageContainer,
62
67
  accountName: this.eventGridEventSubscription.dlqStorageAccount.name,
@@ -68,11 +73,19 @@ export class AzureEventHandler extends AzureFunctionApp {
68
73
  * @summary Method to create the Service Bus namespace
69
74
  */
70
75
  createServiceBusNamespace() {
71
- this.serviceBus.namespace = this.serviceBusManager.createServiceBusNamespace(this.id, this, {
72
- ...this.props.serviceBus.namespace,
73
- namespaceName: this.props.serviceBus.namespace.namespaceName ?? this.id,
74
- resourceGroupName: this.resourceGroup.name,
75
- }, { ignoreChanges: ['location'] });
76
+ if (this.props.serviceBus.useExisting && this.props.serviceBus.namespace.namespaceName) {
77
+ this.serviceBus.namespace = getNamespaceOutput({
78
+ namespaceName: this.props.serviceBus.namespace.namespaceName,
79
+ resourceGroupName: this.props.serviceBus.namespace.resourceGroupName,
80
+ });
81
+ }
82
+ else {
83
+ this.serviceBus.namespace = this.serviceBusManager.createServiceBusNamespace(this.id, this, {
84
+ ...this.props.serviceBus.namespace,
85
+ namespaceName: this.props.serviceBus.namespace.namespaceName ?? this.id,
86
+ resourceGroupName: this.resourceGroup.name,
87
+ }, { ignoreChanges: ['location'] });
88
+ }
76
89
  this.registerOutputs({
77
90
  serviceBusNamespaceId: this.serviceBus.namespace.id,
78
91
  });
@@ -81,11 +94,22 @@ export class AzureEventHandler extends AzureFunctionApp {
81
94
  * @summary Method to create the Service Bus queue
82
95
  */
83
96
  createServiceBusQueue() {
84
- this.serviceBus.queue = this.serviceBusManager.createServiceBusQueue(this.id, this, {
85
- ...this.props.serviceBus.queue,
86
- queueName: this.props.serviceBus.queue.queueName ?? this.id,
87
- namespaceName: this.serviceBus.namespace.name,
88
- });
97
+ if (this.props.serviceBus.useExisting &&
98
+ this.props.serviceBus.namespace.namespaceName &&
99
+ this.props.serviceBus.queue.queueName) {
100
+ this.serviceBus.queue = getQueueOutput({
101
+ namespaceName: this.props.serviceBus.namespace.namespaceName,
102
+ queueName: this.props.serviceBus.queue.queueName,
103
+ resourceGroupName: this.props.serviceBus.namespace.resourceGroupName,
104
+ });
105
+ }
106
+ else {
107
+ this.serviceBus.queue = this.serviceBusManager.createServiceBusQueue(this.id, this, {
108
+ ...this.props.serviceBus.queue,
109
+ queueName: this.props.serviceBus.queue.queueName ?? this.id,
110
+ namespaceName: this.serviceBus.namespace.name,
111
+ });
112
+ }
89
113
  this.registerOutputs({
90
114
  serviceBusQueueId: this.serviceBus.queue.id,
91
115
  serviceBusQueueName: this.serviceBus.queue.name,
@@ -124,6 +148,8 @@ export class AzureEventHandler extends AzureFunctionApp {
124
148
  * @summary Method to create the EventGrid event subscription with Service Bus queue destination
125
149
  */
126
150
  createEventGridEventSubscription() {
151
+ if (this.props.serviceBus.useExisting)
152
+ return;
127
153
  this.eventGridEventSubscription.eventSubscription = this.eventgridManager.createEventgridSubscription(this.id, this, {
128
154
  ...this.props.eventGridEventSubscription,
129
155
  eventSubscriptionName: this.props.eventGridEventSubscription.eventSubscriptionName ?? this.id,
@@ -143,6 +169,8 @@ export class AzureEventHandler extends AzureFunctionApp {
143
169
  * @summary Method to create diagnostic log settings for the Service Bus namespace
144
170
  */
145
171
  createServiceBusDiagnosticLog() {
172
+ if (this.props.serviceBus.useExisting)
173
+ return;
146
174
  this.monitorManager.createMonitorDiagnosticSettings(this.id, this, {
147
175
  name: `${this.id}-servicebus`,
148
176
  resourceUri: this.serviceBus.namespace.id,
@@ -178,4 +206,22 @@ export class AzureEventHandler extends AzureFunctionApp {
178
206
  },
179
207
  });
180
208
  }
209
+ createFunctionAppSiteConfig() {
210
+ super.createFunctionAppSiteConfig();
211
+ this.appEnvironmentVariables = {
212
+ ...this.appEnvironmentVariables,
213
+ EVENT_INGEST_QUEUE_NAME: this.serviceBus.queue.name,
214
+ };
215
+ this.appConnectionStrings = [
216
+ {
217
+ name: 'EVENT_INGEST_SERVICE_BUS',
218
+ value: listNamespaceKeysOutput({
219
+ resourceGroupName: this.props.serviceBus.namespace.resourceGroupName,
220
+ namespaceName: this.serviceBus.namespace.name,
221
+ authorizationRuleName: 'RootManageSharedAccessKey',
222
+ }).primaryConnectionString,
223
+ type: 'ServiceBus',
224
+ },
225
+ ];
226
+ }
181
227
  }
@@ -1,7 +1,7 @@
1
1
  import { EventSubscription } from '@pulumi/azure-native/eventgrid/index.js';
2
- import { Namespace, Queue } from '@pulumi/azure-native/servicebus/index.js';
2
+ import { GetNamespaceResult, GetQueueResult, Namespace, Queue } from '@pulumi/azure-native/servicebus/index.js';
3
3
  import { BlobContainer, StorageAccount } from '@pulumi/azure-native/storage/index.js';
4
- import { Input } from '@pulumi/pulumi';
4
+ import { Input, Output } from '@pulumi/pulumi';
5
5
  import { DefenderForStorageProps, EventgridEventSubscriptionProps, EventgridTopicProps, ServiceBusNamespaceProps, ServiceBusQueueProps, StorageAccountProps, StorageContainerProps } from '../../services/index.js';
6
6
  import { AzureFunctionAppProps } from '../function-app/index.js';
7
7
  /** @category Interface */
@@ -19,11 +19,12 @@ export interface EventHandlerEventGridSubscription {
19
19
  export interface EventHandlerServiceBusProps {
20
20
  namespace: ServiceBusNamespaceProps;
21
21
  queue: ServiceBusQueueProps;
22
+ useExisting?: boolean;
22
23
  }
23
24
  /** @category Interface */
24
25
  export interface EventHandlerServiceBus {
25
- namespace: Namespace;
26
- queue: Queue;
26
+ namespace: Namespace | Output<GetNamespaceResult>;
27
+ queue: Queue | Output<GetQueueResult>;
27
28
  }
28
29
  /** @category Interface */
29
30
  export interface EventHandlerEventGridTopicProps extends EventgridTopicProps {
@@ -51,7 +51,7 @@ export declare class AzureAuthorisationManager {
51
51
  * @param roleDefinitionId the role definition id
52
52
  * @param resourceOptions Optional settings to control resource behaviour
53
53
  */
54
- grantRoleAssignmentToEventgridTopic(id: string, scope: CommonAzureConstruct, topicName: string, resourceGroupName: Input<string>, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
54
+ grantRoleAssignmentToEventgridTopic(id: string, scope: CommonAzureConstruct, topicName: Input<string>, resourceGroupName: Input<string>, principalId: Input<string>, roleDefinitionId: RoleDefinitionId, resourceOptions?: ResourceOptions): import("@pulumi/azure-native/authorization/roleAssignment.js").RoleAssignment;
55
55
  /**
56
56
  * @summary Method to grant a role assignment to application configuration
57
57
  * @param id scoped id of the resource
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils-azure",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Azure Pulumi utilities for @gradientedge/cdk-utils",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "@pulumi/archive": "0.3.7",
18
18
  "@pulumi/azure-native": "3.16.0",
19
- "@pulumi/pulumi": "3.229.0",
19
+ "@pulumi/pulumi": "3.230.0",
20
20
  "@types/lodash": "4.17.24",
21
21
  "app-root-path": "3.1.0",
22
22
  "lodash": "4.18.1",