@gradientedge/cdk-utils 9.40.0 → 9.41.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.
- package/dist/src/lib/azure/common/construct.d.ts +2 -0
- package/dist/src/lib/azure/common/construct.js +3 -0
- package/dist/src/lib/azure/common/resource-name-formatter.d.ts +14 -0
- package/dist/src/lib/azure/common/resource-name-formatter.js +32 -0
- package/dist/src/lib/azure/common/types.d.ts +14 -0
- package/dist/src/lib/azure/services/api-management/main.js +7 -11
- package/dist/src/lib/azure/services/api-management/types.d.ts +1 -2
- package/dist/src/lib/azure/services/app-configuration/main.js +1 -3
- package/dist/src/lib/azure/services/app-service/main.js +2 -4
- package/dist/src/lib/azure/services/application-insights/main.js +1 -3
- package/dist/src/lib/azure/services/cosmosdb/main.js +5 -9
- package/dist/src/lib/azure/services/dns/main.d.ts +10 -1
- package/dist/src/lib/azure/services/dns/main.js +29 -19
- package/dist/src/lib/azure/services/dns/types.d.ts +3 -0
- package/dist/src/lib/azure/services/eventgrid/main.js +5 -9
- package/dist/src/lib/azure/services/eventgrid/types.d.ts +1 -2
- package/dist/src/lib/azure/services/function/main.js +5 -9
- package/dist/src/lib/azure/services/key-vault/main.js +2 -4
- package/dist/src/lib/azure/services/log-analytics-workspace/main.js +2 -4
- package/dist/src/lib/azure/services/servicebus/main.js +5 -7
- package/dist/src/lib/azure/services/storage/main.js +4 -8
- package/package.json +1 -1
- package/src/lib/azure/common/construct.ts +3 -0
- package/src/lib/azure/common/resource-name-formatter.ts +38 -0
- package/src/lib/azure/common/types.ts +13 -0
- package/src/lib/azure/services/api-management/main.ts +13 -11
- package/src/lib/azure/services/api-management/types.ts +1 -3
- package/src/lib/azure/services/app-configuration/main.ts +4 -3
- package/src/lib/azure/services/app-service/main.ts +5 -4
- package/src/lib/azure/services/application-insights/main.ts +4 -3
- package/src/lib/azure/services/cosmosdb/main.ts +11 -9
- package/src/lib/azure/services/dns/main.ts +36 -22
- package/src/lib/azure/services/dns/types.ts +2 -0
- package/src/lib/azure/services/eventgrid/main.ts +11 -9
- package/src/lib/azure/services/eventgrid/types.ts +1 -3
- package/src/lib/azure/services/function/main.ts +11 -9
- package/src/lib/azure/services/key-vault/main.ts +5 -4
- package/src/lib/azure/services/log-analytics-workspace/main.ts +5 -4
- package/src/lib/azure/services/servicebus/main.ts +8 -7
- package/src/lib/azure/services/storage/main.ts +10 -8
|
@@ -2,6 +2,7 @@ import { TerraformStack } from 'cdktf';
|
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
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
8
|
apiManagementManager: AzureApiManagementManager;
|
|
@@ -17,6 +18,7 @@ export declare class CommonAzureConstruct extends TerraformStack {
|
|
|
17
18
|
keyVaultManager: AzureKeyVaultManager;
|
|
18
19
|
logAnalyticsWorkspaceManager: AzureLogAnalyticsWorkspaceManager;
|
|
19
20
|
resourceGroupManager: AzureResourceGroupManager;
|
|
21
|
+
resourceNameFormatter: AzureResourceNameFormatter;
|
|
20
22
|
servicebusManager: AzureServicebusManager;
|
|
21
23
|
storageManager: AzureStorageManager;
|
|
22
24
|
tenantId: string;
|
|
@@ -8,6 +8,7 @@ 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
13
|
apiManagementManager;
|
|
13
14
|
appConfigurationManager;
|
|
@@ -22,6 +23,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
22
23
|
keyVaultManager;
|
|
23
24
|
logAnalyticsWorkspaceManager;
|
|
24
25
|
resourceGroupManager;
|
|
26
|
+
resourceNameFormatter;
|
|
25
27
|
servicebusManager;
|
|
26
28
|
storageManager;
|
|
27
29
|
tenantId;
|
|
@@ -40,6 +42,7 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
40
42
|
this.keyVaultManager = new services_1.AzureKeyVaultManager();
|
|
41
43
|
this.logAnalyticsWorkspaceManager = new services_1.AzureLogAnalyticsWorkspaceManager();
|
|
42
44
|
this.resourceGroupManager = new services_1.AzureResourceGroupManager();
|
|
45
|
+
this.resourceNameFormatter = new resource_name_formatter_1.AzureResourceNameFormatter(this, `${id}-rnf`, props);
|
|
43
46
|
this.servicebusManager = new services_1.AzureServicebusManager();
|
|
44
47
|
this.storageManager = new services_1.AzureStorageManager();
|
|
45
48
|
this.determineFullyQualifiedDomain();
|
|
@@ -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,15 +43,13 @@ 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}`;
|
|
52
50
|
const apiManagement = new api_management_1.ApiManagement(scope, `${id}-am`, {
|
|
53
51
|
...props,
|
|
54
|
-
name:
|
|
52
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
55
53
|
resourceGroupName: resourceGroup.name,
|
|
56
54
|
tags: props.tags ?? {
|
|
57
55
|
environment: scope.props.stage,
|
|
@@ -59,7 +57,7 @@ class AzureApiManagementManager {
|
|
|
59
57
|
});
|
|
60
58
|
if (applicationInsightsKey) {
|
|
61
59
|
new api_management_logger_1.ApiManagementLogger(scope, `${id}-am-logger`, {
|
|
62
|
-
name:
|
|
60
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
63
61
|
resourceGroupName: resourceGroup.name,
|
|
64
62
|
apiManagementName: apiManagement.name,
|
|
65
63
|
applicationInsights: {
|
|
@@ -83,15 +81,13 @@ class AzureApiManagementManager {
|
|
|
83
81
|
if (!props)
|
|
84
82
|
throw `Props undefined for ${id}`;
|
|
85
83
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
86
|
-
name: scope.props.resourceGroupName
|
|
87
|
-
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
88
|
-
: `${props.resourceGroupName}`,
|
|
84
|
+
name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
|
|
89
85
|
});
|
|
90
86
|
if (!resourceGroup)
|
|
91
87
|
throw `Resource group undefined for ${id}`;
|
|
92
88
|
const apiManagement = new data_azurerm_api_management_1.DataAzurermApiManagement(scope, `${id}-am`, {
|
|
93
89
|
...props,
|
|
94
|
-
name:
|
|
90
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
95
91
|
resourceGroupName: scope.props.resourceGroupName
|
|
96
92
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
97
93
|
: `${props.resourceGroupName}`,
|
|
@@ -110,7 +106,7 @@ class AzureApiManagementManager {
|
|
|
110
106
|
throw `Props undefined for ${id}`;
|
|
111
107
|
const apiManagementBackend = new api_management_backend_1.ApiManagementBackend(scope, `${id}-am-be`, {
|
|
112
108
|
...props,
|
|
113
|
-
name:
|
|
109
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
114
110
|
description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
|
|
115
111
|
protocol: props.protocol || 'http',
|
|
116
112
|
});
|
|
@@ -131,7 +127,7 @@ class AzureApiManagementManager {
|
|
|
131
127
|
throw `Props undefined for ${id}`;
|
|
132
128
|
const apiManagementApi = new api_management_api_1.ApiManagementApi(scope, `${id}-am-api`, {
|
|
133
129
|
...props,
|
|
134
|
-
name:
|
|
130
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
135
131
|
displayName: props.displayName || props.name,
|
|
136
132
|
revision: props.revision || '1',
|
|
137
133
|
protocols: props.protocols || ['https'],
|
|
@@ -3,8 +3,7 @@ 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
|
|
7
|
-
name?: string | undefined;
|
|
6
|
+
export interface ApiManagementProps extends ApiManagementConfig {
|
|
8
7
|
}
|
|
9
8
|
export interface ApiManagementBackendProps extends ApiManagementBackendConfig {
|
|
10
9
|
}
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { DnsZone } from '@cdktf/provider-azurerm/lib/dns-zone';
|
|
2
2
|
import { DnsARecord } from '@cdktf/provider-azurerm/lib/dns-a-record';
|
|
3
3
|
import { DnsCnameRecord } from '@cdktf/provider-azurerm/lib/dns-cname-record';
|
|
4
|
+
import { DnsTxtRecord } from '@cdktf/provider-azurerm/lib/dns-txt-record';
|
|
4
5
|
import { CommonAzureConstruct } from '../../common';
|
|
5
|
-
import { DnsZoneProps, DnsARecordProps, DnsCnameRecordProps } from './types';
|
|
6
|
+
import { DnsZoneProps, DnsARecordProps, DnsCnameRecordProps, DnsTxtRecordProps } from './types';
|
|
6
7
|
/**
|
|
7
8
|
* @classdesc Provides operations on Azure DNS
|
|
8
9
|
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
@@ -45,4 +46,12 @@ export declare class AzureDnsManager {
|
|
|
45
46
|
* @see [CDKTF DNS CNAME Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
|
|
46
47
|
*/
|
|
47
48
|
createDnsCnameRecord(id: string, scope: CommonAzureConstruct, props: DnsCnameRecordProps): DnsCnameRecord;
|
|
49
|
+
/**
|
|
50
|
+
* @summary Method to create a new DNS TXT Record
|
|
51
|
+
* @param id scoped id of the resource
|
|
52
|
+
* @param scope scope in which this resource is defined
|
|
53
|
+
* @param props dns txt record properties
|
|
54
|
+
* @see [CDKTF DNS TXT Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
|
|
55
|
+
*/
|
|
56
|
+
createDnsTxtRecord(id: string, scope: CommonAzureConstruct, props: DnsTxtRecordProps): DnsTxtRecord;
|
|
48
57
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AzureDnsManager = void 0;
|
|
4
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
5
|
const dns_zone_1 = require("@cdktf/provider-azurerm/lib/dns-zone");
|
|
7
6
|
const dns_a_record_1 = require("@cdktf/provider-azurerm/lib/dns-a-record");
|
|
8
7
|
const dns_cname_record_1 = require("@cdktf/provider-azurerm/lib/dns-cname-record");
|
|
8
|
+
const dns_txt_record_1 = require("@cdktf/provider-azurerm/lib/dns-txt-record");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
/**
|
|
11
11
|
* @classdesc Provides operations on Azure DNS
|
|
@@ -36,15 +36,13 @@ class AzureDnsManager {
|
|
|
36
36
|
if (!props)
|
|
37
37
|
throw `Props undefined for ${id}`;
|
|
38
38
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-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 dnsZone = new dns_zone_1.DnsZone(scope, `${id}-dz`, {
|
|
46
44
|
...props,
|
|
47
|
-
name:
|
|
45
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
48
46
|
resourceGroupName: resourceGroup.name,
|
|
49
47
|
tags: props.tags ?? {
|
|
50
48
|
environment: scope.props.stage,
|
|
@@ -65,15 +63,10 @@ class AzureDnsManager {
|
|
|
65
63
|
createDnsARecord(id, scope, props) {
|
|
66
64
|
if (!props)
|
|
67
65
|
throw `Props undefined for ${id}`;
|
|
68
|
-
const dnsZone = new data_azurerm_dns_zone_1.DataAzurermDnsZone(scope, `${id}-da-dz`, {
|
|
69
|
-
name: props.zoneName,
|
|
70
|
-
resourceGroupName: props.resourceGroupName,
|
|
71
|
-
});
|
|
72
66
|
const dnsARecord = new dns_a_record_1.DnsARecord(scope, `${id}-da`, {
|
|
73
67
|
...props,
|
|
74
|
-
name:
|
|
75
|
-
|
|
76
|
-
zoneName: dnsZone.name,
|
|
68
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
69
|
+
ttl: props.ttl || 300,
|
|
77
70
|
tags: props.tags ?? {
|
|
78
71
|
environment: scope.props.stage,
|
|
79
72
|
},
|
|
@@ -93,15 +86,10 @@ class AzureDnsManager {
|
|
|
93
86
|
createDnsCnameRecord(id, scope, props) {
|
|
94
87
|
if (!props)
|
|
95
88
|
throw `Props undefined for ${id}`;
|
|
96
|
-
const dnsZone = new data_azurerm_dns_zone_1.DataAzurermDnsZone(scope, `${id}-dc-dz`, {
|
|
97
|
-
name: props.zoneName,
|
|
98
|
-
resourceGroupName: props.resourceGroupName,
|
|
99
|
-
});
|
|
100
89
|
const dnsCnameRecord = new dns_cname_record_1.DnsCnameRecord(scope, `${id}-dc`, {
|
|
101
90
|
...props,
|
|
102
|
-
name:
|
|
103
|
-
|
|
104
|
-
zoneName: dnsZone.name,
|
|
91
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
92
|
+
ttl: props.ttl || 300,
|
|
105
93
|
tags: props.tags ?? {
|
|
106
94
|
environment: scope.props.stage,
|
|
107
95
|
},
|
|
@@ -111,5 +99,27 @@ class AzureDnsManager {
|
|
|
111
99
|
(0, utils_1.createAzureTfOutput)(`${id}-dnsCnameRecordId`, scope, dnsCnameRecord.id);
|
|
112
100
|
return dnsCnameRecord;
|
|
113
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @summary Method to create a new DNS TXT Record
|
|
104
|
+
* @param id scoped id of the resource
|
|
105
|
+
* @param scope scope in which this resource is defined
|
|
106
|
+
* @param props dns txt record properties
|
|
107
|
+
* @see [CDKTF DNS TXT Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
|
|
108
|
+
*/
|
|
109
|
+
createDnsTxtRecord(id, scope, props) {
|
|
110
|
+
if (!props)
|
|
111
|
+
throw `Props undefined for ${id}`;
|
|
112
|
+
const dnsTxtRecord = new dns_txt_record_1.DnsTxtRecord(scope, `${id}-dc`, {
|
|
113
|
+
...props,
|
|
114
|
+
ttl: props.ttl || 300,
|
|
115
|
+
tags: props.tags ?? {
|
|
116
|
+
environment: scope.props.stage,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
(0, utils_1.createAzureTfOutput)(`${id}-dnsTxtRecordName`, scope, dnsTxtRecord.name);
|
|
120
|
+
(0, utils_1.createAzureTfOutput)(`${id}-dnsTxtRecordFriendlyUniqueId`, scope, dnsTxtRecord.friendlyUniqueId);
|
|
121
|
+
(0, utils_1.createAzureTfOutput)(`${id}-dnsTxtRecordId`, scope, dnsTxtRecord.id);
|
|
122
|
+
return dnsTxtRecord;
|
|
123
|
+
}
|
|
114
124
|
}
|
|
115
125
|
exports.AzureDnsManager = AzureDnsManager;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { DnsZoneConfig } from '@cdktf/provider-azurerm/lib/dns-zone';
|
|
2
2
|
import { DnsARecordConfig } from '@cdktf/provider-azurerm/lib/dns-a-record';
|
|
3
3
|
import { DnsCnameRecordConfig } from '@cdktf/provider-azurerm/lib/dns-cname-record';
|
|
4
|
+
import { DnsTxtRecordConfig } from '@cdktf/provider-azurerm/lib/dns-txt-record';
|
|
4
5
|
export interface DnsZoneProps extends DnsZoneConfig {
|
|
5
6
|
}
|
|
6
7
|
export interface DnsARecordProps extends DnsARecordConfig {
|
|
7
8
|
}
|
|
8
9
|
export interface DnsCnameRecordProps extends DnsCnameRecordConfig {
|
|
9
10
|
}
|
|
11
|
+
export interface DnsTxtRecordProps extends DnsTxtRecordConfig {
|
|
12
|
+
}
|
|
@@ -35,15 +35,13 @@ class AzureEventgridManager {
|
|
|
35
35
|
if (!props)
|
|
36
36
|
throw `Props undefined for ${id}`;
|
|
37
37
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-et-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 eventgridTopic = new eventgrid_topic_1.EventgridTopic(scope, `${id}-et`, {
|
|
45
43
|
...props,
|
|
46
|
-
name:
|
|
44
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
47
45
|
location: resourceGroup.location,
|
|
48
46
|
resourceGroupName: resourceGroup.name,
|
|
49
47
|
tags: props.tags ?? {
|
|
@@ -67,15 +65,13 @@ class AzureEventgridManager {
|
|
|
67
65
|
if (!props)
|
|
68
66
|
throw `Props undefined for ${id}`;
|
|
69
67
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-et-rg`, {
|
|
70
|
-
name: scope.props.resourceGroupName
|
|
71
|
-
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
72
|
-
: `${props.resourceGroupName}`,
|
|
68
|
+
name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
|
|
73
69
|
});
|
|
74
70
|
if (!resourceGroup)
|
|
75
71
|
throw `Resource group undefined for ${id}`;
|
|
76
72
|
const eventgridTopic = new data_azurerm_eventgrid_topic_1.DataAzurermEventgridTopic(scope, `${id}-et`, {
|
|
77
73
|
...props,
|
|
78
|
-
name:
|
|
74
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
79
75
|
resourceGroupName: resourceGroup.name,
|
|
80
76
|
});
|
|
81
77
|
(0, utils_1.createAzureTfOutput)(`${id}-eventgridTopicName`, scope, eventgridTopic.name);
|
|
@@ -96,7 +92,7 @@ class AzureEventgridManager {
|
|
|
96
92
|
throw `Props undefined for ${id}`;
|
|
97
93
|
const eventgridSubscription = new eventgrid_event_subscription_1.EventgridEventSubscription(scope, `${id}-es`, {
|
|
98
94
|
...props,
|
|
99
|
-
name:
|
|
95
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
100
96
|
eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
|
|
101
97
|
advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
|
|
102
98
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
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
|
|
4
|
-
name?: string | undefined;
|
|
3
|
+
export interface EventgridTopicProps extends EventgridTopicConfig {
|
|
5
4
|
}
|
|
6
5
|
export interface EventgridEventSubscriptionProps extends EventgridEventSubscriptionConfig {
|
|
7
6
|
}
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
92
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
97
93
|
location: resourceGroup.location,
|
|
98
94
|
parentId: resourceGroup.id,
|
|
99
95
|
body: {
|
|
@@ -33,15 +33,13 @@ class AzureKeyVaultManager {
|
|
|
33
33
|
if (!props)
|
|
34
34
|
throw `Props undefined for ${id}`;
|
|
35
35
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-kv-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 keyVault = new key_vault_1.KeyVault(scope, `${id}-kv`, {
|
|
43
41
|
...props,
|
|
44
|
-
name:
|
|
42
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
45
43
|
location: resourceGroup.location,
|
|
46
44
|
resourceGroupName: resourceGroup.name,
|
|
47
45
|
skuName: props.skuName ?? 'standard',
|
|
@@ -33,15 +33,13 @@ class AzureLogAnalyticsWorkspaceManager {
|
|
|
33
33
|
if (!props)
|
|
34
34
|
throw `Props undefined for ${id}`;
|
|
35
35
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-lw-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 logAnalyticsWorkspace = new log_analytics_workspace_1.LogAnalyticsWorkspace(scope, `${id}-lw`, {
|
|
43
41
|
...props,
|
|
44
|
-
name:
|
|
42
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
45
43
|
location: resourceGroup.location,
|
|
46
44
|
resourceGroupName: resourceGroup.name,
|
|
47
45
|
tags: props.tags ?? {
|
|
@@ -36,15 +36,13 @@ class AzureServicebusManager {
|
|
|
36
36
|
if (!props)
|
|
37
37
|
throw `Props undefined for ${id}`;
|
|
38
38
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sn-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 servicebusNamespace = new servicebus_namespace_1.ServicebusNamespace(scope, `${id}-sn`, {
|
|
46
44
|
...props,
|
|
47
|
-
name:
|
|
45
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
48
46
|
resourceGroupName: resourceGroup.name,
|
|
49
47
|
location: resourceGroup.location,
|
|
50
48
|
identity: {
|
|
@@ -72,7 +70,7 @@ class AzureServicebusManager {
|
|
|
72
70
|
throw `Props undefined for ${id}`;
|
|
73
71
|
const servicebusTopic = new servicebus_topic_1.ServicebusTopic(scope, `${id}-st`, {
|
|
74
72
|
...props,
|
|
75
|
-
name:
|
|
73
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
76
74
|
namespaceId: props.namespaceId,
|
|
77
75
|
});
|
|
78
76
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusTopicName`, scope, servicebusTopic.name);
|
|
@@ -92,7 +90,7 @@ class AzureServicebusManager {
|
|
|
92
90
|
throw `Props undefined for ${id}`;
|
|
93
91
|
const servicebusQueue = new servicebus_queue_1.ServicebusQueue(scope, `${id}-sq`, {
|
|
94
92
|
...props,
|
|
95
|
-
name:
|
|
93
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
96
94
|
namespaceId: props.namespaceId,
|
|
97
95
|
});
|
|
98
96
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusQueueName`, scope, servicebusQueue.name);
|
|
@@ -112,7 +110,7 @@ class AzureServicebusManager {
|
|
|
112
110
|
throw `Props undefined for ${id}`;
|
|
113
111
|
const servicebusSubscription = new servicebus_subscription_1.ServicebusSubscription(scope, `${id}-ss`, {
|
|
114
112
|
...props,
|
|
115
|
-
name:
|
|
113
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
116
114
|
maxDeliveryCount: props.maxDeliveryCount || 1,
|
|
117
115
|
});
|
|
118
116
|
(0, utils_1.createAzureTfOutput)(`${id}-servicebusSubscriptionName`, scope, servicebusSubscription.name);
|
|
@@ -37,9 +37,7 @@ class AzureStorageManager {
|
|
|
37
37
|
if (!props)
|
|
38
38
|
throw `Props undefined for ${id}`;
|
|
39
39
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
40
|
-
name: scope.props.resourceGroupName
|
|
41
|
-
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
42
|
-
: `${props.resourceGroupName}`,
|
|
40
|
+
name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
|
|
43
41
|
});
|
|
44
42
|
if (!resourceGroup)
|
|
45
43
|
throw `Resource group undefined for ${id}`;
|
|
@@ -70,7 +68,7 @@ class AzureStorageManager {
|
|
|
70
68
|
throw `Props undefined for ${id}`;
|
|
71
69
|
const storageContainer = new storage_container_1.StorageContainer(scope, `${id}-sc`, {
|
|
72
70
|
...props,
|
|
73
|
-
name:
|
|
71
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
74
72
|
});
|
|
75
73
|
(0, utils_1.createAzureTfOutput)(`${id}-storageContainerName`, scope, storageContainer.name);
|
|
76
74
|
(0, utils_1.createAzureTfOutput)(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId);
|
|
@@ -88,9 +86,7 @@ class AzureStorageManager {
|
|
|
88
86
|
if (!props)
|
|
89
87
|
throw `Props undefined for ${id}`;
|
|
90
88
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
|
|
91
|
-
name: scope.props.resourceGroupName
|
|
92
|
-
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
93
|
-
: `${props.resourceGroupName}`,
|
|
89
|
+
name: scope.resourceNameFormatter.format(scope.props.resourceGroupName || props.resourceGroupName, scope.props.resourceNameOptions?.resourceGroup),
|
|
94
90
|
});
|
|
95
91
|
if (!resourceGroup)
|
|
96
92
|
throw `Resource group undefined for ${id}`;
|
|
@@ -105,7 +101,7 @@ class AzureStorageManager {
|
|
|
105
101
|
});
|
|
106
102
|
const storageBlob = new storage_blob_1.StorageBlob(scope, `${id}-sb`, {
|
|
107
103
|
...props,
|
|
108
|
-
name:
|
|
104
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
109
105
|
storageAccountName: storageAccount.name,
|
|
110
106
|
storageContainerName: storageContainer.name,
|
|
111
107
|
});
|