@gradientedge/cdk-utils 9.33.0 → 9.35.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 (46) hide show
  1. package/dist/src/lib/azure/common/construct.d.ts +5 -2
  2. package/dist/src/lib/azure/common/construct.js +8 -2
  3. package/dist/src/lib/azure/services/api-management/main.d.ts +30 -2
  4. package/dist/src/lib/azure/services/api-management/main.js +115 -2
  5. package/dist/src/lib/azure/services/api-management/types.d.ts +14 -0
  6. package/dist/src/lib/azure/services/app-configuration/index.d.ts +2 -0
  7. package/dist/src/lib/azure/services/app-configuration/index.js +18 -0
  8. package/dist/src/lib/azure/services/app-configuration/main.d.ts +30 -0
  9. package/dist/src/lib/azure/services/app-configuration/main.js +56 -0
  10. package/dist/src/lib/azure/services/app-configuration/types.d.ts +3 -0
  11. package/dist/src/lib/azure/services/app-configuration/types.js +2 -0
  12. package/dist/src/lib/azure/services/app-service/index.d.ts +2 -0
  13. package/dist/src/lib/azure/services/app-service/index.js +18 -0
  14. package/dist/src/lib/azure/services/app-service/main.d.ts +30 -0
  15. package/dist/src/lib/azure/services/app-service/main.js +56 -0
  16. package/dist/src/lib/azure/services/app-service/types.d.ts +3 -0
  17. package/dist/src/lib/azure/services/app-service/types.js +2 -0
  18. package/dist/src/lib/azure/services/application-insights/index.d.ts +2 -0
  19. package/dist/src/lib/azure/services/application-insights/index.js +18 -0
  20. package/dist/src/lib/azure/services/application-insights/main.d.ts +30 -0
  21. package/dist/src/lib/azure/services/application-insights/main.js +56 -0
  22. package/dist/src/lib/azure/services/application-insights/types.d.ts +3 -0
  23. package/dist/src/lib/azure/services/application-insights/types.js +2 -0
  24. package/dist/src/lib/azure/services/function/main.d.ts +2 -2
  25. package/dist/src/lib/azure/services/function/main.js +4 -15
  26. package/dist/src/lib/azure/services/function/types.d.ts +3 -5
  27. package/dist/src/lib/azure/services/index.d.ts +3 -0
  28. package/dist/src/lib/azure/services/index.js +3 -0
  29. package/dist/src/lib/azure/services/storage/main.js +4 -4
  30. package/package.json +1 -1
  31. package/src/lib/azure/common/construct.ts +11 -2
  32. package/src/lib/azure/services/api-management/main.ts +162 -3
  33. package/src/lib/azure/services/api-management/types.ts +16 -0
  34. package/src/lib/azure/services/app-configuration/index.ts +2 -0
  35. package/src/lib/azure/services/app-configuration/main.ts +58 -0
  36. package/src/lib/azure/services/app-configuration/types.ts +3 -0
  37. package/src/lib/azure/services/app-service/index.ts +2 -0
  38. package/src/lib/azure/services/app-service/main.ts +58 -0
  39. package/src/lib/azure/services/app-service/types.ts +3 -0
  40. package/src/lib/azure/services/application-insights/index.ts +2 -0
  41. package/src/lib/azure/services/application-insights/main.ts +58 -0
  42. package/src/lib/azure/services/application-insights/types.ts +3 -0
  43. package/src/lib/azure/services/function/main.ts +4 -17
  44. package/src/lib/azure/services/function/types.ts +3 -5
  45. package/src/lib/azure/services/index.ts +3 -0
  46. package/src/lib/azure/services/storage/main.ts +4 -4
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AzureFunctionManager = void 0;
4
4
  const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
5
- const data_azurerm_function_app_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-function-app");
6
- const function_app_1 = require("@cdktf/provider-azurerm/lib/function-app");
5
+ const linux_function_app_1 = require("@cdktf/provider-azurerm/lib/linux-function-app");
7
6
  const function_app_function_1 = require("@cdktf/provider-azurerm/lib/function-app-function");
8
7
  const utils_1 = require("../../utils");
9
8
  /**
@@ -37,11 +36,11 @@ class AzureFunctionManager {
37
36
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
38
37
  name: scope.props.resourceGroupName
39
38
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
40
- : `${props.resourceGroupName}-${scope.props.stage}`,
39
+ : `${props.resourceGroupName}`,
41
40
  });
42
41
  if (!resourceGroup)
43
42
  throw `Resource group undefined for ${id}`;
44
- const functionApp = new function_app_1.FunctionApp(scope, `${id}-fa`, {
43
+ const functionApp = new linux_function_app_1.LinuxFunctionApp(scope, `${id}-fa`, {
45
44
  ...props,
46
45
  name: `${props.name}-${scope.props.stage}`,
47
46
  resourceGroupName: resourceGroup.name,
@@ -64,20 +63,10 @@ class AzureFunctionManager {
64
63
  createFunction(id, scope, props) {
65
64
  if (!props)
66
65
  throw `Props undefined for ${id}`;
67
- const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
68
- name: scope.props.resourceGroupName
69
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
70
- : `${props.resourceGroupName}-${scope.props.stage}`,
71
- });
72
- if (!resourceGroup)
73
- throw `Resource group undefined for ${id}`;
74
- const storageAccount = new data_azurerm_function_app_1.DataAzurermFunctionApp(scope, `${id}-sa`, {
75
- name: `${props.functionAppName}-${scope.props.stage}`,
76
- resourceGroupName: resourceGroup.name,
77
- });
78
66
  const functionAppFunction = new function_app_function_1.FunctionAppFunction(scope, `${id}-fc`, {
79
67
  ...props,
80
68
  name: `${props.name}-${scope.props.stage}`,
69
+ configJson: JSON.stringify(props.configJson || {}),
81
70
  });
82
71
  (0, utils_1.createAzureTfOutput)(`${id}-functionName`, scope, functionAppFunction.name);
83
72
  (0, utils_1.createAzureTfOutput)(`${id}-functionFriendlyUniqueId`, scope, functionAppFunction.friendlyUniqueId);
@@ -1,8 +1,6 @@
1
- import { FunctionAppConfig } from '@cdktf/provider-azurerm/lib/function-app';
1
+ import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app';
2
2
  import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function';
3
- import { BaseAzureConfigProps } from '../../types';
4
- export interface FunctionAppProps extends FunctionAppConfig {
3
+ export interface FunctionAppProps extends LinuxFunctionAppConfig {
5
4
  }
6
- export interface FunctionProps extends BaseAzureConfigProps, FunctionAppFunctionConfig {
7
- functionAppName: string;
5
+ export interface FunctionProps extends FunctionAppFunctionConfig {
8
6
  }
@@ -1,4 +1,7 @@
1
1
  export * from './api-management';
2
+ export * from './app-configuration';
3
+ export * from './app-service';
4
+ export * from './application-insights';
2
5
  export * from './function';
3
6
  export * from './key-vault';
4
7
  export * from './resource-group';
@@ -15,6 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./api-management"), exports);
18
+ __exportStar(require("./app-configuration"), exports);
19
+ __exportStar(require("./app-service"), exports);
20
+ __exportStar(require("./application-insights"), exports);
18
21
  __exportStar(require("./function"), exports);
19
22
  __exportStar(require("./key-vault"), exports);
20
23
  __exportStar(require("./resource-group"), exports);
@@ -39,7 +39,7 @@ class AzureStorageManager {
39
39
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
40
40
  name: scope.props.resourceGroupName
41
41
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
42
- : `${props.resourceGroupName}-${scope.props.stage}`,
42
+ : `${props.resourceGroupName}`,
43
43
  });
44
44
  if (!resourceGroup)
45
45
  throw `Resource group undefined for ${id}`;
@@ -47,7 +47,7 @@ class AzureStorageManager {
47
47
  ...props,
48
48
  accountTier: props.accountTier ?? 'Standard',
49
49
  location: props.location ?? resourceGroup.location,
50
- name: `${props.name}-${scope.props.stage}`,
50
+ name: `${props.name}-${scope.props.stage}`.replace(/\W/g, '').toLowerCase(),
51
51
  resourceGroupName: resourceGroup.name,
52
52
  tags: props.tags ?? {
53
53
  environment: scope.props.stage,
@@ -71,7 +71,7 @@ class AzureStorageManager {
71
71
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
72
72
  name: scope.props.resourceGroupName
73
73
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
74
- : `${props.resourceGroupName}-${scope.props.stage}`,
74
+ : `${props.resourceGroupName}`,
75
75
  });
76
76
  if (!resourceGroup)
77
77
  throw `Resource group undefined for ${id}`;
@@ -102,7 +102,7 @@ class AzureStorageManager {
102
102
  const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
103
103
  name: scope.props.resourceGroupName
104
104
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
105
- : `${props.resourceGroupName}-${scope.props.stage}`,
105
+ : `${props.resourceGroupName}`,
106
106
  });
107
107
  if (!resourceGroup)
108
108
  throw `Resource group undefined for ${id}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "9.33.0",
3
+ "version": "9.35.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -9,6 +9,9 @@ import {
9
9
  AzureApiManagementManager,
10
10
  AzureFunctionManager,
11
11
  AzureResourceGroupManager,
12
+ AzureAppServiceManager,
13
+ AzureApplicationInsightsManager,
14
+ AzureAppConfigurationManager,
12
15
  } from '../services'
13
16
  import { CommonAzureStackProps } from './types'
14
17
  import { AzureRemoteBackend } from './constants'
@@ -18,7 +21,10 @@ export class CommonAzureConstruct extends TerraformStack {
18
21
  id: string
19
22
  fullyQualifiedDomainName: string
20
23
  tenantId: string
21
- apiManagementtManager: AzureApiManagementManager
24
+ apiManagementManager: AzureApiManagementManager
25
+ appServiceManager: AzureAppServiceManager
26
+ applicationInsightsManager: AzureApplicationInsightsManager
27
+ appConfigurationManager: AzureAppConfigurationManager
22
28
  functiontManager: AzureFunctionManager
23
29
  keyVaultManager: AzureKeyVaultManager
24
30
  resourceGroupManager: AzureResourceGroupManager
@@ -29,7 +35,10 @@ export class CommonAzureConstruct extends TerraformStack {
29
35
  this.props = props
30
36
  this.id = id
31
37
 
32
- this.apiManagementtManager = new AzureApiManagementManager()
38
+ this.apiManagementManager = new AzureApiManagementManager()
39
+ this.appServiceManager = new AzureAppServiceManager()
40
+ this.applicationInsightsManager = new AzureApplicationInsightsManager()
41
+ this.appConfigurationManager = new AzureAppConfigurationManager()
33
42
  this.functiontManager = new AzureFunctionManager()
34
43
  this.keyVaultManager = new AzureKeyVaultManager()
35
44
  this.resourceGroupManager = new AzureResourceGroupManager()
@@ -1,8 +1,21 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import {
3
+ DataAzurermApiManagement,
4
+ DataAzurermApiManagementConfig,
5
+ } from '@cdktf/provider-azurerm/lib/data-azurerm-api-management'
6
+ import { ApiManagementBackend } from '@cdktf/provider-azurerm/lib/api-management-backend'
2
7
  import { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management'
8
+ import { ApiManagementApi } from '@cdktf/provider-azurerm/lib/api-management-api'
9
+ import { ApiManagementApiOperation } from '@cdktf/provider-azurerm/lib/api-management-api-operation'
10
+ import { ApiManagementApiOperationPolicy } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy'
11
+ import {
12
+ ApiManagementLogger,
13
+ ApiManagementLoggerApplicationInsights,
14
+ } from '@cdktf/provider-azurerm/lib/api-management-logger'
3
15
  import { CommonAzureConstruct } from '../../common'
4
16
  import { createAzureTfOutput } from '../../utils'
5
- import { ApiManagementProps } from './types'
17
+ import { ApiManagementProps, ApiManagementBackendProps, ApiManagementApiProps } from './types'
18
+ import _ from 'lodash'
6
19
 
7
20
  /**
8
21
  * @classdesc Provides operations on Azure Api Management
@@ -29,13 +42,18 @@ export class AzureApiManagementManager {
29
42
  * @param props api management properties
30
43
  * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
31
44
  */
32
- public createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps) {
45
+ public createApiManagement(
46
+ id: string,
47
+ scope: CommonAzureConstruct,
48
+ props: ApiManagementProps,
49
+ applicationInsightsKey?: ApiManagementLoggerApplicationInsights['instrumentationKey']
50
+ ) {
33
51
  if (!props) throw `Props undefined for ${id}`
34
52
 
35
53
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
54
  name: scope.props.resourceGroupName
37
55
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
- : `${props.resourceGroupName}-${scope.props.stage}`,
56
+ : `${props.resourceGroupName}`,
39
57
  })
40
58
 
41
59
  if (!resourceGroup) throw `Resource group undefined for ${id}`
@@ -49,10 +67,151 @@ export class AzureApiManagementManager {
49
67
  },
50
68
  })
51
69
 
70
+ if (applicationInsightsKey) {
71
+ new ApiManagementLogger(scope, `${id}-am-logger`, {
72
+ name: `${props.name}-${scope.props.stage}`,
73
+ resourceGroupName: resourceGroup.name,
74
+ apiManagementName: apiManagement.name,
75
+ applicationInsights: {
76
+ instrumentationKey: applicationInsightsKey,
77
+ },
78
+ })
79
+ }
80
+
52
81
  createAzureTfOutput(`${id}-apiManagementName`, scope, apiManagement.name)
53
82
  createAzureTfOutput(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId)
54
83
  createAzureTfOutput(`${id}-apiManagementId`, scope, apiManagement.id)
55
84
 
56
85
  return apiManagement
57
86
  }
87
+
88
+ /**
89
+ * @summary Method to resolve an api management
90
+ * @param id scoped id of the resource
91
+ * @param scope scope in which this resource is defined
92
+ * @param props api management properties
93
+ * @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
94
+ */
95
+ public resolveApiManagement(id: string, scope: CommonAzureConstruct, props: DataAzurermApiManagementConfig) {
96
+ if (!props) throw `Props undefined for ${id}`
97
+
98
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
99
+ name: scope.props.resourceGroupName
100
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
101
+ : `${props.resourceGroupName}`,
102
+ })
103
+
104
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
105
+
106
+ const apiManagement = new DataAzurermApiManagement(scope, `${id}-am`, {
107
+ ...props,
108
+ name: `${props.name}-${scope.props.stage}`,
109
+ resourceGroupName: scope.props.resourceGroupName
110
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
111
+ : `${props.resourceGroupName}`,
112
+ })
113
+
114
+ return apiManagement
115
+ }
116
+
117
+ /**
118
+ * @summary Method to create a new api management backend
119
+ * @param id scoped id of the resource
120
+ * @param scope scope in which this resource is defined
121
+ * @param props api management backend properties
122
+ * @see [CDKTF Api management Backend Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementBackend.typescript.md}
123
+ */
124
+ public createApiManagementBackend(id: string, scope: CommonAzureConstruct, props: ApiManagementBackendProps) {
125
+ if (!props) throw `Props undefined for ${id}`
126
+
127
+ const apiManagementBackend = new ApiManagementBackend(scope, `${id}-am-be`, {
128
+ ...props,
129
+ name: `${props.name}-${scope.props.stage}`,
130
+ description: props.description || `Backend for ${props.name}-${scope.props.stage}`,
131
+ protocol: props.protocol || 'http',
132
+ })
133
+
134
+ createAzureTfOutput(`${id}-apiManagementBackendName`, scope, apiManagementBackend.name)
135
+ createAzureTfOutput(`${id}-apiManagementBackendFriendlyUniqueId`, scope, apiManagementBackend.friendlyUniqueId)
136
+ createAzureTfOutput(`${id}-apiManagementBackendId`, scope, apiManagementBackend.id)
137
+
138
+ return apiManagementBackend
139
+ }
140
+
141
+ /**
142
+ * @summary Method to create a new api management api
143
+ * @param id scoped id of the resource
144
+ * @param scope scope in which this resource is defined
145
+ * @param props api management api properties
146
+ * @see [CDKTF Api management Api Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/ApiManagementApi.typescript.md}
147
+ */
148
+ public createApiManagementApi(id: string, scope: CommonAzureConstruct, props: ApiManagementApiProps) {
149
+ if (!props) throw `Props undefined for ${id}`
150
+
151
+ const apiManagementApi = new ApiManagementApi(scope, `${id}-am-api`, {
152
+ ...props,
153
+ name: `${props.name}-${scope.props.stage}`,
154
+ displayName: props.displayName || props.name,
155
+ revision: props.revision || '1',
156
+ protocols: props.protocols || ['https'],
157
+ subscriptionRequired: props.subscriptionRequired || true,
158
+ })
159
+
160
+ _.forEach(props.operations, operation => {
161
+ const apimOperation = new ApiManagementApiOperation(
162
+ scope,
163
+ `${id}-apim-api-operation-${operation.path}-${operation.method}`,
164
+ {
165
+ operationId: `${operation.path}-${operation.method}`,
166
+ method: operation.method.toUpperCase(),
167
+ apiManagementName: apiManagementApi.apiManagementName,
168
+ resourceGroupName: apiManagementApi.resourceGroupName,
169
+ apiName: apiManagementApi.name,
170
+ displayName: `/${operation.path}`,
171
+ urlTemplate: `/${operation.path}`,
172
+ }
173
+ )
174
+
175
+ const apimOperationPolicy = new ApiManagementApiOperationPolicy(
176
+ scope,
177
+ `${id}-apim-api-operation-policy-${operation.path}-${operation.method}`,
178
+ {
179
+ apiManagementName: apiManagementApi.apiManagementName,
180
+ resourceGroupName: apiManagementApi.resourceGroupName,
181
+ apiName: apiManagementApi.name,
182
+ operationId: apimOperation.operationId,
183
+ xmlContent: operation.xmlContent,
184
+ }
185
+ )
186
+
187
+ createAzureTfOutput(
188
+ `${id}-${operation.path}-${operation.method}-apimOperationOperationId`,
189
+ scope,
190
+ apimOperation.operationId
191
+ )
192
+ createAzureTfOutput(
193
+ `${id}-${operation.path}-${operation.method}-apimOperationFriendlyUniqueId`,
194
+ scope,
195
+ apimOperation.friendlyUniqueId
196
+ )
197
+ createAzureTfOutput(`${id}-${operation.path}-${operation.method}-apimOperationId`, scope, apimOperation.id)
198
+
199
+ createAzureTfOutput(
200
+ `${id}-${operation.path}-${operation.method}-apimOperationPolicyFriendlyUniqueId`,
201
+ scope,
202
+ apimOperationPolicy.friendlyUniqueId
203
+ )
204
+ createAzureTfOutput(
205
+ `${id}-${operation.path}-${operation.method}-apimOperationPolicyId`,
206
+ scope,
207
+ apimOperationPolicy.id
208
+ )
209
+ })
210
+
211
+ createAzureTfOutput(`${id}-apiManagementApiName`, scope, apiManagementApi.name)
212
+ createAzureTfOutput(`${id}-apiManagementApiFriendlyUniqueId`, scope, apiManagementApi.friendlyUniqueId)
213
+ createAzureTfOutput(`${id}-apiManagementApiId`, scope, apiManagementApi.id)
214
+
215
+ return apiManagementApi
216
+ }
58
217
  }
@@ -1,3 +1,19 @@
1
1
  import { ApiManagementConfig } from '@cdktf/provider-azurerm/lib/api-management'
2
+ import { ApiManagementBackendConfig } from '@cdktf/provider-azurerm/lib/api-management-backend'
3
+ import { ApiManagementApiConfig } from '@cdktf/provider-azurerm/lib/api-management-api'
4
+ import { ApiManagementApiOperationConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation'
5
+ import { ApiManagementApiOperationPolicyConfig } from '@cdktf/provider-azurerm/lib/api-management-api-operation-policy'
2
6
 
3
7
  export interface ApiManagementProps extends ApiManagementConfig {}
8
+
9
+ export interface ApiManagementBackendProps extends ApiManagementBackendConfig {}
10
+
11
+ export interface ApiManagementApiProps extends ApiManagementApiConfig {
12
+ operations: OperationsProps[]
13
+ }
14
+
15
+ export interface OperationsProps {
16
+ path: ApiManagementApiOperationConfig['urlTemplate']
17
+ method: ApiManagementApiOperationConfig['method']
18
+ xmlContent?: ApiManagementApiOperationPolicyConfig['xmlContent']
19
+ }
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -0,0 +1,58 @@
1
+ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import { AppConfiguration } from '@cdktf/provider-azurerm/lib/app-configuration'
3
+ import { CommonAzureConstruct } from '../../common'
4
+ import { createAzureTfOutput } from '../../utils'
5
+ import { AppConfigurationProps } from './types'
6
+
7
+ /**
8
+ * @classdesc Provides operations on Azure App Configuration
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.appConfigurationManager.createAppConfiguration('MyAppConfiguration', this, props)
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export class AzureAppConfigurationManager {
25
+ /**
26
+ * @summary Method to create a new app configuration
27
+ * @param id scoped id of the resource
28
+ * @param scope scope in which this resource is defined
29
+ * @param props app configuration properties
30
+ * @see [CDKTF App Configuration plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appConfiguration.typescript.md}
31
+ */
32
+ public createAppConfiguration(id: string, scope: CommonAzureConstruct, props: AppConfigurationProps) {
33
+ if (!props) throw `Props undefined for ${id}`
34
+
35
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
+ name: scope.props.resourceGroupName
37
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
+ : `${props.resourceGroupName}`,
39
+ })
40
+
41
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
42
+
43
+ const appConfiguration = new AppConfiguration(scope, `${id}-am`, {
44
+ ...props,
45
+ name: `${props.name}-${scope.props.stage}`,
46
+ resourceGroupName: resourceGroup.name,
47
+ tags: props.tags ?? {
48
+ environment: scope.props.stage,
49
+ },
50
+ })
51
+
52
+ createAzureTfOutput(`${id}-appConfigurationName`, scope, appConfiguration.name)
53
+ createAzureTfOutput(`${id}-appConfigurationFriendlyUniqueId`, scope, appConfiguration.friendlyUniqueId)
54
+ createAzureTfOutput(`${id}-appConfigurationId`, scope, appConfiguration.id)
55
+
56
+ return appConfiguration
57
+ }
58
+ }
@@ -0,0 +1,3 @@
1
+ import { AppConfigurationConfig } from '@cdktf/provider-azurerm/lib/app-configuration'
2
+
3
+ export interface AppConfigurationProps extends AppConfigurationConfig {}
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -0,0 +1,58 @@
1
+ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import { ServicePlan } from '@cdktf/provider-azurerm/lib/service-plan'
3
+ import { CommonAzureConstruct } from '../../common'
4
+ import { createAzureTfOutput } from '../../utils'
5
+ import { ServicePlanProps } from './types'
6
+
7
+ /**
8
+ * @classdesc Provides operations on Azure App Service
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.appServiceManager.createAppService('MyAppService', this, props)
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export class AzureAppServiceManager {
25
+ /**
26
+ * @summary Method to create a new app service plan
27
+ * @param id scoped id of the resource
28
+ * @param scope scope in which this resource is defined
29
+ * @param props app service plan properties
30
+ * @see [CDKTF App service plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appServicePlan.typescript.md}
31
+ */
32
+ public createAppServicePlan(id: string, scope: CommonAzureConstruct, props: ServicePlanProps) {
33
+ if (!props) throw `Props undefined for ${id}`
34
+
35
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
+ name: scope.props.resourceGroupName
37
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
+ : `${props.resourceGroupName}`,
39
+ })
40
+
41
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
42
+
43
+ const appServicePlan = new ServicePlan(scope, `${id}-am`, {
44
+ ...props,
45
+ name: `${props.name}-${scope.props.stage}`,
46
+ resourceGroupName: resourceGroup.name,
47
+ tags: props.tags ?? {
48
+ environment: scope.props.stage,
49
+ },
50
+ })
51
+
52
+ createAzureTfOutput(`${id}-appServicePlanName`, scope, appServicePlan.name)
53
+ createAzureTfOutput(`${id}-appServicePlanFriendlyUniqueId`, scope, appServicePlan.friendlyUniqueId)
54
+ createAzureTfOutput(`${id}-appServicePlanId`, scope, appServicePlan.id)
55
+
56
+ return appServicePlan
57
+ }
58
+ }
@@ -0,0 +1,3 @@
1
+ import { ServicePlanConfig } from '@cdktf/provider-azurerm/lib/service-plan'
2
+
3
+ export interface ServicePlanProps extends ServicePlanConfig {}
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -0,0 +1,58 @@
1
+ import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
+ import { ApplicationInsights } from '@cdktf/provider-azurerm/lib/application-insights'
3
+ import { CommonAzureConstruct } from '../../common'
4
+ import { createAzureTfOutput } from '../../utils'
5
+ import { ApplicationInsightsProps } from './types'
6
+
7
+ /**
8
+ * @classdesc Provides operations on Azure Application Insights
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.applicationInsightseManager.createApplicationInsights('MyApplicationInsights', this, props)
20
+ * }
21
+ * }
22
+ * ```
23
+ */
24
+ export class AzureApplicationInsightsManager {
25
+ /**
26
+ * @summary Method to create a new application insights
27
+ * @param id scoped id of the resource
28
+ * @param scope scope in which this resource is defined
29
+ * @param props application insights properties
30
+ * @see [CDKTF Application insights Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/applicationInsights.typescript.md}
31
+ */
32
+ public createApplicationInsights(id: string, scope: CommonAzureConstruct, props: ApplicationInsightsProps) {
33
+ if (!props) throw `Props undefined for ${id}`
34
+
35
+ const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
36
+ name: scope.props.resourceGroupName
37
+ ? `${scope.props.resourceGroupName}-${scope.props.stage}`
38
+ : `${props.resourceGroupName}`,
39
+ })
40
+
41
+ if (!resourceGroup) throw `Resource group undefined for ${id}`
42
+
43
+ const applicationInsights = new ApplicationInsights(scope, `${id}-am`, {
44
+ ...props,
45
+ name: `${props.name}-${scope.props.stage}`,
46
+ resourceGroupName: resourceGroup.name,
47
+ tags: props.tags ?? {
48
+ environment: scope.props.stage,
49
+ },
50
+ })
51
+
52
+ createAzureTfOutput(`${id}-applicationInsightsName`, scope, applicationInsights.name)
53
+ createAzureTfOutput(`${id}-applicationInsightsFriendlyUniqueId`, scope, applicationInsights.friendlyUniqueId)
54
+ createAzureTfOutput(`${id}-applicationInsightsId`, scope, applicationInsights.id)
55
+
56
+ return applicationInsights
57
+ }
58
+ }
@@ -0,0 +1,3 @@
1
+ import { ApplicationInsightsConfig } from '@cdktf/provider-azurerm/lib/application-insights'
2
+
3
+ export interface ApplicationInsightsProps extends ApplicationInsightsConfig {}
@@ -1,6 +1,5 @@
1
1
  import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
2
- import { DataAzurermFunctionApp } from '@cdktf/provider-azurerm/lib/data-azurerm-function-app'
3
- import { FunctionApp } from '@cdktf/provider-azurerm/lib/function-app'
2
+ import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app'
4
3
  import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function'
5
4
  import { CommonAzureConstruct } from '../../common'
6
5
  import { createAzureTfOutput } from '../../utils'
@@ -37,12 +36,12 @@ export class AzureFunctionManager {
37
36
  const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
38
37
  name: scope.props.resourceGroupName
39
38
  ? `${scope.props.resourceGroupName}-${scope.props.stage}`
40
- : `${props.resourceGroupName}-${scope.props.stage}`,
39
+ : `${props.resourceGroupName}`,
41
40
  })
42
41
 
43
42
  if (!resourceGroup) throw `Resource group undefined for ${id}`
44
43
 
45
- const functionApp = new FunctionApp(scope, `${id}-fa`, {
44
+ const functionApp = new LinuxFunctionApp(scope, `${id}-fa`, {
46
45
  ...props,
47
46
  name: `${props.name}-${scope.props.stage}`,
48
47
  resourceGroupName: resourceGroup.name,
@@ -68,22 +67,10 @@ export class AzureFunctionManager {
68
67
  public createFunction(id: string, scope: CommonAzureConstruct, props: FunctionProps) {
69
68
  if (!props) throw `Props undefined for ${id}`
70
69
 
71
- const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
72
- name: scope.props.resourceGroupName
73
- ? `${scope.props.resourceGroupName}-${scope.props.stage}`
74
- : `${props.resourceGroupName}-${scope.props.stage}`,
75
- })
76
-
77
- if (!resourceGroup) throw `Resource group undefined for ${id}`
78
-
79
- const storageAccount = new DataAzurermFunctionApp(scope, `${id}-sa`, {
80
- name: `${props.functionAppName}-${scope.props.stage}`,
81
- resourceGroupName: resourceGroup.name,
82
- })
83
-
84
70
  const functionAppFunction = new FunctionAppFunction(scope, `${id}-fc`, {
85
71
  ...props,
86
72
  name: `${props.name}-${scope.props.stage}`,
73
+ configJson: JSON.stringify(props.configJson || {}),
87
74
  })
88
75
 
89
76
  createAzureTfOutput(`${id}-functionName`, scope, functionAppFunction.name)
@@ -1,9 +1,7 @@
1
- import { FunctionAppConfig } from '@cdktf/provider-azurerm/lib/function-app'
1
+ import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app'
2
2
  import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function'
3
3
  import { BaseAzureConfigProps } from '../../types'
4
4
 
5
- export interface FunctionAppProps extends FunctionAppConfig {}
5
+ export interface FunctionAppProps extends LinuxFunctionAppConfig {}
6
6
 
7
- export interface FunctionProps extends BaseAzureConfigProps, FunctionAppFunctionConfig {
8
- functionAppName: string
9
- }
7
+ export interface FunctionProps extends FunctionAppFunctionConfig {}
@@ -1,4 +1,7 @@
1
1
  export * from './api-management'
2
+ export * from './app-configuration'
3
+ export * from './app-service'
4
+ export * from './application-insights'
2
5
  export * from './function'
3
6
  export * from './key-vault'
4
7
  export * from './resource-group'