@gradientedge/cdk-utils 9.40.0 → 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.
- 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 +1 -3
- 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.js +4 -6
- package/dist/src/lib/azure/services/eventgrid/main.js +4 -8
- 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 +4 -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 +7 -6
- package/src/lib/azure/services/eventgrid/main.ts +10 -8
- 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,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}`;
|
|
@@ -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);
|
|
@@ -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,
|
|
@@ -71,7 +69,7 @@ class AzureDnsManager {
|
|
|
71
69
|
});
|
|
72
70
|
const dnsARecord = new dns_a_record_1.DnsARecord(scope, `${id}-da`, {
|
|
73
71
|
...props,
|
|
74
|
-
name:
|
|
72
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
75
73
|
resourceGroupName: dnsZone.resourceGroupName,
|
|
76
74
|
zoneName: dnsZone.name,
|
|
77
75
|
tags: props.tags ?? {
|
|
@@ -99,7 +97,7 @@ class AzureDnsManager {
|
|
|
99
97
|
});
|
|
100
98
|
const dnsCnameRecord = new dns_cname_record_1.DnsCnameRecord(scope, `${id}-dc`, {
|
|
101
99
|
...props,
|
|
102
|
-
name:
|
|
100
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
103
101
|
resourceGroupName: dnsZone.resourceGroupName,
|
|
104
102
|
zoneName: dnsZone.name,
|
|
105
103
|
tags: props.tags ?? {
|
|
@@ -35,9 +35,7 @@ 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}`;
|
|
@@ -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
|
});
|
|
@@ -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
|
});
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
} from '../services'
|
|
22
22
|
import { CommonAzureStackProps } from './types'
|
|
23
23
|
import { AzureRemoteBackend } from './constants'
|
|
24
|
+
import { AzureResourceNameFormatter } from './resource-name-formatter'
|
|
24
25
|
|
|
25
26
|
export class CommonAzureConstruct extends TerraformStack {
|
|
26
27
|
declare props: CommonAzureStackProps
|
|
@@ -37,6 +38,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
37
38
|
keyVaultManager: AzureKeyVaultManager
|
|
38
39
|
logAnalyticsWorkspaceManager: AzureLogAnalyticsWorkspaceManager
|
|
39
40
|
resourceGroupManager: AzureResourceGroupManager
|
|
41
|
+
resourceNameFormatter: AzureResourceNameFormatter
|
|
40
42
|
servicebusManager: AzureServicebusManager
|
|
41
43
|
storageManager: AzureStorageManager
|
|
42
44
|
tenantId: string
|
|
@@ -57,6 +59,7 @@ export class CommonAzureConstruct extends TerraformStack {
|
|
|
57
59
|
this.keyVaultManager = new AzureKeyVaultManager()
|
|
58
60
|
this.logAnalyticsWorkspaceManager = new AzureLogAnalyticsWorkspaceManager()
|
|
59
61
|
this.resourceGroupManager = new AzureResourceGroupManager()
|
|
62
|
+
this.resourceNameFormatter = new AzureResourceNameFormatter(this, `${id}-rnf`, props)
|
|
60
63
|
this.servicebusManager = new AzureServicebusManager()
|
|
61
64
|
this.storageManager = new AzureStorageManager()
|
|
62
65
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Construct } from 'constructs'
|
|
2
|
+
import { AzureResourceNameFormatterProps } from './types'
|
|
3
|
+
import { CommonAzureStackProps } from './types'
|
|
4
|
+
|
|
5
|
+
export class AzureResourceNameFormatter extends Construct {
|
|
6
|
+
props: CommonAzureStackProps
|
|
7
|
+
|
|
8
|
+
constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
9
|
+
super(parent, id)
|
|
10
|
+
this.props = props
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @summary Helper method to format azure resource name based on the provided options
|
|
15
|
+
* @param resourceName The azure resource name to format
|
|
16
|
+
* @param options Options to control the formatting of the resource name
|
|
17
|
+
* @returns The formatted Azure-compliant resource name
|
|
18
|
+
*/
|
|
19
|
+
public format(resourceName: string, options?: AzureResourceNameFormatterProps) {
|
|
20
|
+
const azureResourceNameElements = []
|
|
21
|
+
|
|
22
|
+
if (!options?.exclude) {
|
|
23
|
+
azureResourceNameElements.push(options?.globalPrefix ? this.props.globalPrefix : undefined)
|
|
24
|
+
azureResourceNameElements.push(options?.prefix ?? this.props.resourcePrefix)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
azureResourceNameElements.push(resourceName)
|
|
28
|
+
|
|
29
|
+
if (!options?.exclude) {
|
|
30
|
+
azureResourceNameElements.push(options?.suffix ?? this.props.resourceSuffix)
|
|
31
|
+
azureResourceNameElements.push(options?.globalSuffix ? this.props.globalSuffix : undefined)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
azureResourceNameElements.push(this.props.stage)
|
|
35
|
+
|
|
36
|
+
return azureResourceNameElements.filter(Boolean).join('-')
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -8,8 +8,21 @@ import { AzurermBackendConfig } from 'cdktf'
|
|
|
8
8
|
export interface CommonAzureStackProps extends BaseProps, AzurermProviderConfig {
|
|
9
9
|
resourceGroupName?: string
|
|
10
10
|
remoteBackend?: AzureRemoteBackendProps
|
|
11
|
+
globalPrefix?: string
|
|
12
|
+
globalSuffix?: string
|
|
13
|
+
resourcePrefix?: string
|
|
14
|
+
resourceSuffix?: string
|
|
15
|
+
resourceNameOptions?: { [key: string]: AzureResourceNameFormatterProps }
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export interface AzureRemoteBackendProps extends AzurermBackendConfig {
|
|
14
19
|
type: AzureRemoteBackend
|
|
15
20
|
}
|
|
21
|
+
|
|
22
|
+
export interface AzureResourceNameFormatterProps {
|
|
23
|
+
exclude?: boolean
|
|
24
|
+
globalPrefix?: boolean
|
|
25
|
+
globalSuffix?: boolean
|
|
26
|
+
prefix?: string
|
|
27
|
+
suffix?: string
|
|
28
|
+
}
|
|
@@ -51,9 +51,10 @@ export class AzureApiManagementManager {
|
|
|
51
51
|
if (!props) throw `Props undefined for ${id}`
|
|
52
52
|
|
|
53
53
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
54
|
-
name: scope.
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
name: scope.resourceNameFormatter.format(
|
|
55
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
56
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
57
|
+
),
|
|
57
58
|
})
|
|
58
59
|
|
|
59
60
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -33,9 +33,10 @@ export class AzureAppConfigurationManager {
|
|
|
33
33
|
if (!props) throw `Props undefined for ${id}`
|
|
34
34
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
36
|
-
name: scope.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
name: scope.resourceNameFormatter.format(
|
|
37
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
38
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
39
|
+
),
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -33,16 +33,17 @@ export class AzureAppServiceManager {
|
|
|
33
33
|
if (!props) throw `Props undefined for ${id}`
|
|
34
34
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
36
|
-
name: scope.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
name: scope.resourceNameFormatter.format(
|
|
37
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
38
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
39
|
+
),
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
42
43
|
|
|
43
44
|
const appServicePlan = new ServicePlan(scope, `${id}-am`, {
|
|
44
45
|
...props,
|
|
45
|
-
name:
|
|
46
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
46
47
|
resourceGroupName: resourceGroup.name,
|
|
47
48
|
tags: props.tags ?? {
|
|
48
49
|
environment: scope.props.stage,
|
|
@@ -33,9 +33,10 @@ export class AzureApplicationInsightsManager {
|
|
|
33
33
|
if (!props) throw `Props undefined for ${id}`
|
|
34
34
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
36
|
-
name: scope.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
name: scope.resourceNameFormatter.format(
|
|
37
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
38
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
39
|
+
),
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -35,16 +35,17 @@ export class AzureCosmosDbManager {
|
|
|
35
35
|
if (!props) throw `Props undefined for ${id}`
|
|
36
36
|
|
|
37
37
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-ca-rg`, {
|
|
38
|
-
name: scope.
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
name: scope.resourceNameFormatter.format(
|
|
39
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
40
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
41
|
+
),
|
|
41
42
|
})
|
|
42
43
|
|
|
43
44
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
44
45
|
|
|
45
46
|
const cosmosdbAccount = new CosmosdbAccount(scope, `${id}-ca`, {
|
|
46
47
|
...props,
|
|
47
|
-
name:
|
|
48
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
48
49
|
location: resourceGroup.location,
|
|
49
50
|
resourceGroupName: resourceGroup.name,
|
|
50
51
|
tags: props.tags ?? {
|
|
@@ -70,16 +71,17 @@ export class AzureCosmosDbManager {
|
|
|
70
71
|
if (!props) throw `Props undefined for ${id}`
|
|
71
72
|
|
|
72
73
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-cd-rg`, {
|
|
73
|
-
name: scope.
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
name: scope.resourceNameFormatter.format(
|
|
75
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
76
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
77
|
+
),
|
|
76
78
|
})
|
|
77
79
|
|
|
78
80
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
79
81
|
|
|
80
82
|
const cosmosdbDatatbase = new CosmosdbSqlDatabase(scope, `${id}-cd`, {
|
|
81
83
|
...props,
|
|
82
|
-
name:
|
|
84
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
83
85
|
resourceGroupName: resourceGroup.name,
|
|
84
86
|
})
|
|
85
87
|
|
|
@@ -110,7 +112,7 @@ export class AzureCosmosDbManager {
|
|
|
110
112
|
|
|
111
113
|
const cosmosdbContainer = new CosmosdbSqlContainer(scope, `${id}-cc`, {
|
|
112
114
|
...props,
|
|
113
|
-
name:
|
|
115
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
114
116
|
resourceGroupName: resourceGroup.name,
|
|
115
117
|
})
|
|
116
118
|
|
|
@@ -36,16 +36,17 @@ export class AzureDnsManager {
|
|
|
36
36
|
if (!props) throw `Props undefined for ${id}`
|
|
37
37
|
|
|
38
38
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
39
|
-
name: scope.
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
name: scope.resourceNameFormatter.format(
|
|
40
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
41
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
42
|
+
),
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
45
46
|
|
|
46
47
|
const dnsZone = new DnsZone(scope, `${id}-dz`, {
|
|
47
48
|
...props,
|
|
48
|
-
name:
|
|
49
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
49
50
|
resourceGroupName: resourceGroup.name,
|
|
50
51
|
tags: props.tags ?? {
|
|
51
52
|
environment: scope.props.stage,
|
|
@@ -76,7 +77,7 @@ export class AzureDnsManager {
|
|
|
76
77
|
|
|
77
78
|
const dnsARecord = new DnsARecord(scope, `${id}-da`, {
|
|
78
79
|
...props,
|
|
79
|
-
name:
|
|
80
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
80
81
|
resourceGroupName: dnsZone.resourceGroupName,
|
|
81
82
|
zoneName: dnsZone.name,
|
|
82
83
|
tags: props.tags ?? {
|
|
@@ -108,7 +109,7 @@ export class AzureDnsManager {
|
|
|
108
109
|
|
|
109
110
|
const dnsCnameRecord = new DnsCnameRecord(scope, `${id}-dc`, {
|
|
110
111
|
...props,
|
|
111
|
-
name:
|
|
112
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
112
113
|
resourceGroupName: dnsZone.resourceGroupName,
|
|
113
114
|
zoneName: dnsZone.name,
|
|
114
115
|
tags: props.tags ?? {
|
|
@@ -38,9 +38,10 @@ export class AzureEventgridManager {
|
|
|
38
38
|
if (!props) throw `Props undefined for ${id}`
|
|
39
39
|
|
|
40
40
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-et-rg`, {
|
|
41
|
-
name: scope.
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
name: scope.resourceNameFormatter.format(
|
|
42
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
43
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
44
|
+
),
|
|
44
45
|
})
|
|
45
46
|
|
|
46
47
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -74,16 +75,17 @@ export class AzureEventgridManager {
|
|
|
74
75
|
if (!props) throw `Props undefined for ${id}`
|
|
75
76
|
|
|
76
77
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-et-rg`, {
|
|
77
|
-
name: scope.
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
name: scope.resourceNameFormatter.format(
|
|
79
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
80
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
81
|
+
),
|
|
80
82
|
})
|
|
81
83
|
|
|
82
84
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
83
85
|
|
|
84
86
|
const eventgridTopic = new DataAzurermEventgridTopic(scope, `${id}-et`, {
|
|
85
87
|
...props,
|
|
86
|
-
name:
|
|
88
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
87
89
|
resourceGroupName: resourceGroup.name,
|
|
88
90
|
})
|
|
89
91
|
|
|
@@ -107,7 +109,7 @@ export class AzureEventgridManager {
|
|
|
107
109
|
|
|
108
110
|
const eventgridSubscription = new EventgridEventSubscription(scope, `${id}-es`, {
|
|
109
111
|
...props,
|
|
110
|
-
name:
|
|
112
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
111
113
|
eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
|
|
112
114
|
advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
|
|
113
115
|
})
|
|
@@ -36,16 +36,17 @@ export class AzureFunctionManager {
|
|
|
36
36
|
if (!props) throw `Props undefined for ${id}`
|
|
37
37
|
|
|
38
38
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
|
|
39
|
-
name: scope.
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
name: scope.resourceNameFormatter.format(
|
|
40
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
41
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
42
|
+
),
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
45
46
|
|
|
46
47
|
const functionApp = new LinuxFunctionApp(scope, `${id}-fa`, {
|
|
47
48
|
...props,
|
|
48
|
-
name:
|
|
49
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
49
50
|
resourceGroupName: resourceGroup.name,
|
|
50
51
|
tags: props.tags ?? {
|
|
51
52
|
environment: scope.props.stage,
|
|
@@ -71,7 +72,7 @@ export class AzureFunctionManager {
|
|
|
71
72
|
|
|
72
73
|
const functionAppFunction = new FunctionAppFunction(scope, `${id}-fc`, {
|
|
73
74
|
...props,
|
|
74
|
-
name:
|
|
75
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
75
76
|
configJson: JSON.stringify(props.configJson || {}),
|
|
76
77
|
})
|
|
77
78
|
|
|
@@ -96,16 +97,17 @@ export class AzureFunctionManager {
|
|
|
96
97
|
if (!props) throw `Props undefined for ${id}`
|
|
97
98
|
|
|
98
99
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
|
|
99
|
-
name: scope.
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
name: scope.resourceNameFormatter.format(
|
|
101
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
102
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
103
|
+
),
|
|
102
104
|
})
|
|
103
105
|
|
|
104
106
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
105
107
|
|
|
106
108
|
const functionApp = new Resource(scope, `${id}-fa`, {
|
|
107
109
|
type: 'Microsoft.Web/sites@2024-04-01',
|
|
108
|
-
name:
|
|
110
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
109
111
|
location: resourceGroup.location,
|
|
110
112
|
parentId: resourceGroup.id,
|
|
111
113
|
|
|
@@ -33,16 +33,17 @@ export class AzureKeyVaultManager {
|
|
|
33
33
|
if (!props) throw `Props undefined for ${id}`
|
|
34
34
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-kv-rg`, {
|
|
36
|
-
name: scope.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
name: scope.resourceNameFormatter.format(
|
|
37
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
38
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
39
|
+
),
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
42
43
|
|
|
43
44
|
const keyVault = new KeyVault(scope, `${id}-kv`, {
|
|
44
45
|
...props,
|
|
45
|
-
name:
|
|
46
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
46
47
|
location: resourceGroup.location,
|
|
47
48
|
resourceGroupName: resourceGroup.name,
|
|
48
49
|
skuName: props.skuName ?? 'standard',
|
|
@@ -33,16 +33,17 @@ export class AzureLogAnalyticsWorkspaceManager {
|
|
|
33
33
|
if (!props) throw `Props undefined for ${id}`
|
|
34
34
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-lw-rg`, {
|
|
36
|
-
name: scope.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
name: scope.resourceNameFormatter.format(
|
|
37
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
38
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
39
|
+
),
|
|
39
40
|
})
|
|
40
41
|
|
|
41
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
42
43
|
|
|
43
44
|
const logAnalyticsWorkspace = new LogAnalyticsWorkspace(scope, `${id}-lw`, {
|
|
44
45
|
...props,
|
|
45
|
-
name:
|
|
46
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
46
47
|
location: resourceGroup.location,
|
|
47
48
|
resourceGroupName: resourceGroup.name,
|
|
48
49
|
tags: props.tags ?? {
|
|
@@ -41,16 +41,17 @@ export class AzureServicebusManager {
|
|
|
41
41
|
if (!props) throw `Props undefined for ${id}`
|
|
42
42
|
|
|
43
43
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sn-rg`, {
|
|
44
|
-
name: scope.
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
name: scope.resourceNameFormatter.format(
|
|
45
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
46
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
47
|
+
),
|
|
47
48
|
})
|
|
48
49
|
|
|
49
50
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
50
51
|
|
|
51
52
|
const servicebusNamespace = new ServicebusNamespace(scope, `${id}-sn`, {
|
|
52
53
|
...props,
|
|
53
|
-
name:
|
|
54
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
54
55
|
resourceGroupName: resourceGroup.name,
|
|
55
56
|
location: resourceGroup.location,
|
|
56
57
|
identity: {
|
|
@@ -81,7 +82,7 @@ export class AzureServicebusManager {
|
|
|
81
82
|
|
|
82
83
|
const servicebusTopic = new ServicebusTopic(scope, `${id}-st`, {
|
|
83
84
|
...props,
|
|
84
|
-
name:
|
|
85
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
85
86
|
namespaceId: props.namespaceId,
|
|
86
87
|
})
|
|
87
88
|
|
|
@@ -104,7 +105,7 @@ export class AzureServicebusManager {
|
|
|
104
105
|
|
|
105
106
|
const servicebusQueue = new ServicebusQueue(scope, `${id}-sq`, {
|
|
106
107
|
...props,
|
|
107
|
-
name:
|
|
108
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
108
109
|
namespaceId: props.namespaceId,
|
|
109
110
|
})
|
|
110
111
|
|
|
@@ -127,7 +128,7 @@ export class AzureServicebusManager {
|
|
|
127
128
|
|
|
128
129
|
const servicebusSubscription = new ServicebusSubscription(scope, `${id}-ss`, {
|
|
129
130
|
...props,
|
|
130
|
-
name:
|
|
131
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
131
132
|
maxDeliveryCount: props.maxDeliveryCount || 1,
|
|
132
133
|
})
|
|
133
134
|
|
|
@@ -37,9 +37,10 @@ export class AzureStorageManager {
|
|
|
37
37
|
if (!props) throw `Props undefined for ${id}`
|
|
38
38
|
|
|
39
39
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
40
|
-
name: scope.
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
name: scope.resourceNameFormatter.format(
|
|
41
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
42
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
43
|
+
),
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -74,7 +75,7 @@ export class AzureStorageManager {
|
|
|
74
75
|
|
|
75
76
|
const storageContainer = new StorageContainer(scope, `${id}-sc`, {
|
|
76
77
|
...props,
|
|
77
|
-
name:
|
|
78
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
78
79
|
})
|
|
79
80
|
|
|
80
81
|
createAzureTfOutput(`${id}-storageContainerName`, scope, storageContainer.name)
|
|
@@ -95,9 +96,10 @@ export class AzureStorageManager {
|
|
|
95
96
|
if (!props) throw `Props undefined for ${id}`
|
|
96
97
|
|
|
97
98
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
|
|
98
|
-
name: scope.
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
name: scope.resourceNameFormatter.format(
|
|
100
|
+
scope.props.resourceGroupName || props.resourceGroupName,
|
|
101
|
+
scope.props.resourceNameOptions?.resourceGroup
|
|
102
|
+
),
|
|
101
103
|
})
|
|
102
104
|
|
|
103
105
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -115,7 +117,7 @@ export class AzureStorageManager {
|
|
|
115
117
|
|
|
116
118
|
const storageBlob = new StorageBlob(scope, `${id}-sb`, {
|
|
117
119
|
...props,
|
|
118
|
-
name:
|
|
120
|
+
name: scope.resourceNameFormatter.format(props.name),
|
|
119
121
|
storageAccountName: storageAccount.name,
|
|
120
122
|
storageContainerName: storageContainer.name,
|
|
121
123
|
})
|