@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.
Files changed (40) hide show
  1. package/dist/src/lib/azure/common/construct.d.ts +2 -0
  2. package/dist/src/lib/azure/common/construct.js +3 -0
  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 +7 -11
  7. package/dist/src/lib/azure/services/api-management/types.d.ts +1 -2
  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/main.d.ts +10 -1
  13. package/dist/src/lib/azure/services/dns/main.js +29 -19
  14. package/dist/src/lib/azure/services/dns/types.d.ts +3 -0
  15. package/dist/src/lib/azure/services/eventgrid/main.js +5 -9
  16. package/dist/src/lib/azure/services/eventgrid/types.d.ts +1 -2
  17. package/dist/src/lib/azure/services/function/main.js +5 -9
  18. package/dist/src/lib/azure/services/key-vault/main.js +2 -4
  19. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +2 -4
  20. package/dist/src/lib/azure/services/servicebus/main.js +5 -7
  21. package/dist/src/lib/azure/services/storage/main.js +4 -8
  22. package/package.json +1 -1
  23. package/src/lib/azure/common/construct.ts +3 -0
  24. package/src/lib/azure/common/resource-name-formatter.ts +38 -0
  25. package/src/lib/azure/common/types.ts +13 -0
  26. package/src/lib/azure/services/api-management/main.ts +13 -11
  27. package/src/lib/azure/services/api-management/types.ts +1 -3
  28. package/src/lib/azure/services/app-configuration/main.ts +4 -3
  29. package/src/lib/azure/services/app-service/main.ts +5 -4
  30. package/src/lib/azure/services/application-insights/main.ts +4 -3
  31. package/src/lib/azure/services/cosmosdb/main.ts +11 -9
  32. package/src/lib/azure/services/dns/main.ts +36 -22
  33. package/src/lib/azure/services/dns/types.ts +2 -0
  34. package/src/lib/azure/services/eventgrid/main.ts +11 -9
  35. package/src/lib/azure/services/eventgrid/types.ts +1 -3
  36. package/src/lib/azure/services/function/main.ts +11 -9
  37. package/src/lib/azure/services/key-vault/main.ts +5 -4
  38. package/src/lib/azure/services/log-analytics-workspace/main.ts +5 -4
  39. package/src/lib/azure/services/servicebus/main.ts +8 -7
  40. package/src/lib/azure/services/storage/main.ts +10 -8
@@ -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,16 +51,17 @@ 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.props.resourceGroupName
55
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
56
- : `${props.resourceGroupName}`,
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}`
60
61
 
61
62
  const apiManagement = new ApiManagement(scope, `${id}-am`, {
62
63
  ...props,
63
- name: `${props.name}-${scope.props.stage}`,
64
+ name: scope.resourceNameFormatter.format(props.name),
64
65
  resourceGroupName: resourceGroup.name,
65
66
  tags: props.tags ?? {
66
67
  environment: scope.props.stage,
@@ -69,7 +70,7 @@ export class AzureApiManagementManager {
69
70
 
70
71
  if (applicationInsightsKey) {
71
72
  new ApiManagementLogger(scope, `${id}-am-logger`, {
72
- name: `${props.name}-${scope.props.stage}`,
73
+ name: scope.resourceNameFormatter.format(props.name),
73
74
  resourceGroupName: resourceGroup.name,
74
75
  apiManagementName: apiManagement.name,
75
76
  applicationInsights: {
@@ -96,16 +97,17 @@ export class AzureApiManagementManager {
96
97
  if (!props) throw `Props undefined for ${id}`
97
98
 
98
99
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
99
- name: scope.props.resourceGroupName
100
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
101
- : `${props.resourceGroupName}`,
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 apiManagement = new DataAzurermApiManagement(scope, `${id}-am`, {
107
109
  ...props,
108
- name: `${props.name}-${scope.props.stage}`,
110
+ name: scope.resourceNameFormatter.format(props.name),
109
111
  resourceGroupName: scope.props.resourceGroupName
110
112
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
111
113
  : `${props.resourceGroupName}`,
@@ -126,7 +128,7 @@ export class AzureApiManagementManager {
126
128
 
127
129
  const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
128
130
  ...props,
129
- name: `${props.name}-${scope.props.stage}`,
131
+ name: scope.resourceNameFormatter.format(props.name),
130
132
  description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
131
133
  protocol: props.protocol || 'http',
132
134
  })
@@ -150,7 +152,7 @@ export class AzureApiManagementManager {
150
152
 
151
153
  const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
152
154
  ...props,
153
- name: `${props.name}-${scope.props.stage}`,
155
+ name: scope.resourceNameFormatter.format(props.name),
154
156
  displayName: props.displayName || props.name,
155
157
  revision: props.revision || '1',
156
158
  protocols: props.protocols || ['https'],
@@ -4,9 +4,7 @@ import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-manageme
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
6
 
7
- export interface ApiManagementProps extends Omit<ApiManagementConfig, 'name'> {
8
- name?: string | undefined
9
- }
7
+ export interface ApiManagementProps extends ApiManagementConfig {}
10
8
 
11
9
  export interface ApiManagementBackendProps extends ApiManagementBackendConfig {}
12
10
 
@@ -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.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
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.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
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.props.resourceGroupName
39
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
40
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
74
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
75
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
115
+ name: scope.resourceNameFormatter.format(props.name),
114
116
  resourceGroupName: resourceGroup.name,
115
117
  })
116
118
 
@@ -1,11 +1,11 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
- import { DataAzurermDnsZone } from '@cdktf/provider-azurerm/lib/data-azurerm-dns-zone'
3
2
  import { DnsZone } from '@cdktf/provider-azurerm/lib/dns-zone'
4
3
  import { DnsARecord } from '@cdktf/provider-azurerm/lib/dns-a-record'
5
4
  import { DnsCnameRecord } from '@cdktf/provider-azurerm/lib/dns-cname-record'
5
+ import { DnsTxtRecord } from '@cdktf/provider-azurerm/lib/dns-txt-record'
6
6
  import { CommonAzureConstruct } from '../../common'
7
7
  import { createAzureTfOutput } from '../../utils'
8
- import { DnsZoneProps, DnsARecordProps, DnsCnameRecordProps } from './types'
8
+ import { DnsZoneProps, DnsARecordProps, DnsCnameRecordProps, DnsTxtRecordProps } from './types'
9
9
 
10
10
  /**
11
11
  * @classdesc Provides operations on Azure DNS
@@ -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.props.resourceGroupName
40
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
41
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
49
+ name: scope.resourceNameFormatter.format(props.name),
49
50
  resourceGroupName: resourceGroup.name,
50
51
  tags: props.tags ?? {
51
52
  environment: scope.props.stage,
@@ -69,16 +70,10 @@ export class AzureDnsManager {
69
70
  public createDnsARecord(id: string, scope: CommonAzureConstruct, props: DnsARecordProps) {
70
71
  if (!props) throw `Props undefined for ${id}`
71
72
 
72
- const dnsZone = new DataAzurermDnsZone(scope, `${id}-da-dz`, {
73
- name: props.zoneName,
74
- resourceGroupName: props.resourceGroupName,
75
- })
76
-
77
73
  const dnsARecord = new DnsARecord(scope, `${id}-da`, {
78
74
  ...props,
79
- name: `${props.name}-${scope.props.stage}`,
80
- resourceGroupName: dnsZone.resourceGroupName,
81
- zoneName: dnsZone.name,
75
+ name: scope.resourceNameFormatter.format(props.name),
76
+ ttl: props.ttl || 300,
82
77
  tags: props.tags ?? {
83
78
  environment: scope.props.stage,
84
79
  },
@@ -101,16 +96,10 @@ export class AzureDnsManager {
101
96
  public createDnsCnameRecord(id: string, scope: CommonAzureConstruct, props: DnsCnameRecordProps) {
102
97
  if (!props) throw `Props undefined for ${id}`
103
98
 
104
- const dnsZone = new DataAzurermDnsZone(scope, `${id}-dc-dz`, {
105
- name: props.zoneName,
106
- resourceGroupName: props.resourceGroupName,
107
- })
108
-
109
99
  const dnsCnameRecord = new DnsCnameRecord(scope, `${id}-dc`, {
110
100
  ...props,
111
- name: `${props.name}-${scope.props.stage}`,
112
- resourceGroupName: dnsZone.resourceGroupName,
113
- zoneName: dnsZone.name,
101
+ name: scope.resourceNameFormatter.format(props.name),
102
+ ttl: props.ttl || 300,
114
103
  tags: props.tags ?? {
115
104
  environment: scope.props.stage,
116
105
  },
@@ -122,4 +111,29 @@ export class AzureDnsManager {
122
111
 
123
112
  return dnsCnameRecord
124
113
  }
114
+
115
+ /**
116
+ * @summary Method to create a new DNS TXT Record
117
+ * @param id scoped id of the resource
118
+ * @param scope scope in which this resource is defined
119
+ * @param props dns txt record properties
120
+ * @see [CDKTF DNS TXT Record Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/DnsCnameRecord.typescript.md}
121
+ */
122
+ public createDnsTxtRecord(id: string, scope: CommonAzureConstruct, props: DnsTxtRecordProps) {
123
+ if (!props) throw `Props undefined for ${id}`
124
+
125
+ const dnsTxtRecord = new DnsTxtRecord(scope, `${id}-dc`, {
126
+ ...props,
127
+ ttl: props.ttl || 300,
128
+ tags: props.tags ?? {
129
+ environment: scope.props.stage,
130
+ },
131
+ })
132
+
133
+ createAzureTfOutput(`${id}-dnsTxtRecordName`, scope, dnsTxtRecord.name)
134
+ createAzureTfOutput(`${id}-dnsTxtRecordFriendlyUniqueId`, scope, dnsTxtRecord.friendlyUniqueId)
135
+ createAzureTfOutput(`${id}-dnsTxtRecordId`, scope, dnsTxtRecord.id)
136
+
137
+ return dnsTxtRecord
138
+ }
125
139
  }
@@ -1,7 +1,9 @@
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
 
5
6
  export interface DnsZoneProps extends DnsZoneConfig {}
6
7
  export interface DnsARecordProps extends DnsARecordConfig {}
7
8
  export interface DnsCnameRecordProps extends DnsCnameRecordConfig {}
9
+ export interface DnsTxtRecordProps extends DnsTxtRecordConfig {}
@@ -38,16 +38,17 @@ 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.props.resourceGroupName
42
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
43
- : `${props.resourceGroupName}`,
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}`
47
48
 
48
49
  const eventgridTopic = new EventgridTopic(scope, `${id}-et`, {
49
50
  ...props,
50
- name: `${props.name}-${scope.props.stage}`,
51
+ name: scope.resourceNameFormatter.format(props.name),
51
52
  location: resourceGroup.location,
52
53
  resourceGroupName: resourceGroup.name,
53
54
  tags: props.tags ?? {
@@ -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.props.resourceGroupName
78
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
79
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
112
+ name: scope.resourceNameFormatter.format(props.name),
111
113
  eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
112
114
  advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
113
115
  })
@@ -1,8 +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
3
 
4
- export interface EventgridTopicProps extends Omit<EventgridTopicConfig, 'name'> {
5
- name?: string | undefined
6
- }
4
+ export interface EventgridTopicProps extends EventgridTopicConfig {}
7
5
 
8
6
  export interface EventgridEventSubscriptionProps extends EventgridEventSubscriptionConfig {}
@@ -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.props.resourceGroupName
40
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
41
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
100
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
101
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
37
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
45
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
46
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
41
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
42
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
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.props.resourceGroupName
99
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
100
- : `${props.resourceGroupName}`,
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: `${props.name}-${scope.props.stage}`,
120
+ name: scope.resourceNameFormatter.format(props.name),
119
121
  storageAccountName: storageAccount.name,
120
122
  storageContainerName: storageContainer.name,
121
123
  })