@gradientedge/cdk-utils 9.39.2 → 9.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/src/lib/azure/common/construct.d.ts +11 -7
  2. package/dist/src/lib/azure/common/construct.js +17 -10
  3. package/dist/src/lib/azure/common/resource-name-formatter.d.ts +14 -0
  4. package/dist/src/lib/azure/common/resource-name-formatter.js +32 -0
  5. package/dist/src/lib/azure/common/types.d.ts +14 -0
  6. package/dist/src/lib/azure/services/api-management/main.js +1 -3
  7. package/dist/src/lib/azure/services/api-management/types.d.ts +2 -1
  8. package/dist/src/lib/azure/services/app-configuration/main.js +1 -3
  9. package/dist/src/lib/azure/services/app-service/main.js +2 -4
  10. package/dist/src/lib/azure/services/application-insights/main.js +1 -3
  11. package/dist/src/lib/azure/services/cosmosdb/main.js +5 -9
  12. package/dist/src/lib/azure/services/dns/index.d.ts +2 -0
  13. package/dist/src/lib/azure/services/dns/index.js +18 -0
  14. package/dist/src/lib/azure/services/dns/main.d.ts +48 -0
  15. package/dist/src/lib/azure/services/dns/main.js +113 -0
  16. package/dist/src/lib/azure/services/dns/types.d.ts +9 -0
  17. package/dist/src/lib/azure/services/dns/types.js +2 -0
  18. package/dist/src/lib/azure/services/eventgrid/main.d.ts +9 -0
  19. package/dist/src/lib/azure/services/eventgrid/main.js +30 -4
  20. package/dist/src/lib/azure/services/eventgrid/types.d.ts +2 -1
  21. package/dist/src/lib/azure/services/function/main.js +5 -9
  22. package/dist/src/lib/azure/services/index.d.ts +2 -0
  23. package/dist/src/lib/azure/services/index.js +2 -0
  24. package/dist/src/lib/azure/services/key-vault/main.js +2 -4
  25. package/dist/src/lib/azure/services/log-analytics-workspace/index.d.ts +2 -0
  26. package/dist/src/lib/azure/services/log-analytics-workspace/index.js +18 -0
  27. package/dist/src/lib/azure/services/log-analytics-workspace/main.d.ts +30 -0
  28. package/dist/src/lib/azure/services/log-analytics-workspace/main.js +55 -0
  29. package/dist/src/lib/azure/services/log-analytics-workspace/types.d.ts +3 -0
  30. package/dist/src/lib/azure/services/log-analytics-workspace/types.js +2 -0
  31. package/dist/src/lib/azure/services/servicebus/main.js +5 -7
  32. package/dist/src/lib/azure/services/storage/main.js +4 -8
  33. package/package.json +1 -1
  34. package/src/lib/azure/common/construct.ts +20 -10
  35. package/src/lib/azure/common/resource-name-formatter.ts +38 -0
  36. package/src/lib/azure/common/types.ts +13 -0
  37. package/src/lib/azure/services/api-management/main.ts +4 -3
  38. package/src/lib/azure/services/api-management/types.ts +3 -1
  39. package/src/lib/azure/services/app-configuration/main.ts +4 -3
  40. package/src/lib/azure/services/app-service/main.ts +5 -4
  41. package/src/lib/azure/services/application-insights/main.ts +4 -3
  42. package/src/lib/azure/services/cosmosdb/main.ts +11 -9
  43. package/src/lib/azure/services/dns/index.ts +2 -0
  44. package/src/lib/azure/services/dns/main.ts +126 -0
  45. package/src/lib/azure/services/dns/types.ts +7 -0
  46. package/src/lib/azure/services/eventgrid/main.ts +43 -4
  47. package/src/lib/azure/services/eventgrid/types.ts +4 -1
  48. package/src/lib/azure/services/function/main.ts +11 -9
  49. package/src/lib/azure/services/index.ts +2 -0
  50. package/src/lib/azure/services/key-vault/main.ts +5 -4
  51. package/src/lib/azure/services/log-analytics-workspace/index.ts +2 -0
  52. package/src/lib/azure/services/log-analytics-workspace/main.ts +60 -0
  53. package/src/lib/azure/services/log-analytics-workspace/types.ts +3 -0
  54. package/src/lib/azure/services/servicebus/main.ts +8 -7
  55. package/src/lib/azure/services/storage/main.ts +10 -8
@@ -1,4 +1,8 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import {
3
+ DataAzurermEventgridTopic,
4
+ DataAzurermEventgridTopicConfig,
5
+ } from '@cdktf/provider-azurerm/lib/data-azurerm-eventgrid-topic'
2
6
  import { EventgridTopic } from '@cdktf/provider-azurerm/lib/eventgrid-topic'
3
7
  import { EventgridEventSubscription } from '@cdktf/provider-azurerm/lib/eventgrid-event-subscription'
4
8
  import { CommonAzureConstruct } from '../../common'
@@ -34,9 +38,10 @@ export class AzureEventgridManager {
34
38
  if (!props) throw `Props undefined for ${id}`
35
39
 
36
40
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-et-rg`, {
37
- name: scope.props.resourceGroupName
38
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
39
- : `${props.resourceGroupName}`,
41
+ name: scope.resourceNameFormatter.format(
42
+ scope.props.resourceGroupName || props.resourceGroupName,
43
+ scope.props.resourceNameOptions?.resourceGroup
44
+ ),
40
45
  })
41
46
 
42
47
  if (!resourceGroup) throw `Resource group undefined for ${id}`
@@ -54,6 +59,40 @@ export class AzureEventgridManager {
54
59
  createAzureTfOutput(`${id}-eventgridTopicName`, scope, eventgridTopic.name)
55
60
  createAzureTfOutput(`${id}-eventgridTopicFriendlyUniqueId`, scope, eventgridTopic.friendlyUniqueId)
56
61
  createAzureTfOutput(`${id}-eventgridTopicId`, scope, eventgridTopic.id)
62
+ createAzureTfOutput(`${id}-eventgridTopicEndpoint`, scope, eventgridTopic.endpoint)
63
+
64
+ return eventgridTopic
65
+ }
66
+
67
+ /**
68
+ * @summary Method to resolve an existing eventgrid topic
69
+ * @param id scoped id of the resource
70
+ * @param scope scope in which this resource is defined
71
+ * @param props eventgrid topic properties
72
+ * @see [CDKTF Eventgrid Topic Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/eventgridTopic.typescript.md}
73
+ */
74
+ public resolveEventgridTopic(id: string, scope: CommonAzureConstruct, props: DataAzurermEventgridTopicConfig) {
75
+ if (!props) throw `Props undefined for ${id}`
76
+
77
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-et-rg`, {
78
+ name: scope.resourceNameFormatter.format(
79
+ scope.props.resourceGroupName || props.resourceGroupName,
80
+ scope.props.resourceNameOptions?.resourceGroup
81
+ ),
82
+ })
83
+
84
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
85
+
86
+ const eventgridTopic = new DataAzurermEventgridTopic(scope, `${id}-et`, {
87
+ ...props,
88
+ name: scope.resourceNameFormatter.format(props.name),
89
+ resourceGroupName: resourceGroup.name,
90
+ })
91
+
92
+ createAzureTfOutput(`${id}-eventgridTopicName`, scope, eventgridTopic.name)
93
+ createAzureTfOutput(`${id}-eventgridTopicFriendlyUniqueId`, scope, eventgridTopic.friendlyUniqueId)
94
+ createAzureTfOutput(`${id}-eventgridTopicId`, scope, eventgridTopic.id)
95
+ createAzureTfOutput(`${id}-eventgridTopicEndpoint`, scope, eventgridTopic.endpoint)
57
96
 
58
97
  return eventgridTopic
59
98
  }
@@ -70,7 +109,7 @@ export class AzureEventgridManager {
70
109
 
71
110
  const eventgridSubscription = new EventgridEventSubscription(scope, `${id}-es`, {
72
111
  ...props,
73
- name: `${props.name}-${scope.props.stage}`,
112
+ name: scope.resourceNameFormatter.format(props.name),
74
113
  eventDeliverySchema: props.eventDeliverySchema || 'CloudEventSchemaV1_0',
75
114
  advancedFilteringOnArraysEnabled: props.advancedFilteringOnArraysEnabled || true,
76
115
  })
@@ -1,5 +1,8 @@
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 EventgridTopicConfig {}
4
+ export interface EventgridTopicProps extends Omit<EventgridTopicConfig, 'name'> {
5
+ name?: string | undefined
6
+ }
7
+
5
8
  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
 
@@ -3,9 +3,11 @@ export * from './app-configuration'
3
3
  export * from './app-service'
4
4
  export * from './application-insights'
5
5
  export * from './cosmosdb'
6
+ export * from './dns'
6
7
  export * from './eventgrid'
7
8
  export * from './function'
8
9
  export * from './key-vault'
10
+ export * from './log-analytics-workspace'
9
11
  export * from './resource-group'
10
12
  export * from './servicebus'
11
13
  export * from './storage'
@@ -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',
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -0,0 +1,60 @@
1
+ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import { LogAnalyticsWorkspace } from '@cdktf/provider-azurerm/lib/log-analytics-workspace'
3
+ import { CommonAzureConstruct } from '../../common'
4
+ import { createAzureTfOutput } from '../../utils'
5
+ import { LogAnalyticsWorkspaceProps } from './types'
6
+
7
+ /**
8
+ * @classdesc Provides operations on Azure Log Analytics Workspace
9
+ * - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
10
+ * - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
11
+ * @example
12
+ * ```
13
+ * import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
14
+ *
15
+ * class CustomConstruct extends CommonAzureConstruct {
16
+ * constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
17
+ * super(parent, id, props)
18
+ * this.props = props
19
+ * this.LogAnalyticWorkspaceManager.createLogAnalyticsWorkspace('MyLogAnalyticsWorkspace', this, props)
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export class AzureLogAnalyticsWorkspaceManager {
25
+ /**
26
+ * @summary Method to create a new cosmosdb account
27
+ * @param id scoped id of the resource
28
+ * @param scope scope in which this resource is defined
29
+ * @param props cosmosdb account properties
30
+ * @see [CDKTF CosmosDb Account Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/logAnalyticsWorkspace.typescript.md}
31
+ */
32
+ public createLogAnalyticsWorkspace(id: string, scope: CommonAzureConstruct, props: LogAnalyticsWorkspaceProps) {
33
+ if (!props) throw `Props undefined for ${id}`
34
+
35
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-lw-rg`, {
36
+ name: scope.resourceNameFormatter.format(
37
+ scope.props.resourceGroupName || props.resourceGroupName,
38
+ scope.props.resourceNameOptions?.resourceGroup
39
+ ),
40
+ })
41
+
42
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
43
+
44
+ const logAnalyticsWorkspace = new LogAnalyticsWorkspace(scope, `${id}-lw`, {
45
+ ...props,
46
+ name: scope.resourceNameFormatter.format(props.name),
47
+ location: resourceGroup.location,
48
+ resourceGroupName: resourceGroup.name,
49
+ tags: props.tags ?? {
50
+ environment: scope.props.stage,
51
+ },
52
+ })
53
+
54
+ createAzureTfOutput(`${id}-logAnalyticsWorkspaceName`, scope, logAnalyticsWorkspace.name)
55
+ createAzureTfOutput(`${id}-logAnalyticsWorkspaceFriendlyUniqueId`, scope, logAnalyticsWorkspace.friendlyUniqueId)
56
+ createAzureTfOutput(`${id}-logAnalyticsWorkspaceId`, scope, logAnalyticsWorkspace.id)
57
+
58
+ return logAnalyticsWorkspace
59
+ }
60
+ }
@@ -0,0 +1,3 @@
1
+ import { LogAnalyticsWorkspaceConfig } from '@cdktf/provider-azurerm/lib/log-analytics-workspace'
2
+
3
+ export interface LogAnalyticsWorkspaceProps extends LogAnalyticsWorkspaceConfig {}
@@ -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
  })