@gradientedge/cdk-utils 9.39.2 → 9.41.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 (55) hide show
  1. package/dist/src/lib/azure/common/construct.d.ts +11 -7
  2. package/dist/src/lib/azure/common/construct.js +17 -10
  3. package/dist/src/lib/azure/common/resource-name-formatter.d.ts +14 -0
  4. package/dist/src/lib/azure/common/resource-name-formatter.js +32 -0
  5. package/dist/src/lib/azure/common/types.d.ts +14 -0
  6. package/dist/src/lib/azure/services/api-management/main.js +1 -3
  7. package/dist/src/lib/azure/services/api-management/types.d.ts +2 -1
  8. package/dist/src/lib/azure/services/app-configuration/main.js +1 -3
  9. package/dist/src/lib/azure/services/app-service/main.js +2 -4
  10. package/dist/src/lib/azure/services/application-insights/main.js +1 -3
  11. package/dist/src/lib/azure/services/cosmosdb/main.js +5 -9
  12. package/dist/src/lib/azure/services/dns/index.d.ts +2 -0
  13. package/dist/src/lib/azure/services/dns/index.js +18 -0
  14. package/dist/src/lib/azure/services/dns/main.d.ts +48 -0
  15. package/dist/src/lib/azure/services/dns/main.js +113 -0
  16. package/dist/src/lib/azure/services/dns/types.d.ts +9 -0
  17. package/dist/src/lib/azure/services/dns/types.js +2 -0
  18. package/dist/src/lib/azure/services/eventgrid/main.d.ts +9 -0
  19. package/dist/src/lib/azure/services/eventgrid/main.js +30 -4
  20. package/dist/src/lib/azure/services/eventgrid/types.d.ts +2 -1
  21. package/dist/src/lib/azure/services/function/main.js +5 -9
  22. package/dist/src/lib/azure/services/index.d.ts +2 -0
  23. package/dist/src/lib/azure/services/index.js +2 -0
  24. package/dist/src/lib/azure/services/key-vault/main.js +2 -4
  25. package/dist/src/lib/azure/services/log-analytics-workspace/index.d.ts +2 -0
  26. package/dist/src/lib/azure/services/log-analytics-workspace/index.js +18 -0
  27. package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +30 -0
  28. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +55 -0
  29. package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +3 -0
  30. package/dist/src/lib/azure/services/log-analytics-workspace/types.js +2 -0
  31. package/dist/src/lib/azure/services/servicebus/main.js +5 -7
  32. package/dist/src/lib/azure/services/storage/main.js +4 -8
  33. package/package.json +1 -1
  34. package/src/lib/azure/common/construct.ts +20 -10
  35. package/src/lib/azure/common/resource-name-formatter.ts +38 -0
  36. package/src/lib/azure/common/types.ts +13 -0
  37. package/src/lib/azure/services/api-management/main.ts +4 -3
  38. package/src/lib/azure/services/api-management/types.ts +3 -1
  39. package/src/lib/azure/services/app-configuration/main.ts +4 -3
  40. package/src/lib/azure/services/app-service/main.ts +5 -4
  41. package/src/lib/azure/services/application-insights/main.ts +4 -3
  42. package/src/lib/azure/services/cosmosdb/main.ts +11 -9
  43. package/src/lib/azure/services/dns/index.ts +2 -0
  44. package/src/lib/azure/services/dns/main.ts +126 -0
  45. package/src/lib/azure/services/dns/types.ts +7 -0
  46. package/src/lib/azure/services/eventgrid/main.ts +43 -4
  47. package/src/lib/azure/services/eventgrid/types.ts +4 -1
  48. package/src/lib/azure/services/function/main.ts +11 -9
  49. package/src/lib/azure/services/index.ts +2 -0
  50. package/src/lib/azure/services/key-vault/main.ts +5 -4
  51. package/src/lib/azure/services/log-analytics-workspace/index.ts +2 -0
  52. package/src/lib/azure/services/log-analytics-workspace/main.ts +60 -0
  53. package/src/lib/azure/services/log-analytics-workspace/types.ts +3 -0
  54. package/src/lib/azure/services/servicebus/main.ts +8 -7
  55. package/src/lib/azure/services/storage/main.ts +10 -8
@@ -1,23 +1,27 @@
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 } from '../services';
3
+ import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager, AzureCosmosDbManager, AzureServicebusManager, AzureEventgridManager, AzureDnsManager, AzureLogAnalyticsWorkspaceManager } from '../services';
4
4
  import { CommonAzureStackProps } from './types';
5
+ import { AzureResourceNameFormatter } from './resource-name-formatter';
5
6
  export declare class CommonAzureConstruct extends TerraformStack {
6
7
  props: CommonAzureStackProps;
7
- id: string;
8
- fullyQualifiedDomainName: string;
9
- tenantId: string;
10
8
  apiManagementManager: AzureApiManagementManager;
9
+ appConfigurationManager: AzureAppConfigurationManager;
11
10
  appServiceManager: AzureAppServiceManager;
12
11
  applicationInsightsManager: AzureApplicationInsightsManager;
13
- appConfigurationManager: AzureAppConfigurationManager;
14
12
  cosmosDbManager: AzureCosmosDbManager;
13
+ dnsManager: AzureDnsManager;
14
+ eventgridManager: AzureEventgridManager;
15
+ fullyQualifiedDomainName: string;
15
16
  functiontManager: AzureFunctionManager;
17
+ id: string;
16
18
  keyVaultManager: AzureKeyVaultManager;
19
+ logAnalyticsWorkspaceManager: AzureLogAnalyticsWorkspaceManager;
17
20
  resourceGroupManager: AzureResourceGroupManager;
18
- storageManager: AzureStorageManager;
21
+ resourceNameFormatter: AzureResourceNameFormatter;
19
22
  servicebusManager: AzureServicebusManager;
20
- eventgridManager: AzureEventgridManager;
23
+ storageManager: AzureStorageManager;
24
+ tenantId: string;
21
25
  constructor(scope: Construct, id: string, props: CommonAzureStackProps);
22
26
  /**
23
27
  * @summary Determine the fully qualified domain name based on domainName & subDomain
@@ -8,41 +8,48 @@ const cdktf_1 = require("cdktf");
8
8
  const common_1 = require("../../common");
9
9
  const services_1 = require("../services");
10
10
  const constants_1 = require("./constants");
11
+ const resource_name_formatter_1 = require("./resource-name-formatter");
11
12
  class CommonAzureConstruct extends cdktf_1.TerraformStack {
12
- id;
13
- fullyQualifiedDomainName;
14
- tenantId;
15
13
  apiManagementManager;
14
+ appConfigurationManager;
16
15
  appServiceManager;
17
16
  applicationInsightsManager;
18
- appConfigurationManager;
19
17
  cosmosDbManager;
18
+ dnsManager;
19
+ eventgridManager;
20
+ fullyQualifiedDomainName;
20
21
  functiontManager;
22
+ id;
21
23
  keyVaultManager;
24
+ logAnalyticsWorkspaceManager;
22
25
  resourceGroupManager;
23
- storageManager;
26
+ resourceNameFormatter;
24
27
  servicebusManager;
25
- eventgridManager;
28
+ storageManager;
29
+ tenantId;
26
30
  constructor(scope, id, props) {
27
31
  super(scope, id);
28
32
  this.props = props;
29
33
  this.id = id;
30
34
  this.apiManagementManager = new services_1.AzureApiManagementManager();
35
+ this.appConfigurationManager = new services_1.AzureAppConfigurationManager();
31
36
  this.appServiceManager = new services_1.AzureAppServiceManager();
32
37
  this.applicationInsightsManager = new services_1.AzureApplicationInsightsManager();
33
- this.appConfigurationManager = new services_1.AzureAppConfigurationManager();
34
38
  this.cosmosDbManager = new services_1.AzureCosmosDbManager();
39
+ this.dnsManager = new services_1.AzureDnsManager();
40
+ this.eventgridManager = new services_1.AzureEventgridManager();
35
41
  this.functiontManager = new services_1.AzureFunctionManager();
36
42
  this.keyVaultManager = new services_1.AzureKeyVaultManager();
43
+ this.logAnalyticsWorkspaceManager = new services_1.AzureLogAnalyticsWorkspaceManager();
37
44
  this.resourceGroupManager = new services_1.AzureResourceGroupManager();
38
- this.storageManager = new services_1.AzureStorageManager();
45
+ this.resourceNameFormatter = new resource_name_formatter_1.AzureResourceNameFormatter(this, `${id}-rnf`, props);
39
46
  this.servicebusManager = new services_1.AzureServicebusManager();
40
- this.eventgridManager = new services_1.AzureEventgridManager();
47
+ this.storageManager = new services_1.AzureStorageManager();
41
48
  this.determineFullyQualifiedDomain();
42
49
  this.determineRemoteBackend();
43
50
  this.determineTenantId();
44
- new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
45
51
  new provider_2.AzapiProvider(this, `${this.id}-azapi-provider`, this.props);
52
+ new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
46
53
  }
47
54
  /**
48
55
  * @summary Determine the fully qualified domain name based on domainName & subDomain
@@ -0,0 +1,14 @@
1
+ import { Construct } from 'constructs';
2
+ import { AzureResourceNameFormatterProps } from './types';
3
+ import { CommonAzureStackProps } from './types';
4
+ export declare class AzureResourceNameFormatter extends Construct {
5
+ props: CommonAzureStackProps;
6
+ constructor(parent: Construct, id: string, props: CommonAzureStackProps);
7
+ /**
8
+ * @summary Helper method to format azure resource name based on the provided options
9
+ * @param resourceName The azure resource name to format
10
+ * @param options Options to control the formatting of the resource name
11
+ * @returns The formatted Azure-compliant resource name
12
+ */
13
+ format(resourceName: string, options?: AzureResourceNameFormatterProps): string;
14
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AzureResourceNameFormatter = void 0;
4
+ const constructs_1 = require("constructs");
5
+ class AzureResourceNameFormatter extends constructs_1.Construct {
6
+ props;
7
+ constructor(parent, id, props) {
8
+ super(parent, id);
9
+ this.props = props;
10
+ }
11
+ /**
12
+ * @summary Helper method to format azure resource name based on the provided options
13
+ * @param resourceName The azure resource name to format
14
+ * @param options Options to control the formatting of the resource name
15
+ * @returns The formatted Azure-compliant resource name
16
+ */
17
+ format(resourceName, options) {
18
+ const azureResourceNameElements = [];
19
+ if (!options?.exclude) {
20
+ azureResourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined);
21
+ azureResourceNameElements.push(options?.prefix ?? this.props.resourcePrefix);
22
+ }
23
+ azureResourceNameElements.push(resourceName);
24
+ if (!options?.exclude) {
25
+ azureResourceNameElements.push(options?.suffix ?? this.props.resourceSuffix);
26
+ azureResourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined);
27
+ }
28
+ azureResourceNameElements.push(this.props.stage);
29
+ return azureResourceNameElements.filter(Boolean).join('-');
30
+ }
31
+ }
32
+ exports.AzureResourceNameFormatter = AzureResourceNameFormatter;
@@ -7,7 +7,21 @@ import { AzurermBackendConfig } from 'cdktf';
7
7
  export interface CommonAzureStackProps extends BaseProps, AzurermProviderConfig {
8
8
  resourceGroupName?: string;
9
9
  remoteBackend?: AzureRemoteBackendProps;
10
+ globalPrefix?: string;
11
+ globalSuffix?: string;
12
+ resourcePrefix?: string;
13
+ resourceSuffix?: string;
14
+ resourceNameOptions?: {
15
+ [key: string]: AzureResourceNameFormatterProps;
16
+ };
10
17
  }
11
18
  export interface AzureRemoteBackendProps extends AzurermBackendConfig {
12
19
  type: AzureRemoteBackend;
13
20
  }
21
+ export interface AzureResourceNameFormatterProps {
22
+ exclude?: boolean;
23
+ globalPrefix?: boolean;
24
+ globalSuffix?: boolean;
25
+ prefix?: string;
26
+ suffix?: string;
27
+ }
@@ -43,9 +43,7 @@ class AzureApiManagementManager {
43
43
  if (!props)
44
44
  throw `Props undefined for ${id}`;
45
45
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
46
- name: scope.props.resourceGroupName
47
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
48
- : `${props.resourceGroupName}`,
46
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
49
47
  });
50
48
  if (!resourceGroup)
51
49
  throw `Resource group undefined for ${id}`;
@@ -3,7 +3,8 @@ import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-mana
3
3
  import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api';
4
4
  import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation';
5
5
  import { ApiManagementApiOperationPolicyConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy';
6
- export interface ApiManagementProps extends ApiManagementConfig {
6
+ export interface ApiManagementProps extends Omit<ApiManagementConfig, 'name'> {
7
+ name?: string | undefined;
7
8
  }
8
9
  export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
9
10
  }
@@ -33,9 +33,7 @@ class AzureAppConfigurationManager {
33
33
  if (!props)
34
34
  throw `Props undefined for ${id}`;
35
35
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
- name: scope.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
36
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
39
37
  });
40
38
  if (!resourceGroup)
41
39
  throw `Resource group undefined for ${id}`;
@@ -33,15 +33,13 @@ class AzureAppServiceManager {
33
33
  if (!props)
34
34
  throw `Props undefined for ${id}`;
35
35
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
- name: scope.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
36
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
39
37
  });
40
38
  if (!resourceGroup)
41
39
  throw `Resource group undefined for ${id}`;
42
40
  const appServicePlan = new service_plan_1.ServicePlan(scope, `${id}-am`, {
43
41
  ...props,
44
- name: `${props.name}-${scope.props.stage}`,
42
+ name: scope.resourceNameFormatter.format(props.name),
45
43
  resourceGroupName: resourceGroup.name,
46
44
  tags: props.tags ?? {
47
45
  environment: scope.props.stage,
@@ -33,9 +33,7 @@ class AzureApplicationInsightsManager {
33
33
  if (!props)
34
34
  throw `Props undefined for ${id}`;
35
35
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
- name: scope.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
36
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
39
37
  });
40
38
  if (!resourceGroup)
41
39
  throw `Resource group undefined for ${id}`;
@@ -35,15 +35,13 @@ class AzureCosmosDbManager {
35
35
  if (!props)
36
36
  throw `Props undefined for ${id}`;
37
37
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-ca-rg`, {
38
- name: scope.props.resourceGroupName
39
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
40
- : `${props.resourceGroupName}`,
38
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
41
39
  });
42
40
  if (!resourceGroup)
43
41
  throw `Resource group undefined for ${id}`;
44
42
  const cosmosdbAccount = new cosmosdb_account_1.CosmosdbAccount(scope, `${id}-ca`, {
45
43
  ...props,
46
- name: `${props.name}-${scope.props.stage}`,
44
+ name: scope.resourceNameFormatter.format(props.name),
47
45
  location: resourceGroup.location,
48
46
  resourceGroupName: resourceGroup.name,
49
47
  tags: props.tags ?? {
@@ -66,15 +64,13 @@ class AzureCosmosDbManager {
66
64
  if (!props)
67
65
  throw `Props undefined for ${id}`;
68
66
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-cd-rg`, {
69
- name: scope.props.resourceGroupName
70
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
71
- : `${props.resourceGroupName}`,
67
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
72
68
  });
73
69
  if (!resourceGroup)
74
70
  throw `Resource group undefined for ${id}`;
75
71
  const cosmosdbDatatbase = new cosmosdb_sql_database_1.CosmosdbSqlDatabase(scope, `${id}-cd`, {
76
72
  ...props,
77
- name: `${props.name}-${scope.props.stage}`,
73
+ name: scope.resourceNameFormatter.format(props.name),
78
74
  resourceGroupName: resourceGroup.name,
79
75
  });
80
76
  (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbDatatbasetName`, scope, cosmosdbDatatbase.name);
@@ -101,7 +97,7 @@ class AzureCosmosDbManager {
101
97
  throw `Resource group undefined for ${id}`;
102
98
  const cosmosdbContainer = new cosmosdb_sql_container_1.CosmosdbSqlContainer(scope, `${id}-cc`, {
103
99
  ...props,
104
- name: `${props.name}-${scope.props.stage}`,
100
+ name: scope.resourceNameFormatter.format(props.name),
105
101
  resourceGroupName: resourceGroup.name,
106
102
  });
107
103
  (0, utils_1.createAzureTfOutput)(`${id}-cosmosdbContainertName`, scope, cosmosdbContainer.name);
@@ -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,48 @@
1
+ import { DnsZone } from '@cdktf/provider-azurerm/lib/dns-zone';
2
+ import { DnsARecord } from '@cdktf/provider-azurerm/lib/dns-a-record';
3
+ import { DnsCnameRecord } from '@cdktf/provider-azurerm/lib/dns-cname-record';
4
+ import { CommonAzureConstruct } from '../../common';
5
+ import { DnsZoneProps, DnsARecordProps, DnsCnameRecordProps } from './types';
6
+ /**
7
+ * @classdesc Provides operations on Azure DNS
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.dnsManager.createAppService('MyDnsZone', this, props)
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export declare class AzureDnsManager {
24
+ /**
25
+ * @summary Method to create a new DNS Zone
26
+ * @param id scoped id of the resource
27
+ * @param scope scope in which this resource is defined
28
+ * @param props dns zone properties
29
+ * @see [CDKTF DNS Zone Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsZone.typescript.md}
30
+ */
31
+ createDnsZone(id: string, scope: CommonAzureConstruct, props: DnsZoneProps): DnsZone;
32
+ /**
33
+ * @summary Method to create a new DNS A Record
34
+ * @param id scoped id of the resource
35
+ * @param scope scope in which this resource is defined
36
+ * @param props dns a record properties
37
+ * @see [CDKTF DNS A Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsARecord.typescript.md}
38
+ */
39
+ createDnsARecord(id: string, scope: CommonAzureConstruct, props: DnsARecordProps): DnsARecord;
40
+ /**
41
+ * @summary Method to create a new DNS CNAME Record
42
+ * @param id scoped id of the resource
43
+ * @param scope scope in which this resource is defined
44
+ * @param props dns cname record properties
45
+ * @see [CDKTF DNS CNAME Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
46
+ */
47
+ createDnsCnameRecord(id: string, scope: CommonAzureConstruct, props: DnsCnameRecordProps): DnsCnameRecord;
48
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AzureDnsManager = void 0;
4
+ const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
+ const data_azurerm_dns_zone_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-dns-zone");
6
+ const dns_zone_1 = require("@cdktf/provider-azurerm/lib/dns-zone");
7
+ const dns_a_record_1 = require("@cdktf/provider-azurerm/lib/dns-a-record");
8
+ const dns_cname_record_1 = require("@cdktf/provider-azurerm/lib/dns-cname-record");
9
+ const utils_1 = require("../../utils");
10
+ /**
11
+ * @classdesc Provides operations on Azure DNS
12
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
13
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
14
+ * @example
15
+ * ```
16
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
17
+ *
18
+ * class CustomConstruct extends CommonAzureConstruct {
19
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
20
+ * super(parent, id, props)
21
+ * this.props = props
22
+ * this.dnsManager.createAppService('MyDnsZone', this, props)
23
+ * }
24
+ * }
25
+ * ```
26
+ */
27
+ class AzureDnsManager {
28
+ /**
29
+ * @summary Method to create a new DNS Zone
30
+ * @param id scoped id of the resource
31
+ * @param scope scope in which this resource is defined
32
+ * @param props dns zone properties
33
+ * @see [CDKTF DNS Zone Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsZone.typescript.md}
34
+ */
35
+ createDnsZone(id, scope, props) {
36
+ if (!props)
37
+ throw `Props undefined for ${id}`;
38
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
39
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
40
+ });
41
+ if (!resourceGroup)
42
+ throw `Resource group undefined for ${id}`;
43
+ const dnsZone = new dns_zone_1.DnsZone(scope, `${id}-dz`, {
44
+ ...props,
45
+ name: scope.resourceNameFormatter.format(props.name),
46
+ resourceGroupName: resourceGroup.name,
47
+ tags: props.tags ?? {
48
+ environment: scope.props.stage,
49
+ },
50
+ });
51
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsZoneName`, scope, dnsZone.name);
52
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsZoneFriendlyUniqueId`, scope, dnsZone.friendlyUniqueId);
53
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsZoneId`, scope, dnsZone.id);
54
+ return dnsZone;
55
+ }
56
+ /**
57
+ * @summary Method to create a new DNS A Record
58
+ * @param id scoped id of the resource
59
+ * @param scope scope in which this resource is defined
60
+ * @param props dns a record properties
61
+ * @see [CDKTF DNS A Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsARecord.typescript.md}
62
+ */
63
+ createDnsARecord(id, scope, props) {
64
+ if (!props)
65
+ throw `Props undefined for ${id}`;
66
+ const dnsZone = new data_azurerm_dns_zone_1.DataAzurermDnsZone(scope, `${id}-da-dz`, {
67
+ name: props.zoneName,
68
+ resourceGroupName: props.resourceGroupName,
69
+ });
70
+ const dnsARecord = new dns_a_record_1.DnsARecord(scope, `${id}-da`, {
71
+ ...props,
72
+ name: scope.resourceNameFormatter.format(props.name),
73
+ resourceGroupName: dnsZone.resourceGroupName,
74
+ zoneName: dnsZone.name,
75
+ tags: props.tags ?? {
76
+ environment: scope.props.stage,
77
+ },
78
+ });
79
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsARecordName`, scope, dnsARecord.name);
80
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsARecordFriendlyUniqueId`, scope, dnsARecord.friendlyUniqueId);
81
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsARecordId`, scope, dnsARecord.id);
82
+ return dnsARecord;
83
+ }
84
+ /**
85
+ * @summary Method to create a new DNS CNAME Record
86
+ * @param id scoped id of the resource
87
+ * @param scope scope in which this resource is defined
88
+ * @param props dns cname record properties
89
+ * @see [CDKTF DNS CNAME Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
90
+ */
91
+ createDnsCnameRecord(id, scope, props) {
92
+ if (!props)
93
+ throw `Props undefined for ${id}`;
94
+ const dnsZone = new data_azurerm_dns_zone_1.DataAzurermDnsZone(scope, `${id}-dc-dz`, {
95
+ name: props.zoneName,
96
+ resourceGroupName: props.resourceGroupName,
97
+ });
98
+ const dnsCnameRecord = new dns_cname_record_1.DnsCnameRecord(scope, `${id}-dc`, {
99
+ ...props,
100
+ name: scope.resourceNameFormatter.format(props.name),
101
+ resourceGroupName: dnsZone.resourceGroupName,
102
+ zoneName: dnsZone.name,
103
+ tags: props.tags ?? {
104
+ environment: scope.props.stage,
105
+ },
106
+ });
107
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsCnameRecordName`, scope, dnsCnameRecord.name);
108
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsCnameRecordFriendlyUniqueId`, scope, dnsCnameRecord.friendlyUniqueId);
109
+ (0, utils_1.createAzureTfOutput)(`${id}-dnsCnameRecordId`, scope, dnsCnameRecord.id);
110
+ return dnsCnameRecord;
111
+ }
112
+ }
113
+ exports.AzureDnsManager = AzureDnsManager;
@@ -0,0 +1,9 @@
1
+ import { DnsZoneConfig } from '@cdktf/provider-azurerm/lib/dns-zone';
2
+ import { DnsARecordConfig } from '@cdktf/provider-azurerm/lib/dns-a-record';
3
+ import { DnsCnameRecordConfig } from '@cdktf/provider-azurerm/lib/dns-cname-record';
4
+ export interface DnsZoneProps extends DnsZoneConfig {
5
+ }
6
+ export interface DnsARecordProps extends DnsARecordConfig {
7
+ }
8
+ export interface DnsCnameRecordProps extends DnsCnameRecordConfig {
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ import { DataAzurermEventgridTopic, DataAzurermEventgridTopicConfig } from '@cdktf/provider-azurerm/lib/data-azurerm-eventgrid-topic';
1
2
  import { EventgridTopic } from '@cdktf/provider-azurerm/lib/eventgrid-topic';
2
3
  import { EventgridEventSubscription } from '@cdktf/provider-azurerm/lib/eventgrid-event-subscription';
3
4
  import { CommonAzureConstruct } from '../../common';
@@ -28,6 +29,14 @@ export declare class AzureEventgridManager {
28
29
  * @see [CDKTF Eventgrid Topic Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/eventgridTopic.typescript.md}
29
30
  */
30
31
  createEventgridTopic(id: string, scope: CommonAzureConstruct, props: EventgridTopicProps): EventgridTopic;
32
+ /**
33
+ * @summary Method to resolve an existing eventgrid topic
34
+ * @param id scoped id of the resource
35
+ * @param scope scope in which this resource is defined
36
+ * @param props eventgrid topic properties
37
+ * @see [CDKTF Eventgrid Topic Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/eventgridTopic.typescript.md}
38
+ */
39
+ resolveEventgridTopic(id: string, scope: CommonAzureConstruct, props: DataAzurermEventgridTopicConfig): DataAzurermEventgridTopic;
31
40
  /**
32
41
  * @summary Method to create a new eventgrid subscription
33
42
  * @param id scoped id of the resource
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AzureEventgridManager = void 0;
4
4
  const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
+ const data_azurerm_eventgrid_topic_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-eventgrid-topic");
5
6
  const eventgrid_topic_1 = require("@cdktf/provider-azurerm/lib/eventgrid-topic");
6
7
  const eventgrid_event_subscription_1 = require("@cdktf/provider-azurerm/lib/eventgrid-event-subscription");
7
8
  const utils_1 = require("../../utils");
@@ -34,9 +35,7 @@ class AzureEventgridManager {
34
35
  if (!props)
35
36
  throw `Props undefined for ${id}`;
36
37
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-et-rg`, {
37
- name: scope.props.resourceGroupName
38
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
39
- : `${props.resourceGroupName}`,
38
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
40
39
  });
41
40
  if (!resourceGroup)
42
41
  throw `Resource group undefined for ${id}`;
@@ -52,6 +51,33 @@ class AzureEventgridManager {
52
51
  (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicName`, scope, eventgridTopic.name);
53
52
  (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicFriendlyUniqueId`, scope, eventgridTopic.friendlyUniqueId);
54
53
  (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicId`, scope, eventgridTopic.id);
54
+ (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicEndpoint`, scope, eventgridTopic.endpoint);
55
+ return eventgridTopic;
56
+ }
57
+ /**
58
+ * @summary Method to resolve an existing eventgrid topic
59
+ * @param id scoped id of the resource
60
+ * @param scope scope in which this resource is defined
61
+ * @param props eventgrid topic properties
62
+ * @see [CDKTF Eventgrid Topic Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/eventgridTopic.typescript.md}
63
+ */
64
+ resolveEventgridTopic(id, scope, props) {
65
+ if (!props)
66
+ throw `Props undefined for ${id}`;
67
+ const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-et-rg`, {
68
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
69
+ });
70
+ if (!resourceGroup)
71
+ throw `Resource group undefined for ${id}`;
72
+ const eventgridTopic = new data_azurerm_eventgrid_topic_1.DataAzurermEventgridTopic(scope, `${id}-et`, {
73
+ ...props,
74
+ name: scope.resourceNameFormatter.format(props.name),
75
+ resourceGroupName: resourceGroup.name,
76
+ });
77
+ (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicName`, scope, eventgridTopic.name);
78
+ (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicFriendlyUniqueId`, scope, eventgridTopic.friendlyUniqueId);
79
+ (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicId`, scope, eventgridTopic.id);
80
+ (0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicEndpoint`, scope, eventgridTopic.endpoint);
55
81
  return eventgridTopic;
56
82
  }
57
83
  /**
@@ -66,7 +92,7 @@ class AzureEventgridManager {
66
92
  throw `Props undefined for ${id}`;
67
93
  const eventgridSubscription = new eventgrid_event_subscription_1.EventgridEventSubscription(scope, `${id}-es`, {
68
94
  ...props,
69
- name: `${props.name}-${scope.props.stage}`,
95
+ name: scope.resourceNameFormatter.format(props.name),
70
96
  eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
71
97
  advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
72
98
  });
@@ -1,6 +1,7 @@
1
1
  import { EventgridTopicConfig } from '@cdktf/provider-azurerm/lib/eventgrid-topic';
2
2
  import { EventgridEventSubscriptionConfig } from '@cdktf/provider-azurerm/lib/eventgrid-event-subscription';
3
- export interface EventgridTopicProps extends EventgridTopicConfig {
3
+ export interface EventgridTopicProps extends Omit<EventgridTopicConfig, 'name'> {
4
+ name?: string | undefined;
4
5
  }
5
6
  export interface EventgridEventSubscriptionProps extends EventgridEventSubscriptionConfig {
6
7
  }
@@ -36,15 +36,13 @@ class AzureFunctionManager {
36
36
  if (!props)
37
37
  throw `Props undefined for ${id}`;
38
38
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
39
- name: scope.props.resourceGroupName
40
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
41
- : `${props.resourceGroupName}`,
39
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
42
40
  });
43
41
  if (!resourceGroup)
44
42
  throw `Resource group undefined for ${id}`;
45
43
  const functionApp = new linux_function_app_1.LinuxFunctionApp(scope, `${id}-fa`, {
46
44
  ...props,
47
- name: `${props.name}-${scope.props.stage}`,
45
+ name: scope.resourceNameFormatter.format(props.name),
48
46
  resourceGroupName: resourceGroup.name,
49
47
  tags: props.tags ?? {
50
48
  environment: scope.props.stage,
@@ -67,7 +65,7 @@ class AzureFunctionManager {
67
65
  throw `Props undefined for ${id}`;
68
66
  const functionAppFunction = new function_app_function_1.FunctionAppFunction(scope, `${id}-fc`, {
69
67
  ...props,
70
- name: `${props.name}-${scope.props.stage}`,
68
+ name: scope.resourceNameFormatter.format(props.name),
71
69
  configJson: JSON.stringify(props.configJson || {}),
72
70
  });
73
71
  (0, utils_1.createAzureTfOutput)(`${id}-functionName`, scope, functionAppFunction.name);
@@ -85,15 +83,13 @@ class AzureFunctionManager {
85
83
  if (!props)
86
84
  throw `Props undefined for ${id}`;
87
85
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
88
- name: scope.props.resourceGroupName
89
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
90
- : `${props.resourceGroupName}`,
86
+ name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
91
87
  });
92
88
  if (!resourceGroup)
93
89
  throw `Resource group undefined for ${id}`;
94
90
  const functionApp = new resource_1.Resource(scope, `${id}-fa`, {
95
91
  type: 'Microsoft.Web/sites@2024-04-01',
96
- name: `${props.name}-${scope.props.stage}`,
92
+ name: scope.resourceNameFormatter.format(props.name),
97
93
  location: resourceGroup.location,
98
94
  parentId: resourceGroup.id,
99
95
  body: {
@@ -3,9 +3,11 @@ export * from './app-configuration';
3
3
  export * from './app-service';
4
4
  export * from './application-insights';
5
5
  export * from './cosmosdb';
6
+ export * from './dns';
6
7
  export * from './eventgrid';
7
8
  export * from './function';
8
9
  export * from './key-vault';
10
+ export * from './log-analytics-workspace';
9
11
  export * from './resource-group';
10
12
  export * from './servicebus';
11
13
  export * from './storage';
@@ -19,9 +19,11 @@ __exportStar(require("./app-configuration"), exports);
19
19
  __exportStar(require("./app-service"), exports);
20
20
  __exportStar(require("./application-insights"), exports);
21
21
  __exportStar(require("./cosmosdb"), exports);
22
+ __exportStar(require("./dns"), exports);
22
23
  __exportStar(require("./eventgrid"), exports);
23
24
  __exportStar(require("./function"), exports);
24
25
  __exportStar(require("./key-vault"), exports);
26
+ __exportStar(require("./log-analytics-workspace"), exports);
25
27
  __exportStar(require("./resource-group"), exports);
26
28
  __exportStar(require("./servicebus"), exports);
27
29
  __exportStar(require("./storage"), exports);