@gradientedge/cdk-utils 9.49.0 → 9.51.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.
Files changed (41) hide show
  1. package/dist/src/lib/azure/common/construct.d.ts +2 -1
  2. package/dist/src/lib/azure/common/construct.js +2 -0
  3. package/dist/src/lib/azure/services/api-management/main.js +6 -5
  4. package/dist/src/lib/azure/services/app-configuration/main.js +3 -0
  5. package/dist/src/lib/azure/services/app-service/main.js +1 -1
  6. package/dist/src/lib/azure/services/application-insights/main.js +1 -1
  7. package/dist/src/lib/azure/services/cosmosdb/main.js +1 -1
  8. package/dist/src/lib/azure/services/dns/main.js +3 -3
  9. package/dist/src/lib/azure/services/eventgrid/main.js +2 -2
  10. package/dist/src/lib/azure/services/function/main.d.ts +2 -2
  11. package/dist/src/lib/azure/services/function/main.js +20 -55
  12. package/dist/src/lib/azure/services/function/types.d.ts +3 -21
  13. package/dist/src/lib/azure/services/index.d.ts +1 -0
  14. package/dist/src/lib/azure/services/index.js +1 -0
  15. package/dist/src/lib/azure/services/key-vault/main.js +1 -1
  16. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +2 -0
  17. package/dist/src/lib/azure/services/monitor/index.d.ts +2 -0
  18. package/dist/src/lib/azure/services/monitor/index.js +18 -0
  19. package/dist/src/lib/azure/services/monitor/main.d.ts +30 -0
  20. package/dist/src/lib/azure/services/monitor/main.js +44 -0
  21. package/dist/src/lib/azure/services/monitor/types.d.ts +3 -0
  22. package/dist/src/lib/azure/services/monitor/types.js +2 -0
  23. package/dist/src/lib/azure/services/servicebus/main.js +3 -3
  24. package/package.json +1 -1
  25. package/src/lib/azure/common/construct.ts +3 -0
  26. package/src/lib/azure/services/api-management/main.ts +7 -5
  27. package/src/lib/azure/services/app-configuration/main.ts +3 -0
  28. package/src/lib/azure/services/app-service/main.ts +1 -1
  29. package/src/lib/azure/services/application-insights/main.ts +1 -1
  30. package/src/lib/azure/services/cosmosdb/main.ts +1 -1
  31. package/src/lib/azure/services/dns/main.ts +3 -3
  32. package/src/lib/azure/services/eventgrid/main.ts +2 -2
  33. package/src/lib/azure/services/function/main.ts +20 -62
  34. package/src/lib/azure/services/function/types.ts +3 -22
  35. package/src/lib/azure/services/index.ts +1 -0
  36. package/src/lib/azure/services/key-vault/main.ts +1 -1
  37. package/src/lib/azure/services/log-analytics-workspace/main.ts +2 -0
  38. package/src/lib/azure/services/monitor/index.ts +2 -0
  39. package/src/lib/azure/services/monitor/main.ts +53 -0
  40. package/src/lib/azure/services/monitor/types.ts +3 -0
  41. package/src/lib/azure/services/servicebus/main.ts +3 -3
@@ -1,6 +1,6 @@
1
1
  import { TerraformStack } from 'cdktf';
2
2
  import { Construct } from 'constructs';
3
- import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager, AzureCosmosDbManager, AzureServicebusManager, AzureEventgridManager, AzureDnsManager, AzureLogAnalyticsWorkspaceManager } from '../services';
3
+ import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager, AzureCosmosDbManager, AzureServicebusManager, AzureEventgridManager, AzureDnsManager, AzureLogAnalyticsWorkspaceManager, AzureMonitorManager } from '../services';
4
4
  import { CommonAzureStackProps } from './types';
5
5
  import { AzureResourceNameFormatter } from './resource-name-formatter';
6
6
  export declare class CommonAzureConstruct extends TerraformStack {
@@ -17,6 +17,7 @@ export declare class CommonAzureConstruct extends TerraformStack {
17
17
  id: string;
18
18
  keyVaultManager: AzureKeyVaultManager;
19
19
  logAnalyticsWorkspaceManager: AzureLogAnalyticsWorkspaceManager;
20
+ monitorManager: AzureMonitorManager;
20
21
  resourceGroupManager: AzureResourceGroupManager;
21
22
  resourceNameFormatter: AzureResourceNameFormatter;
22
23
  servicebusManager: AzureServicebusManager;
@@ -22,6 +22,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
22
22
  id;
23
23
  keyVaultManager;
24
24
  logAnalyticsWorkspaceManager;
25
+ monitorManager;
25
26
  resourceGroupManager;
26
27
  resourceNameFormatter;
27
28
  servicebusManager;
@@ -41,6 +42,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
41
42
  this.functiontManager = new services_1.AzureFunctionManager();
42
43
  this.keyVaultManager = new services_1.AzureKeyVaultManager();
43
44
  this.logAnalyticsWorkspaceManager = new services_1.AzureLogAnalyticsWorkspaceManager();
45
+ this.monitorManager = new services_1.AzureMonitorManager();
44
46
  this.resourceGroupManager = new services_1.AzureResourceGroupManager();
45
47
  this.resourceNameFormatter = new resource_name_formatter_1.AzureResourceNameFormatter(this, `${id}-rnf`, props);
46
48
  this.servicebusManager = new services_1.AzureServicebusManager();
@@ -144,6 +144,7 @@ class AzureApiManagementManager {
144
144
  ignoreMissingProperty: true,
145
145
  ignoreCasing: true,
146
146
  schemaValidationEnabled: false,
147
+ lifecycle: props.lifecycle,
147
148
  });
148
149
  if (applicationInsightsKey) {
149
150
  new api_management_logger_1.ApiManagementLogger(scope, `${id}-am-logger`, {
@@ -173,8 +174,8 @@ class AzureApiManagementManager {
173
174
  const apiManagementBackend = new api_management_backend_1.ApiManagementBackend(scope, `${id}-am-be`, {
174
175
  ...props,
175
176
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
176
- description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
177
- protocol: props.protocol || 'http',
177
+ description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
178
+ protocol: props.protocol ?? 'http',
178
179
  });
179
180
  (0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name);
180
181
  (0, utils_1.createAzureTfOutput)(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId);
@@ -194,9 +195,9 @@ class AzureApiManagementManager {
194
195
  const apiManagementApi = new api_management_api_1.ApiManagementApi(scope, `${id}-am-api`, {
195
196
  ...props,
196
197
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementApi),
197
- displayName: props.displayName || props.name,
198
- revision: props.revision || '1',
199
- protocols: props.protocols || ['https'],
198
+ displayName: props.displayName ?? props.name,
199
+ revision: props.revision ?? '1',
200
+ protocols: props.protocols ?? ['https'],
200
201
  });
201
202
  (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiName`, scope, apiManagementApi.name);
202
203
  (0, utils_1.createAzureTfOutput)(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId);
@@ -43,6 +43,9 @@ class AzureAppConfigurationManager {
43
43
  ...props,
44
44
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appConfiguration),
45
45
  resourceGroupName: resourceGroup.name,
46
+ identity: {
47
+ type: 'SystemAssigned',
48
+ },
46
49
  tags: props.tags ?? {
47
50
  environment: scope.props.stage,
48
51
  },
@@ -75,7 +75,7 @@ class AzureAppServiceManager {
75
75
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.linuxWebApp),
76
76
  resourceGroupName: resourceGroup.name,
77
77
  httpsOnly: props.httpsOnly ?? true,
78
- identity: props.identity || {
78
+ identity: props.identity ?? {
79
79
  type: 'SystemAssigned',
80
80
  },
81
81
  siteConfig: {
@@ -43,7 +43,7 @@ class AzureApplicationInsightsManager {
43
43
  ...props,
44
44
  name: scope.resourceNameFormatter.format(props.name ?? '', scope.props.resourceNameOptions?.applicationInsights),
45
45
  resourceGroupName: resourceGroup.name,
46
- applicationType: props.applicationType || 'web',
46
+ applicationType: props.applicationType ?? 'web',
47
47
  tags: props.tags ?? {
48
48
  environment: scope.props.stage,
49
49
  },
@@ -49,7 +49,7 @@ class AzureCosmosDbManager {
49
49
  tags: props.tags ?? {
50
50
  environment: scope.props.stage,
51
51
  },
52
- identity: props.identity || {
52
+ identity: props.identity ?? {
53
53
  type: 'SystemAssigned',
54
54
  },
55
55
  });
@@ -67,7 +67,7 @@ class AzureDnsManager {
67
67
  throw `Props undefined for ${id}`;
68
68
  const dnsARecord = new dns_a_record_1.DnsARecord(scope, `${id}-da`, {
69
69
  ...props,
70
- ttl: props.ttl || 300,
70
+ ttl: props.ttl ?? 300,
71
71
  tags: props.tags ?? {
72
72
  environment: scope.props.stage,
73
73
  },
@@ -89,7 +89,7 @@ class AzureDnsManager {
89
89
  throw `Props undefined for ${id}`;
90
90
  const dnsCnameRecord = new dns_cname_record_1.DnsCnameRecord(scope, `${id}-dc`, {
91
91
  ...props,
92
- ttl: props.ttl || 300,
92
+ ttl: props.ttl ?? 300,
93
93
  tags: props.tags ?? {
94
94
  environment: scope.props.stage,
95
95
  },
@@ -111,7 +111,7 @@ class AzureDnsManager {
111
111
  throw `Props undefined for ${id}`;
112
112
  const dnsTxtRecord = new dns_txt_record_1.DnsTxtRecord(scope, `${id}-dc`, {
113
113
  ...props,
114
- ttl: props.ttl || 300,
114
+ ttl: props.ttl ?? 300,
115
115
  tags: props.tags ?? {
116
116
  environment: scope.props.stage,
117
117
  },
@@ -97,8 +97,8 @@ class AzureEventgridManager {
97
97
  const eventgridSubscription = new eventgrid_event_subscription_1.EventgridEventSubscription(scope, `${id}-es`, {
98
98
  ...props,
99
99
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.eventGridEventSubscription),
100
- eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
101
- advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
100
+ eventDeliverySchema: props.eventDeliverySchema ?? 'CloudEventSchemaV1_0',
101
+ advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled ?? true,
102
102
  });
103
103
  (0, utils_1.createAzureTfOutput)(`${id}-eventgridSubscriptiontName`, scope, eventgridSubscription.name);
104
104
  (0, utils_1.createAzureTfOutput)(`${id}-eventgridSubscriptionFriendlyUniqueId`, scope, eventgridSubscription.friendlyUniqueId);
@@ -1,6 +1,6 @@
1
1
  import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app';
2
2
  import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function';
3
- import { Resource } from '../../.gen/providers/azapi/resource';
3
+ import { FunctionAppFlexConsumption } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption';
4
4
  import { CommonAzureConstruct } from '../../common';
5
5
  import { FunctionAppProps, FunctionProps, FunctionAppFlexConsumptionProps } from './types';
6
6
  /**
@@ -43,5 +43,5 @@ export declare class AzureFunctionManager {
43
43
  * @param scope scope in which this resource is defined
44
44
  * @param props flex consumption function app properties
45
45
  */
46
- createFunctionAppFlexConsumption(id: string, scope: CommonAzureConstruct, props: FunctionAppFlexConsumptionProps): Resource;
46
+ createFunctionAppFlexConsumption(id: string, scope: CommonAzureConstruct, props: FunctionAppFlexConsumptionProps): FunctionAppFlexConsumption;
47
47
  }
@@ -4,7 +4,7 @@ exports.AzureFunctionManager = void 0;
4
4
  const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
5
  const linux_function_app_1 = require("@cdktf/provider-azurerm/lib/linux-function-app");
6
6
  const function_app_function_1 = require("@cdktf/provider-azurerm/lib/function-app-function");
7
- const resource_1 = require("../../.gen/providers/azapi/resource");
7
+ const function_app_flex_consumption_1 = require("@cdktf/provider-azurerm/lib/function-app-flex-consumption");
8
8
  const cdktf_local_exec_1 = require("cdktf-local-exec");
9
9
  const utils_1 = require("../../utils");
10
10
  /**
@@ -68,7 +68,7 @@ class AzureFunctionManager {
68
68
  const functionAppFunction = new function_app_function_1.FunctionAppFunction(scope, `${id}-fc`, {
69
69
  ...props,
70
70
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionAppFunction),
71
- configJson: JSON.stringify(props.configJson || {}),
71
+ configJson: JSON.stringify(props.configJson ?? {}),
72
72
  });
73
73
  (0, utils_1.createAzureTfOutput)(`${id}-functionName`, scope, functionAppFunction.name);
74
74
  (0, utils_1.createAzureTfOutput)(`${id}-functionFriendlyUniqueId`, scope, functionAppFunction.friendlyUniqueId);
@@ -91,62 +91,27 @@ class AzureFunctionManager {
91
91
  });
92
92
  if (!resourceGroup)
93
93
  throw `Resource group undefined for ${id}`;
94
- const functionApp = new resource_1.Resource(scope, `${id}-fa`, {
95
- type: 'Microsoft.Web/sites@2024-04-01',
94
+ const functionApp = new function_app_flex_consumption_1.FunctionAppFlexConsumption(scope, `${id}-fc`, {
95
+ ...props,
96
96
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionApp),
97
97
  location: resourceGroup.location,
98
- parentId: resourceGroup.id,
99
- body: {
100
- kind: props.kind || 'functionapp,linux',
101
- properties: {
102
- serverFarmId: props.appServicePlanId,
103
- httpsOnly: props.httpsOnly || true,
104
- functionAppConfig: {
105
- deployment: {
106
- storage: {
107
- type: props.deploymentStorageType || 'blobContainer',
108
- value: `${props.blobEndpoint}${props.containerName}`,
109
- authentication: {
110
- type: props.deploymentAuthenticationType || 'StorageAccountConnectionString',
111
- storageAccountConnectionStringName: props.storageAccountConnectionStringName || 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
112
- },
113
- },
114
- },
115
- runtime: {
116
- name: props.runtime || 'node',
117
- version: props.runtimeVersion || '20',
118
- },
119
- scaleAndConcurrency: {
120
- alwaysReady: props.alwaysReady,
121
- instanceMemoryMB: props.instanceMemory || 2048,
122
- maximumInstanceCount: props.maximumInstanceCount || 40,
123
- triggers: {},
124
- },
125
- },
126
- siteConfig: {
127
- appSettings: props.appSettings.concat([
128
- {
129
- name: 'FUNCTIONS_EXTENSION_VERSION',
130
- value: '~4',
131
- },
132
- {
133
- name: 'AzureWebJobsStorage',
134
- value: props.storageConnectionString,
135
- },
136
- {
137
- name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
138
- value: props.storageConnectionString,
139
- },
140
- ]),
141
- connectionStrings: props.connectionStrings,
142
- minTlsVersion: props.minTlsVersion ?? '1.3',
143
- },
144
- },
98
+ resourceGroupName: resourceGroup.name,
99
+ runtimeName: props.runtimeName ?? 'node',
100
+ runtimeVersion: props.runtimeVersion ?? '20',
101
+ storageAuthenticationType: props.storageAuthenticationType ?? 'StorageAccountConnectionString',
102
+ storageContainerType: props.storageContainerType ?? 'blobContainer',
103
+ maximumInstanceCount: props.maximumInstanceCount ?? 40,
104
+ instanceMemoryInMb: props.instanceMemoryInMb ?? 2048,
105
+ siteConfig: {
106
+ http2Enabled: props.siteConfig.http2Enabled ?? true,
107
+ ...props.siteConfig,
108
+ },
109
+ identity: props.identity ?? {
110
+ type: 'SystemAssigned',
111
+ },
112
+ tags: props.tags ?? {
113
+ environment: scope.props.stage,
145
114
  },
146
- identity: [{ type: 'SystemAssigned' }],
147
- ignoreMissingProperty: true,
148
- ignoreCasing: true,
149
- schemaValidationEnabled: false,
150
115
  });
151
116
  new cdktf_local_exec_1.Provider(scope, `${id}-local-exec-provider`);
152
117
  new cdktf_local_exec_1.LocalExec(scope, `${id}-function-app-deploy`, {
@@ -1,29 +1,11 @@
1
1
  import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app';
2
2
  import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function';
3
+ import { FunctionAppFlexConsumptionConfig } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption';
3
4
  export interface FunctionAppProps extends LinuxFunctionAppConfig {
4
5
  }
5
6
  export interface FunctionProps extends FunctionAppFunctionConfig {
6
7
  }
7
- export interface FunctionAppFlexConsumptionProps {
8
- alwaysReady?: any;
9
- appServicePlanId: string;
10
- appSettings: any;
11
- blobEndpoint: string;
12
- connectionStrings: any;
13
- containerName: string;
14
- deploymentAuthenticationType?: string;
15
- deploymentStorageType?: string;
16
- deploySource: string;
17
- httpsOnly?: string;
18
- instanceMemory?: number;
19
- kind?: string;
20
- maximumInstanceCount?: number;
21
- name: string;
22
- resourceGroupName: string;
23
- runtime?: string;
24
- runtimeVersion?: string;
25
- storageAccountConnectionStringName?: string;
26
- storageConnectionString: string;
8
+ export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
27
9
  sourceCodeHash: string;
28
- minTlsVersion?: string;
10
+ deploySource: string;
29
11
  }
@@ -8,6 +8,7 @@ export * from './eventgrid';
8
8
  export * from './function';
9
9
  export * from './key-vault';
10
10
  export * from './log-analytics-workspace';
11
+ export * from './monitor';
11
12
  export * from './resource-group';
12
13
  export * from './servicebus';
13
14
  export * from './storage';
@@ -24,6 +24,7 @@ __exportStar(require("./eventgrid"), exports);
24
24
  __exportStar(require("./function"), exports);
25
25
  __exportStar(require("./key-vault"), exports);
26
26
  __exportStar(require("./log-analytics-workspace"), exports);
27
+ __exportStar(require("./monitor"), exports);
27
28
  __exportStar(require("./resource-group"), exports);
28
29
  __exportStar(require("./servicebus"), exports);
29
30
  __exportStar(require("./storage"), exports);
@@ -44,7 +44,7 @@ class AzureKeyVaultManager {
44
44
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.keyVault),
45
45
  location: resourceGroup.location,
46
46
  resourceGroupName: resourceGroup.name,
47
- skuName: props.skuName || 'standard',
47
+ skuName: props.skuName ?? 'standard',
48
48
  enableRbacAuthorization: props.enableRbacAuthorization ?? true,
49
49
  softDeleteRetentionDays: props.softDeleteRetentionDays ?? 90,
50
50
  purgeProtectionEnabled: props.purgeProtectionEnabled ?? true,
@@ -44,6 +44,8 @@ class AzureLogAnalyticsWorkspaceManager {
44
44
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.logAnalyticsWorkspace),
45
45
  location: resourceGroup.location,
46
46
  resourceGroupName: resourceGroup.name,
47
+ sku: props.sku ?? 'PerGB2018',
48
+ retentionInDays: props.retentionInDays ?? 30,
47
49
  tags: props.tags ?? {
48
50
  environment: scope.props.stage,
49
51
  },
@@ -0,0 +1,2 @@
1
+ export * from './main';
2
+ export * from './types';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./main"), exports);
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,30 @@
1
+ import { MonitorDiagnosticSetting } from '@cdktf/provider-azurerm/lib/monitor-diagnostic-setting';
2
+ import { CommonAzureConstruct } from '../../common';
3
+ import { MonitorDiagnosticSettingProps } from './types';
4
+ /**
5
+ * @classdesc Provides operations on Azure Key Vault
6
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
7
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
8
+ * @example
9
+ * ```
10
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
11
+ *
12
+ * class CustomConstruct extends CommonAzureConstruct {
13
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
14
+ * super(parent, id, props)
15
+ * this.props = props
16
+ * this.monitorManager.createMonitor('MyMonitor', this, props)
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export declare class AzureMonitorManager {
22
+ /**
23
+ * @summary Method to create a new monitor diagnostic setting
24
+ * @param id scoped id of the resource
25
+ * @param scope scope in which this resource is defined
26
+ * @param props monitor diagnostics settings properties
27
+ * @see [CDKTF Monitor Diagnostics Settings Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/monitorDiagnosticSetting.typescript.md}
28
+ */
29
+ createMonitorDiagnosticSettings(id: string, scope: CommonAzureConstruct, props: MonitorDiagnosticSettingProps): MonitorDiagnosticSetting;
30
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AzureMonitorManager = void 0;
4
+ const monitor_diagnostic_setting_1 = require("@cdktf/provider-azurerm/lib/monitor-diagnostic-setting");
5
+ const utils_1 = require("../../utils");
6
+ /**
7
+ * @classdesc Provides operations on Azure Key Vault
8
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
9
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
10
+ * @example
11
+ * ```
12
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomConstruct extends CommonAzureConstruct {
15
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
16
+ * super(parent, id, props)
17
+ * this.props = props
18
+ * this.monitorManager.createMonitor('MyMonitor', this, props)
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ class AzureMonitorManager {
24
+ /**
25
+ * @summary Method to create a new monitor diagnostic setting
26
+ * @param id scoped id of the resource
27
+ * @param scope scope in which this resource is defined
28
+ * @param props monitor diagnostics settings properties
29
+ * @see [CDKTF Monitor Diagnostics Settings Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/monitorDiagnosticSetting.typescript.md}
30
+ */
31
+ createMonitorDiagnosticSettings(id, scope, props) {
32
+ if (!props)
33
+ throw `Props undefined for ${id}`;
34
+ const monitorDiagnosticSetting = new monitor_diagnostic_setting_1.MonitorDiagnosticSetting(scope, `${id}-ds`, {
35
+ ...props,
36
+ name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.monitorDiagnosticSetting),
37
+ });
38
+ (0, utils_1.createAzureTfOutput)(`${id}-monitorDiagnosticSettingName`, scope, monitorDiagnosticSetting.name);
39
+ (0, utils_1.createAzureTfOutput)(`${id}-monitorDiagnosticSettingFriendlyUniqueId`, scope, monitorDiagnosticSetting.friendlyUniqueId);
40
+ (0, utils_1.createAzureTfOutput)(`${id}-monitorDiagnosticSettingId`, scope, monitorDiagnosticSetting.id);
41
+ return monitorDiagnosticSetting;
42
+ }
43
+ }
44
+ exports.AzureMonitorManager = AzureMonitorManager;
@@ -0,0 +1,3 @@
1
+ import { MonitorDiagnosticSettingConfig } from '@cdktf/provider-azurerm/lib/monitor-diagnostic-setting';
2
+ export interface MonitorDiagnosticSettingProps extends MonitorDiagnosticSettingConfig {
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -48,9 +48,9 @@ class AzureServicebusManager {
48
48
  resourceGroupName: resourceGroup.name,
49
49
  location: resourceGroup.location,
50
50
  identity: {
51
- type: props.identity?.type || 'SystemAssigned',
51
+ type: props.identity?.type ?? 'SystemAssigned',
52
52
  },
53
- sku: props.sku || 'Standard',
53
+ sku: props.sku ?? 'Standard',
54
54
  tags: props.tags ?? {
55
55
  environment: scope.props.stage,
56
56
  },
@@ -113,7 +113,7 @@ class AzureServicebusManager {
113
113
  const servicebusSubscription = new servicebus_subscription_1.ServicebusSubscription(scope, `${id}-ss`, {
114
114
  ...props,
115
115
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.serviceBusSubscription),
116
- maxDeliveryCount: props.maxDeliveryCount || 1,
116
+ maxDeliveryCount: props.maxDeliveryCount ?? 1,
117
117
  });
118
118
  (0, utils_1.createAzureTfOutput)(`${id}-servicebusSubscriptionName`, scope, servicebusSubscription.name);
119
119
  (0, utils_1.createAzureTfOutput)(`${id}-servicebusSubscriptionFriendlyUniqueId`, scope, servicebusSubscription.friendlyUniqueId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.49.0",
3
+ "version": "9.51.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -18,6 +18,7 @@ import {
18
18
  AzureEventgridManager,
19
19
  AzureDnsManager,
20
20
  AzureLogAnalyticsWorkspaceManager,
21
+ AzureMonitorManager,
21
22
  } from '../services'
22
23
  import { CommonAzureStackProps } from './types'
23
24
  import { AzureRemoteBackend } from './constants'
@@ -37,6 +38,7 @@ export class CommonAzureConstruct extends TerraformStack {
37
38
  id: string
38
39
  keyVaultManager: AzureKeyVaultManager
39
40
  logAnalyticsWorkspaceManager: AzureLogAnalyticsWorkspaceManager
41
+ monitorManager: AzureMonitorManager
40
42
  resourceGroupManager: AzureResourceGroupManager
41
43
  resourceNameFormatter: AzureResourceNameFormatter
42
44
  servicebusManager: AzureServicebusManager
@@ -58,6 +60,7 @@ export class CommonAzureConstruct extends TerraformStack {
58
60
  this.functiontManager = new AzureFunctionManager()
59
61
  this.keyVaultManager = new AzureKeyVaultManager()
60
62
  this.logAnalyticsWorkspaceManager = new AzureLogAnalyticsWorkspaceManager()
63
+ this.monitorManager = new AzureMonitorManager()
61
64
  this.resourceGroupManager = new AzureResourceGroupManager()
62
65
  this.resourceNameFormatter = new AzureResourceNameFormatter(this, `${id}-rnf`, props)
63
66
  this.servicebusManager = new AzureServicebusManager()
@@ -176,6 +176,8 @@ export class AzureApiManagementManager {
176
176
  ignoreMissingProperty: true,
177
177
  ignoreCasing: true,
178
178
  schemaValidationEnabled: false,
179
+
180
+ lifecycle: props.lifecycle,
179
181
  })
180
182
 
181
183
  if (applicationInsightsKey) {
@@ -209,8 +211,8 @@ export class AzureApiManagementManager {
209
211
  const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
210
212
  ...props,
211
213
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementBackend),
212
- description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
213
- protocol: props.protocol || 'http',
214
+ description: props.description ?? `Backend for ${props.name}-${scope.props.stage}`,
215
+ protocol: props.protocol ?? 'http',
214
216
  })
215
217
 
216
218
  createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name)
@@ -233,9 +235,9 @@ export class AzureApiManagementManager {
233
235
  const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
234
236
  ...props,
235
237
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.apiManagementApi),
236
- displayName: props.displayName || props.name,
237
- revision: props.revision || '1',
238
- protocols: props.protocols || ['https'],
238
+ displayName: props.displayName ?? props.name,
239
+ revision: props.revision ?? '1',
240
+ protocols: props.protocols ?? ['https'],
239
241
  })
240
242
 
241
243
  createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
@@ -44,6 +44,9 @@ export class AzureAppConfigurationManager {
44
44
  ...props,
45
45
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.appConfiguration),
46
46
  resourceGroupName: resourceGroup.name,
47
+ identity: {
48
+ type: 'SystemAssigned',
49
+ },
47
50
  tags: props.tags ?? {
48
51
  environment: scope.props.stage,
49
52
  },
@@ -81,7 +81,7 @@ export class AzureAppServiceManager {
81
81
  resourceGroupName: resourceGroup.name,
82
82
  httpsOnly: props.httpsOnly ?? true,
83
83
 
84
- identity: props.identity || {
84
+ identity: props.identity ?? {
85
85
  type: 'SystemAssigned',
86
86
  },
87
87
  siteConfig: {
@@ -44,7 +44,7 @@ export class AzureApplicationInsightsManager {
44
44
  ...props,
45
45
  name: scope.resourceNameFormatter.format(props.name ?? '', scope.props.resourceNameOptions?.applicationInsights),
46
46
  resourceGroupName: resourceGroup.name,
47
- applicationType: props.applicationType || 'web',
47
+ applicationType: props.applicationType ?? 'web',
48
48
  tags: props.tags ?? {
49
49
  environment: scope.props.stage,
50
50
  },
@@ -50,7 +50,7 @@ export class AzureCosmosDbManager {
50
50
  tags: props.tags ?? {
51
51
  environment: scope.props.stage,
52
52
  },
53
- identity: props.identity || {
53
+ identity: props.identity ?? {
54
54
  type: 'SystemAssigned',
55
55
  },
56
56
  })
@@ -71,7 +71,7 @@ export class AzureDnsManager {
71
71
 
72
72
  const dnsARecord = new DnsARecord(scope, `${id}-da`, {
73
73
  ...props,
74
- ttl: props.ttl || 300,
74
+ ttl: props.ttl ?? 300,
75
75
  tags: props.tags ?? {
76
76
  environment: scope.props.stage,
77
77
  },
@@ -96,7 +96,7 @@ export class AzureDnsManager {
96
96
 
97
97
  const dnsCnameRecord = new DnsCnameRecord(scope, `${id}-dc`, {
98
98
  ...props,
99
- ttl: props.ttl || 300,
99
+ ttl: props.ttl ?? 300,
100
100
  tags: props.tags ?? {
101
101
  environment: scope.props.stage,
102
102
  },
@@ -121,7 +121,7 @@ export class AzureDnsManager {
121
121
 
122
122
  const dnsTxtRecord = new DnsTxtRecord(scope, `${id}-dc`, {
123
123
  ...props,
124
- ttl: props.ttl || 300,
124
+ ttl: props.ttl ?? 300,
125
125
  tags: props.tags ?? {
126
126
  environment: scope.props.stage,
127
127
  },
@@ -108,8 +108,8 @@ export class AzureEventgridManager {
108
108
  const eventgridSubscription = new EventgridEventSubscription(scope, `${id}-es`, {
109
109
  ...props,
110
110
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.eventGridEventSubscription),
111
- eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
112
- advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
111
+ eventDeliverySchema: props.eventDeliverySchema ?? 'CloudEventSchemaV1_0',
112
+ advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled ?? true,
113
113
  })
114
114
 
115
115
  createAzureTfOutput(`${id}-eventgridSubscriptiontName`, scope, eventgridSubscription.name)
@@ -1,7 +1,7 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
2
  import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app'
3
3
  import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function'
4
- import { Resource } from '../../.gen/providers/azapi/resource'
4
+ import { FunctionAppFlexConsumption } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption'
5
5
  import { LocalExec, Provider } from 'cdktf-local-exec'
6
6
  import { CommonAzureConstruct } from '../../common'
7
7
  import { createAzureTfOutput } from '../../utils'
@@ -72,7 +72,7 @@ export class AzureFunctionManager {
72
72
  const functionAppFunction = new FunctionAppFunction(scope, `${id}-fc`, {
73
73
  ...props,
74
74
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionAppFunction),
75
- configJson: JSON.stringify(props.configJson || {}),
75
+ configJson: JSON.stringify(props.configJson ?? {}),
76
76
  })
77
77
 
78
78
  createAzureTfOutput(`${id}-functionName`, scope, functionAppFunction.name)
@@ -103,69 +103,27 @@ export class AzureFunctionManager {
103
103
 
104
104
  if (!resourceGroup) throw `Resource group undefined for ${id}`
105
105
 
106
- const functionApp = new Resource(scope, `${id}-fa`, {
107
- type: 'Microsoft.Web/sites@2024-04-01',
106
+ const functionApp = new FunctionAppFlexConsumption(scope, `${id}-fc`, {
107
+ ...props,
108
108
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.functionApp),
109
109
  location: resourceGroup.location,
110
- parentId: resourceGroup.id,
111
-
112
- body: {
113
- kind: props.kind || 'functionapp,linux',
114
-
115
- properties: {
116
- serverFarmId: props.appServicePlanId,
117
- httpsOnly: props.httpsOnly || true,
118
-
119
- functionAppConfig: {
120
- deployment: {
121
- storage: {
122
- type: props.deploymentStorageType || 'blobContainer',
123
- value: `${props.blobEndpoint}${props.containerName}`,
124
- authentication: {
125
- type: props.deploymentAuthenticationType || 'StorageAccountConnectionString',
126
- storageAccountConnectionStringName:
127
- props.storageAccountConnectionStringName || 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
128
- },
129
- },
130
- },
131
- runtime: {
132
- name: props.runtime || 'node',
133
- version: props.runtimeVersion || '20',
134
- },
135
- scaleAndConcurrency: {
136
- alwaysReady: props.alwaysReady,
137
- instanceMemoryMB: props.instanceMemory || 2048,
138
- maximumInstanceCount: props.maximumInstanceCount || 40,
139
- triggers: {},
140
- },
141
- },
142
-
143
- siteConfig: {
144
- appSettings: props.appSettings.concat([
145
- {
146
- name: 'FUNCTIONS_EXTENSION_VERSION',
147
- value: '~4',
148
- },
149
- {
150
- name: 'AzureWebJobsStorage',
151
- value: props.storageConnectionString,
152
- },
153
- {
154
- name: 'DEPLOYMENT_STORAGE_CONNECTION_STRING',
155
- value: props.storageConnectionString,
156
- },
157
- ]),
158
- connectionStrings: props.connectionStrings,
159
- minTlsVersion: props.minTlsVersion ?? '1.3',
160
- },
161
- },
110
+ resourceGroupName: resourceGroup.name,
111
+ runtimeName: props.runtimeName ?? 'node',
112
+ runtimeVersion: props.runtimeVersion ?? '20',
113
+ storageAuthenticationType: props.storageAuthenticationType ?? 'StorageAccountConnectionString',
114
+ storageContainerType: props.storageContainerType ?? 'blobContainer',
115
+ maximumInstanceCount: props.maximumInstanceCount ?? 40,
116
+ instanceMemoryInMb: props.instanceMemoryInMb ?? 2048,
117
+ siteConfig: {
118
+ http2Enabled: props.siteConfig.http2Enabled ?? true,
119
+ ...props.siteConfig,
120
+ },
121
+ identity: props.identity ?? {
122
+ type: 'SystemAssigned',
123
+ },
124
+ tags: props.tags ?? {
125
+ environment: scope.props.stage,
162
126
  },
163
-
164
- identity: [{ type: 'SystemAssigned' }],
165
-
166
- ignoreMissingProperty: true,
167
- ignoreCasing: true,
168
- schemaValidationEnabled: false,
169
127
  })
170
128
 
171
129
  new Provider(scope, `${id}-local-exec-provider`)
@@ -1,31 +1,12 @@
1
1
  import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app'
2
2
  import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function'
3
- import { ResourceConfig } from '../../.gen/providers/azapi/resource'
3
+ import { FunctionAppFlexConsumptionConfig } from '@cdktf/provider-azurerm/lib/function-app-flex-consumption'
4
4
 
5
5
  export interface FunctionAppProps extends LinuxFunctionAppConfig {}
6
6
 
7
7
  export interface FunctionProps extends FunctionAppFunctionConfig {}
8
8
 
9
- export interface FunctionAppFlexConsumptionProps {
10
- alwaysReady?: any
11
- appServicePlanId: string
12
- appSettings: any
13
- blobEndpoint: string
14
- connectionStrings: any
15
- containerName: string
16
- deploymentAuthenticationType?: string
17
- deploymentStorageType?: string
18
- deploySource: string
19
- httpsOnly?: string
20
- instanceMemory?: number
21
- kind?: string
22
- maximumInstanceCount?: number
23
- name: string
24
- resourceGroupName: string
25
- runtime?: string
26
- runtimeVersion?: string
27
- storageAccountConnectionStringName?: string
28
- storageConnectionString: string
9
+ export interface FunctionAppFlexConsumptionProps extends FunctionAppFlexConsumptionConfig {
29
10
  sourceCodeHash: string
30
- minTlsVersion?: string
11
+ deploySource: string
31
12
  }
@@ -8,6 +8,7 @@ export * from './eventgrid'
8
8
  export * from './function'
9
9
  export * from './key-vault'
10
10
  export * from './log-analytics-workspace'
11
+ export * from './monitor'
11
12
  export * from './resource-group'
12
13
  export * from './servicebus'
13
14
  export * from './storage'
@@ -45,7 +45,7 @@ export class AzureKeyVaultManager {
45
45
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.keyVault),
46
46
  location: resourceGroup.location,
47
47
  resourceGroupName: resourceGroup.name,
48
- skuName: props.skuName || 'standard',
48
+ skuName: props.skuName ?? 'standard',
49
49
  enableRbacAuthorization: props.enableRbacAuthorization ?? true,
50
50
  softDeleteRetentionDays: props.softDeleteRetentionDays ?? 90,
51
51
  purgeProtectionEnabled: props.purgeProtectionEnabled ?? true,
@@ -45,6 +45,8 @@ export class AzureLogAnalyticsWorkspaceManager {
45
45
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.logAnalyticsWorkspace),
46
46
  location: resourceGroup.location,
47
47
  resourceGroupName: resourceGroup.name,
48
+ sku: props.sku ?? 'PerGB2018',
49
+ retentionInDays: props.retentionInDays ?? 30,
48
50
  tags: props.tags ?? {
49
51
  environment: scope.props.stage,
50
52
  },
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -0,0 +1,53 @@
1
+ import { MonitorDiagnosticSetting } from '@cdktf/provider-azurerm/lib/monitor-diagnostic-setting'
2
+ import { CommonAzureConstruct } from '../../common'
3
+ import { createAzureTfOutput } from '../../utils'
4
+ import { MonitorDiagnosticSettingProps } from './types'
5
+
6
+ /**
7
+ * @classdesc Provides operations on Azure Key Vault
8
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
9
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
10
+ * @example
11
+ * ```
12
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomConstruct extends CommonAzureConstruct {
15
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
16
+ * super(parent, id, props)
17
+ * this.props = props
18
+ * this.monitorManager.createMonitor('MyMonitor', this, props)
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export class AzureMonitorManager {
24
+ /**
25
+ * @summary Method to create a new monitor diagnostic setting
26
+ * @param id scoped id of the resource
27
+ * @param scope scope in which this resource is defined
28
+ * @param props monitor diagnostics settings properties
29
+ * @see [CDKTF Monitor Diagnostics Settings Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/monitorDiagnosticSetting.typescript.md}
30
+ */
31
+ public createMonitorDiagnosticSettings(
32
+ id: string,
33
+ scope: CommonAzureConstruct,
34
+ props: MonitorDiagnosticSettingProps
35
+ ) {
36
+ if (!props) throw `Props undefined for ${id}`
37
+
38
+ const monitorDiagnosticSetting = new MonitorDiagnosticSetting(scope, `${id}-ds`, {
39
+ ...props,
40
+ name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.monitorDiagnosticSetting),
41
+ })
42
+
43
+ createAzureTfOutput(`${id}-monitorDiagnosticSettingName`, scope, monitorDiagnosticSetting.name)
44
+ createAzureTfOutput(
45
+ `${id}-monitorDiagnosticSettingFriendlyUniqueId`,
46
+ scope,
47
+ monitorDiagnosticSetting.friendlyUniqueId
48
+ )
49
+ createAzureTfOutput(`${id}-monitorDiagnosticSettingId`, scope, monitorDiagnosticSetting.id)
50
+
51
+ return monitorDiagnosticSetting
52
+ }
53
+ }
@@ -0,0 +1,3 @@
1
+ import { MonitorDiagnosticSettingConfig } from '@cdktf/provider-azurerm/lib/monitor-diagnostic-setting'
2
+
3
+ export interface MonitorDiagnosticSettingProps extends MonitorDiagnosticSettingConfig {}
@@ -54,9 +54,9 @@ export class AzureServicebusManager {
54
54
  resourceGroupName: resourceGroup.name,
55
55
  location: resourceGroup.location,
56
56
  identity: {
57
- type: props.identity?.type || 'SystemAssigned',
57
+ type: props.identity?.type ?? 'SystemAssigned',
58
58
  },
59
- sku: props.sku || 'Standard',
59
+ sku: props.sku ?? 'Standard',
60
60
  tags: props.tags ?? {
61
61
  environment: scope.props.stage,
62
62
  },
@@ -128,7 +128,7 @@ export class AzureServicebusManager {
128
128
  const servicebusSubscription = new ServicebusSubscription(scope, `${id}-ss`, {
129
129
  ...props,
130
130
  name: scope.resourceNameFormatter.format(props.name, scope.props.resourceNameOptions?.serviceBusSubscription),
131
- maxDeliveryCount: props.maxDeliveryCount || 1,
131
+ maxDeliveryCount: props.maxDeliveryCount ?? 1,
132
132
  })
133
133
 
134
134
  createAzureTfOutput(`${id}-servicebusSubscriptionName`, scope, servicebusSubscription.name)