@gradientedge/cdk-utils-azure 2.11.0 → 2.11.1

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.
@@ -26,6 +26,8 @@ export class AzureEventHandler extends AzureFunctionApp {
26
26
  super(id, props);
27
27
  this.props = props;
28
28
  this.id = id;
29
+ this.eventGridEventSubscription = {};
30
+ this.serviceBus = {};
29
31
  }
30
32
  /**
31
33
  * @summary Initialise and provision resources
@@ -48,7 +50,7 @@ export class AzureEventHandler extends AzureFunctionApp {
48
50
  * @summary Method to create the dead-letter queue storage account for EventGrid subscriptions
49
51
  */
50
52
  createEventGridSubscriptionDlqStorageAccount() {
51
- if (!this.props.eventGridSubscription.dlqStorageAccount)
53
+ if (!this.props.eventGridSubscription || !this.props.eventGridSubscription.dlqStorageAccount)
52
54
  return;
53
55
  this.eventGridEventSubscription.dlqStorageAccount = this.storageManager.createStorageAccount(`${this.id}-eventgrid-subscription-dlq-storage-account`, this, {
54
56
  ...this.props.eventGridSubscription.dlqStorageAccount,
@@ -60,7 +62,7 @@ export class AzureEventHandler extends AzureFunctionApp {
60
62
  * @summary Method to create the dead-letter queue storage container for EventGrid subscriptions
61
63
  */
62
64
  createEventGridSubscriptionDlqStorageContainer() {
63
- if (!this.eventGridEventSubscription.dlqStorageAccount)
65
+ if (!this.eventGridEventSubscription || !this.eventGridEventSubscription.dlqStorageAccount)
64
66
  return;
65
67
  this.eventGridEventSubscription.dlqStorageContainer = this.storageManager.createStorageContainer(`${this.id}-eventgrid-subscription-dlq-container`, this, {
66
68
  ...this.props.eventGridSubscription.dlqStorageContainer,
@@ -73,7 +75,7 @@ export class AzureEventHandler extends AzureFunctionApp {
73
75
  * @summary Method to create the Service Bus namespace
74
76
  */
75
77
  createServiceBusNamespace() {
76
- if (this.props.serviceBus.useExisting && this.props.serviceBus.namespace.namespaceName) {
78
+ if (this.props.serviceBus?.useExisting && this.props.serviceBus?.namespace?.namespaceName) {
77
79
  this.serviceBus.namespace = getNamespaceOutput({
78
80
  namespaceName: this.props.serviceBus.namespace.namespaceName,
79
81
  resourceGroupName: this.props.serviceBus.namespace.resourceGroupName,
@@ -81,8 +83,8 @@ export class AzureEventHandler extends AzureFunctionApp {
81
83
  }
82
84
  else {
83
85
  this.serviceBus.namespace = this.serviceBusManager.createServiceBusNamespace(this.id, this, {
84
- ...this.props.serviceBus.namespace,
85
- namespaceName: this.props.serviceBus.namespace.namespaceName ?? this.id,
86
+ ...this.props.serviceBus?.namespace,
87
+ namespaceName: this.props.serviceBus?.namespace?.namespaceName ?? this.id,
86
88
  resourceGroupName: this.resourceGroup.name,
87
89
  }, { ignoreChanges: ['location'] });
88
90
  }
@@ -94,9 +96,9 @@ export class AzureEventHandler extends AzureFunctionApp {
94
96
  * @summary Method to create the Service Bus queue
95
97
  */
96
98
  createServiceBusQueue() {
97
- if (this.props.serviceBus.useExisting &&
98
- this.props.serviceBus.namespace.namespaceName &&
99
- this.props.serviceBus.queue.queueName) {
99
+ if (this.props.serviceBus?.useExisting &&
100
+ this.props.serviceBus?.namespace?.namespaceName &&
101
+ this.props.serviceBus?.queue?.queueName) {
100
102
  this.serviceBus.queue = getQueueOutput({
101
103
  namespaceName: this.props.serviceBus.namespace.namespaceName,
102
104
  queueName: this.props.serviceBus.queue.queueName,
@@ -105,9 +107,10 @@ export class AzureEventHandler extends AzureFunctionApp {
105
107
  }
106
108
  else {
107
109
  this.serviceBus.queue = this.serviceBusManager.createServiceBusQueue(this.id, this, {
108
- ...this.props.serviceBus.queue,
109
- queueName: this.props.serviceBus.queue.queueName ?? this.id,
110
+ ...this.props.serviceBus?.queue,
111
+ queueName: this.props.serviceBus?.queue?.queueName ?? this.id,
110
112
  namespaceName: this.serviceBus.namespace.name,
113
+ resourceGroupName: this.resourceGroup.name,
111
114
  });
112
115
  }
113
116
  this.registerOutputs({
@@ -148,20 +151,20 @@ export class AzureEventHandler extends AzureFunctionApp {
148
151
  * @summary Method to create the EventGrid event subscription with Service Bus queue destination
149
152
  */
150
153
  createEventGridEventSubscription() {
151
- if (this.props.serviceBus.useExisting)
154
+ if (this.props.serviceBus?.useExisting || !this.eventGridEventSubscription.dlqStorageAccount)
152
155
  return;
153
156
  this.eventGridEventSubscription.eventSubscription = this.eventgridManager.createEventgridSubscription(this.id, this, {
154
157
  ...this.props.eventGridEventSubscription,
155
- eventSubscriptionName: this.props.eventGridEventSubscription.eventSubscriptionName ?? this.id,
158
+ eventSubscriptionName: this.props.eventGridEventSubscription?.eventSubscriptionName ?? this.id,
156
159
  scope: this.eventGridTopic.id,
157
160
  destination: {
158
161
  endpointType: 'ServiceBusQueue',
159
162
  resourceId: this.serviceBus.queue.id,
160
163
  },
161
164
  deadLetterDestination: {
162
- blobContainerName: this.eventGridEventSubscription.dlqStorageContainer.name,
165
+ blobContainerName: this.eventGridEventSubscription.dlqStorageContainer?.name,
163
166
  endpointType: 'StorageBlob',
164
- resourceId: this.eventGridEventSubscription.dlqStorageAccount.id,
167
+ resourceId: this.eventGridEventSubscription.dlqStorageAccount?.id,
165
168
  },
166
169
  }, { dependsOn: [this.eventGridTopic] });
167
170
  }
@@ -169,7 +172,7 @@ export class AzureEventHandler extends AzureFunctionApp {
169
172
  * @summary Method to create diagnostic log settings for the Service Bus namespace
170
173
  */
171
174
  createServiceBusDiagnosticLog() {
172
- if (this.props.serviceBus.useExisting)
175
+ if (this.props.serviceBus?.useExisting)
173
176
  return;
174
177
  this.monitorManager.createMonitorDiagnosticSettings(this.id, this, {
175
178
  name: `${this.id}-servicebus`,
@@ -216,7 +219,7 @@ export class AzureEventHandler extends AzureFunctionApp {
216
219
  {
217
220
  name: 'EVENT_INGEST_SERVICE_BUS',
218
221
  value: listNamespaceKeysOutput({
219
- resourceGroupName: this.props.serviceBus.namespace.resourceGroupName,
222
+ resourceGroupName: this.props.serviceBus?.namespace?.resourceGroupName ?? this.resourceGroup.name,
220
223
  namespaceName: this.serviceBus.namespace.name,
221
224
  authorizationRuleName: 'RootManageSharedAccessKey',
222
225
  }).primaryConnectionString,
@@ -17,8 +17,8 @@ export interface EventHandlerEventGridSubscription {
17
17
  }
18
18
  /** @category Interface */
19
19
  export interface EventHandlerServiceBusProps {
20
- namespace: ServiceBusNamespaceProps;
21
- queue: ServiceBusQueueProps;
20
+ namespace?: ServiceBusNamespaceProps;
21
+ queue?: ServiceBusQueueProps;
22
22
  useExisting?: boolean;
23
23
  }
24
24
  /** @category Interface */
@@ -36,8 +36,8 @@ export interface EventHandlerEventGridTopicProps extends EventgridTopicProps {
36
36
  /** @category Interface */
37
37
  export interface AzureEventHandlerProps extends AzureFunctionAppProps {
38
38
  defender?: DefenderForStorageProps;
39
- eventGridEventSubscription: EventgridEventSubscriptionProps;
39
+ eventGridEventSubscription?: EventgridEventSubscriptionProps;
40
40
  eventGridSubscription: EventHandlerEventGridSubscriptionProps;
41
41
  eventGridTopic: EventHandlerEventGridTopicProps;
42
- serviceBus: EventHandlerServiceBusProps;
42
+ serviceBus?: EventHandlerServiceBusProps;
43
43
  }
@@ -37,8 +37,8 @@ export class AzureFunctionApp extends CommonAzureConstruct {
37
37
  appConfig;
38
38
  appCodeArchiveFile;
39
39
  appConfigHash;
40
- appKeyVaultsByResourceGroup;
41
- appConnectionStrings;
40
+ appKeyVaultsByResourceGroup = {};
41
+ appConnectionStrings = [];
42
42
  appConfigPrefix;
43
43
  appConfigurationsParsedConfig;
44
44
  appConfigurationsOriginalParsedConfig;
@@ -271,7 +271,7 @@ export class AzureFunctionApp extends CommonAzureConstruct {
271
271
  createFunctionApp(resourceOptions) {
272
272
  this.app = this.functionManager.createFunctionAppFlexConsumption(`${this.id}-function-app-flex`, this, {
273
273
  ...this.props.functionApp,
274
- name: this.props.functionApp.app.name ?? this.id,
274
+ name: this.props.functionApp.app?.name ?? this.id,
275
275
  serverFarmId: this.appServicePlan.id,
276
276
  resourceGroupName: this.resourceGroup.name,
277
277
  functionAppConfig: {
@@ -307,7 +307,7 @@ export class AzureFunctionApp extends CommonAzureConstruct {
307
307
  ],
308
308
  connectionStrings: Object.fromEntries(this.appConnectionStrings.map(cs => [cs.name, { type: cs.type, value: cs.value }])),
309
309
  },
310
- httpsOnly: this.props.functionApp.app.httpsOnly ?? true,
310
+ httpsOnly: this.props.functionApp.app?.httpsOnly ?? true,
311
311
  }, { ...resourceOptions });
312
312
  }
313
313
  /**
@@ -369,7 +369,7 @@ export class AzureFunctionApp extends CommonAzureConstruct {
369
369
  resourceGroupName: this.resourceGroup.name,
370
370
  variables: this.dashboardVariables(),
371
371
  panes: this.props.functionApp.dashboard.panes,
372
- properties: this.appConfigurationsOriginalParsedConfig.appConfig,
372
+ properties: this.appConfigurationsOriginalParsedConfig?.appConfig,
373
373
  });
374
374
  }
375
375
  }
@@ -5,7 +5,7 @@ export interface OtelProps {
5
5
  }
6
6
  /** @category Interface */
7
7
  export interface FunctionAppProperties {
8
- app: FunctionAppFlexConsumptionProps;
8
+ app?: FunctionAppFlexConsumptionProps;
9
9
  appConfiguration: AppConfigurationProps;
10
10
  dashboard: PortalDashboardProps;
11
11
  deploymentStorageContainer: StorageContainerProps;
@@ -21,7 +21,7 @@ import { RoleDefinitionId } from '../../services/index.js';
21
21
  */
22
22
  export class AzureRestApi extends CommonAzureConstruct {
23
23
  props;
24
- api;
24
+ api = {};
25
25
  applicationInsights;
26
26
  constructor(id, props) {
27
27
  super(id, props);
@@ -22,11 +22,12 @@ import { AzureFunctionApp } from '../function-app/index.js';
22
22
  */
23
23
  export class AzureRestApiFunction extends AzureFunctionApp {
24
24
  props;
25
- api;
25
+ api = {};
26
26
  constructor(id, props) {
27
27
  super(id, props);
28
28
  this.props = props;
29
29
  this.id = id;
30
+ this.api.apiOperations = {};
30
31
  }
31
32
  /**
32
33
  * @summary Initialise and provision resources
@@ -60,13 +60,15 @@ export class AzureAppConfigurationManager {
60
60
  return false;
61
61
  if ('databaseName' in obj || 'tableName' in obj)
62
62
  return true;
63
- return Object.values(obj).some(val => this.hasCosmosDependencies(val));
63
+ return Object.values(obj).some(v => this.hasCosmosDependencies(v));
64
64
  };
65
65
  /**
66
66
  * @summary Determine if the config object has eventgrid target dependencies
67
67
  * @param obj the config object value
68
68
  */
69
69
  static hasEventGridTargets(obj) {
70
- return (obj && typeof obj === 'object' && ('eventGridTargets' in obj || Object.values(obj).some(this.hasEventGridTargets)));
70
+ return (obj &&
71
+ typeof obj === 'object' &&
72
+ ('eventGridTargets' in obj || Object.values(obj).some(v => this.hasEventGridTargets(v))));
71
73
  }
72
74
  }
@@ -37,7 +37,7 @@ export class AzurePortalManager {
37
37
  const dashboardRenderer = renderer ?? new AzureDashboardRenderer();
38
38
  const templateFile = dashboardRenderer.renderToFile(dashboardName, props);
39
39
  const template = fs.readFileSync(templateFile, 'utf-8');
40
- const content = Object.entries(props.variables).reduce((result, [key, value]) => result.replaceAll(`\${${key}}`, String(value)), template);
40
+ const content = Object.entries(props.variables).reduce((result, [key, value]) => result.replaceAll(`\${${key}}`, JSON.stringify(String(value)).slice(1, -1)), template);
41
41
  return new Dashboard(`${id}-dashboard`, {
42
42
  ...props,
43
43
  dashboardName: scope.resourceNameFormatter.format(props.dashboardName?.toString(), scope.props.resourceNameOptions?.portalDashboard),
@@ -19,14 +19,14 @@ export class AzureDashboardRenderer {
19
19
  return paneTemplate;
20
20
  }
21
21
  getMissingProperties(template, properties = []) {
22
- const keys = Object.keys(template.properties).filter(key => !(key in properties));
22
+ const keys = Object.keys(template.properties ?? {}).filter(key => !(key in properties));
23
23
  return {
24
24
  keys,
25
25
  hasMissingKeys: keys.length !== 0,
26
26
  };
27
27
  }
28
28
  getMissingVariables(template, variables) {
29
- const keys = Object.keys(template.variables).filter(key => !(key in variables));
29
+ const keys = Object.keys(template.variables ?? {}).filter(key => !(key in variables));
30
30
  return {
31
31
  keys,
32
32
  hasMissingKeys: keys.length !== 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils-azure",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "Azure Pulumi utilities for @gradientedge/cdk-utils",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",