@gradientedge/cdk-utils 9.32.0 → 9.34.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/aws/common/stack.js +1 -1
- package/dist/src/lib/azure/common/construct.d.ts +5 -2
- package/dist/src/lib/azure/common/construct.js +8 -2
- package/dist/src/lib/azure/services/api-management/main.js +1 -1
- package/dist/src/lib/azure/services/app-configuration/index.d.ts +2 -0
- package/dist/src/lib/azure/services/app-configuration/index.js +18 -0
- package/dist/src/lib/azure/services/app-configuration/main.d.ts +30 -0
- package/dist/src/lib/azure/services/app-configuration/main.js +56 -0
- package/dist/src/lib/azure/services/app-configuration/types.d.ts +3 -0
- package/dist/src/lib/azure/services/app-configuration/types.js +2 -0
- package/dist/src/lib/azure/services/app-service/index.d.ts +2 -0
- package/dist/src/lib/azure/services/app-service/index.js +18 -0
- package/dist/src/lib/azure/services/app-service/main.d.ts +30 -0
- package/dist/src/lib/azure/services/app-service/main.js +56 -0
- package/dist/src/lib/azure/services/app-service/types.d.ts +3 -0
- package/dist/src/lib/azure/services/app-service/types.js +2 -0
- package/dist/src/lib/azure/services/application-insights/index.d.ts +2 -0
- package/dist/src/lib/azure/services/application-insights/index.js +18 -0
- package/dist/src/lib/azure/services/application-insights/main.d.ts +30 -0
- package/dist/src/lib/azure/services/application-insights/main.js +56 -0
- package/dist/src/lib/azure/services/application-insights/types.d.ts +3 -0
- package/dist/src/lib/azure/services/application-insights/types.js +2 -0
- package/dist/src/lib/azure/services/function/main.d.ts +2 -2
- package/dist/src/lib/azure/services/function/main.js +4 -15
- package/dist/src/lib/azure/services/function/types.d.ts +3 -5
- package/dist/src/lib/azure/services/index.d.ts +3 -0
- package/dist/src/lib/azure/services/index.js +3 -0
- package/dist/src/lib/azure/services/storage/main.js +4 -4
- package/package.json +1 -1
- package/src/lib/aws/common/stack.ts +1 -1
- package/src/lib/azure/common/construct.ts +11 -2
- package/src/lib/azure/services/api-management/main.ts +1 -1
- package/src/lib/azure/services/app-configuration/index.ts +2 -0
- package/src/lib/azure/services/app-configuration/main.ts +58 -0
- package/src/lib/azure/services/app-configuration/types.ts +3 -0
- package/src/lib/azure/services/app-service/index.ts +2 -0
- package/src/lib/azure/services/app-service/main.ts +58 -0
- package/src/lib/azure/services/app-service/types.ts +3 -0
- package/src/lib/azure/services/application-insights/index.ts +2 -0
- package/src/lib/azure/services/application-insights/main.ts +58 -0
- package/src/lib/azure/services/application-insights/types.ts +3 -0
- package/src/lib/azure/services/function/main.ts +4 -17
- package/src/lib/azure/services/function/types.ts +3 -5
- package/src/lib/azure/services/index.ts +3 -0
- package/src/lib/azure/services/storage/main.ts +4 -4
|
@@ -25,7 +25,7 @@ const common_1 = require("../../common");
|
|
|
25
25
|
* }
|
|
26
26
|
*/
|
|
27
27
|
class CommonStack extends aws_cdk_lib_1.Stack {
|
|
28
|
-
static NODEJS_RUNTIME = aws_lambda_1.Runtime.
|
|
28
|
+
static NODEJS_RUNTIME = aws_lambda_1.Runtime.NODEJS_22_X;
|
|
29
29
|
construct;
|
|
30
30
|
props;
|
|
31
31
|
constructor(parent, name, props) {
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager } from '../services';
|
|
3
|
+
import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager, AzureAppServiceManager, AzureApplicationInsightsManager, AzureAppConfigurationManager } from '../services';
|
|
4
4
|
import { CommonAzureStackProps } from './types';
|
|
5
5
|
export declare class CommonAzureConstruct extends TerraformStack {
|
|
6
6
|
props: CommonAzureStackProps;
|
|
7
7
|
id: string;
|
|
8
8
|
fullyQualifiedDomainName: string;
|
|
9
9
|
tenantId: string;
|
|
10
|
-
|
|
10
|
+
apiManagementManager: AzureApiManagementManager;
|
|
11
|
+
appServiceManager: AzureAppServiceManager;
|
|
12
|
+
applicationInsightsManager: AzureApplicationInsightsManager;
|
|
13
|
+
appConfigurationManager: AzureAppConfigurationManager;
|
|
11
14
|
functiontManager: AzureFunctionManager;
|
|
12
15
|
keyVaultManager: AzureKeyVaultManager;
|
|
13
16
|
resourceGroupManager: AzureResourceGroupManager;
|
|
@@ -11,7 +11,10 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
11
11
|
id;
|
|
12
12
|
fullyQualifiedDomainName;
|
|
13
13
|
tenantId;
|
|
14
|
-
|
|
14
|
+
apiManagementManager;
|
|
15
|
+
appServiceManager;
|
|
16
|
+
applicationInsightsManager;
|
|
17
|
+
appConfigurationManager;
|
|
15
18
|
functiontManager;
|
|
16
19
|
keyVaultManager;
|
|
17
20
|
resourceGroupManager;
|
|
@@ -20,7 +23,10 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
20
23
|
super(scope, id);
|
|
21
24
|
this.props = props;
|
|
22
25
|
this.id = id;
|
|
23
|
-
this.
|
|
26
|
+
this.apiManagementManager = new services_1.AzureApiManagementManager();
|
|
27
|
+
this.appServiceManager = new services_1.AzureAppServiceManager();
|
|
28
|
+
this.applicationInsightsManager = new services_1.AzureApplicationInsightsManager();
|
|
29
|
+
this.appConfigurationManager = new services_1.AzureAppConfigurationManager();
|
|
24
30
|
this.functiontManager = new services_1.AzureFunctionManager();
|
|
25
31
|
this.keyVaultManager = new services_1.AzureKeyVaultManager();
|
|
26
32
|
this.resourceGroupManager = new services_1.AzureResourceGroupManager();
|
|
@@ -35,7 +35,7 @@ class AzureApiManagementManager {
|
|
|
35
35
|
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
36
36
|
name: scope.props.resourceGroupName
|
|
37
37
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
38
|
-
: `${props.resourceGroupName}
|
|
38
|
+
: `${props.resourceGroupName}`,
|
|
39
39
|
});
|
|
40
40
|
if (!resourceGroup)
|
|
41
41
|
throw `Resource group undefined for ${id}`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./main"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AppConfiguration } from '@cdktf/provider-azurerm/lib/app-configuration';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common';
|
|
3
|
+
import { AppConfigurationProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure App Configuration
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.appConfigurationManager.createAppConfiguration('MyAppConfiguration', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureAppConfigurationManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new app configuration
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props app configuration properties
|
|
27
|
+
* @see [CDKTF App Configuration plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appConfiguration.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createAppConfiguration(id: string, scope: CommonAzureConstruct, props: AppConfigurationProps): AppConfiguration;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureAppConfigurationManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const app_configuration_1 = require("@cdktf/provider-azurerm/lib/app-configuration");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
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
|
+
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
|
+
createAppConfiguration(id, scope, props) {
|
|
33
|
+
if (!props)
|
|
34
|
+
throw `Props undefined for ${id}`;
|
|
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}`,
|
|
39
|
+
});
|
|
40
|
+
if (!resourceGroup)
|
|
41
|
+
throw `Resource group undefined for ${id}`;
|
|
42
|
+
const appConfiguration = new app_configuration_1.AppConfiguration(scope, `${id}-am`, {
|
|
43
|
+
...props,
|
|
44
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
45
|
+
resourceGroupName: resourceGroup.name,
|
|
46
|
+
tags: props.tags ?? {
|
|
47
|
+
environment: scope.props.stage,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appConfigurationName`, scope, appConfiguration.name);
|
|
51
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appConfigurationFriendlyUniqueId`, scope, appConfiguration.friendlyUniqueId);
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appConfigurationId`, scope, appConfiguration.id);
|
|
53
|
+
return appConfiguration;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AzureAppConfigurationManager = AzureAppConfigurationManager;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./main"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ServicePlan } from '@cdktf/provider-azurerm/lib/service-plan';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common';
|
|
3
|
+
import { ServicePlanProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure App Service
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.appServiceManager.createAppService('MyAppService', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureAppServiceManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new app service plan
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props app service plan properties
|
|
27
|
+
* @see [CDKTF App service plan Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/appServicePlan.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createAppServicePlan(id: string, scope: CommonAzureConstruct, props: ServicePlanProps): ServicePlan;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureAppServiceManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const service_plan_1 = require("@cdktf/provider-azurerm/lib/service-plan");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
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
|
+
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
|
+
createAppServicePlan(id, scope, props) {
|
|
33
|
+
if (!props)
|
|
34
|
+
throw `Props undefined for ${id}`;
|
|
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}`,
|
|
39
|
+
});
|
|
40
|
+
if (!resourceGroup)
|
|
41
|
+
throw `Resource group undefined for ${id}`;
|
|
42
|
+
const appServicePlan = new service_plan_1.ServicePlan(scope, `${id}-am`, {
|
|
43
|
+
...props,
|
|
44
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
45
|
+
resourceGroupName: resourceGroup.name,
|
|
46
|
+
tags: props.tags ?? {
|
|
47
|
+
environment: scope.props.stage,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appServicePlanName`, scope, appServicePlan.name);
|
|
51
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appServicePlanFriendlyUniqueId`, scope, appServicePlan.friendlyUniqueId);
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-appServicePlanId`, scope, appServicePlan.id);
|
|
53
|
+
return appServicePlan;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AzureAppServiceManager = AzureAppServiceManager;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./main"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ApplicationInsights } from '@cdktf/provider-azurerm/lib/application-insights';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common';
|
|
3
|
+
import { ApplicationInsightsProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Application Insights
|
|
6
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
7
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
8
|
+
* @example
|
|
9
|
+
* ```
|
|
10
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
11
|
+
*
|
|
12
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
13
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
14
|
+
* super(parent, id, props)
|
|
15
|
+
* this.props = props
|
|
16
|
+
* this.applicationInsightseManager.createApplicationInsights('MyApplicationInsights', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureApplicationInsightsManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new application insights
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props application insights properties
|
|
27
|
+
* @see [CDKTF Application insights Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/applicationInsights.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createApplicationInsights(id: string, scope: CommonAzureConstruct, props: ApplicationInsightsProps): ApplicationInsights;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureApplicationInsightsManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const application_insights_1 = require("@cdktf/provider-azurerm/lib/application-insights");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
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
|
+
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
|
+
createApplicationInsights(id, scope, props) {
|
|
33
|
+
if (!props)
|
|
34
|
+
throw `Props undefined for ${id}`;
|
|
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}`,
|
|
39
|
+
});
|
|
40
|
+
if (!resourceGroup)
|
|
41
|
+
throw `Resource group undefined for ${id}`;
|
|
42
|
+
const applicationInsights = new application_insights_1.ApplicationInsights(scope, `${id}-am`, {
|
|
43
|
+
...props,
|
|
44
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
45
|
+
resourceGroupName: resourceGroup.name,
|
|
46
|
+
tags: props.tags ?? {
|
|
47
|
+
environment: scope.props.stage,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
(0, utils_1.createAzureTfOutput)(`${id}-applicationInsightsName`, scope, applicationInsights.name);
|
|
51
|
+
(0, utils_1.createAzureTfOutput)(`${id}-applicationInsightsFriendlyUniqueId`, scope, applicationInsights.friendlyUniqueId);
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-applicationInsightsId`, scope, applicationInsights.id);
|
|
53
|
+
return applicationInsights;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AzureApplicationInsightsManager = AzureApplicationInsightsManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinuxFunctionApp } from '@cdktf/provider-azurerm/lib/linux-function-app';
|
|
2
2
|
import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function';
|
|
3
3
|
import { CommonAzureConstruct } from '../../common';
|
|
4
4
|
import { FunctionAppProps, FunctionProps } from './types';
|
|
@@ -27,7 +27,7 @@ export declare class AzureFunctionManager {
|
|
|
27
27
|
* @param props function app properties
|
|
28
28
|
* @see [CDKTF Function App Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionApp.typescript.md}
|
|
29
29
|
*/
|
|
30
|
-
createFunctionApp(id: string, scope: CommonAzureConstruct, props: FunctionAppProps):
|
|
30
|
+
createFunctionApp(id: string, scope: CommonAzureConstruct, props: FunctionAppProps): LinuxFunctionApp;
|
|
31
31
|
/**
|
|
32
32
|
* @summary Method to create a new function
|
|
33
33
|
* @param id scoped id of the resource
|
|
@@ -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
|
|
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}
|
|
39
|
+
: `${props.resourceGroupName}`,
|
|
41
40
|
});
|
|
42
41
|
if (!resourceGroup)
|
|
43
42
|
throw `Resource group undefined for ${id}`;
|
|
44
|
-
const functionApp = new
|
|
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 {
|
|
1
|
+
import { LinuxFunctionAppConfig } from '@cdktf/provider-azurerm/lib/linux-function-app';
|
|
2
2
|
import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function';
|
|
3
|
-
|
|
4
|
-
export interface FunctionAppProps extends FunctionAppConfig {
|
|
3
|
+
export interface FunctionAppProps extends LinuxFunctionAppConfig {
|
|
5
4
|
}
|
|
6
|
-
export interface FunctionProps extends
|
|
7
|
-
functionAppName: string;
|
|
5
|
+
export interface FunctionProps extends FunctionAppFunctionConfig {
|
|
8
6
|
}
|
|
@@ -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}
|
|
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}
|
|
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}
|
|
105
|
+
: `${props.resourceGroupName}`,
|
|
106
106
|
});
|
|
107
107
|
if (!resourceGroup)
|
|
108
108
|
throw `Resource group undefined for ${id}`;
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ import { isDevStage } from '../../common'
|
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
25
|
export class CommonStack extends Stack {
|
|
26
|
-
public static NODEJS_RUNTIME = Runtime.
|
|
26
|
+
public static NODEJS_RUNTIME = Runtime.NODEJS_22_X
|
|
27
27
|
|
|
28
28
|
construct: CommonConstruct
|
|
29
29
|
props: CommonStackProps
|
|
@@ -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
|
-
|
|
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.
|
|
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()
|
|
@@ -35,7 +35,7 @@ export class AzureApiManagementManager {
|
|
|
35
35
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-am-rg`, {
|
|
36
36
|
name: scope.props.resourceGroupName
|
|
37
37
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
38
|
-
: `${props.resourceGroupName}
|
|
38
|
+
: `${props.resourceGroupName}`,
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -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,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,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
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataAzurermResourceGroup } from '@cdktf/provider-azurerm/lib/data-azurerm-resource-group'
|
|
2
|
-
import {
|
|
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}
|
|
39
|
+
: `${props.resourceGroupName}`,
|
|
41
40
|
})
|
|
42
41
|
|
|
43
42
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
44
43
|
|
|
45
|
-
const functionApp = new
|
|
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 {
|
|
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
|
|
5
|
+
export interface FunctionAppProps extends LinuxFunctionAppConfig {}
|
|
6
6
|
|
|
7
|
-
export interface FunctionProps extends
|
|
8
|
-
functionAppName: string
|
|
9
|
-
}
|
|
7
|
+
export interface FunctionProps extends FunctionAppFunctionConfig {}
|
|
@@ -39,7 +39,7 @@ export class AzureStorageManager {
|
|
|
39
39
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
40
40
|
name: scope.props.resourceGroupName
|
|
41
41
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
42
|
-
: `${props.resourceGroupName}
|
|
42
|
+
: `${props.resourceGroupName}`,
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -48,7 +48,7 @@ export class AzureStorageManager {
|
|
|
48
48
|
...props,
|
|
49
49
|
accountTier: props.accountTier ?? 'Standard',
|
|
50
50
|
location: props.location ?? resourceGroup.location,
|
|
51
|
-
name: `${props.name}-${scope.props.stage}
|
|
51
|
+
name: `${props.name}-${scope.props.stage}`.replace(/\W/g, '').toLowerCase(),
|
|
52
52
|
resourceGroupName: resourceGroup.name,
|
|
53
53
|
tags: props.tags ?? {
|
|
54
54
|
environment: scope.props.stage,
|
|
@@ -75,7 +75,7 @@ export class AzureStorageManager {
|
|
|
75
75
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
76
76
|
name: scope.props.resourceGroupName
|
|
77
77
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
78
|
-
: `${props.resourceGroupName}
|
|
78
|
+
: `${props.resourceGroupName}`,
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|
|
@@ -111,7 +111,7 @@ export class AzureStorageManager {
|
|
|
111
111
|
const resourceGroup = new DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
|
|
112
112
|
name: scope.props.resourceGroupName
|
|
113
113
|
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
114
|
-
: `${props.resourceGroupName}
|
|
114
|
+
: `${props.resourceGroupName}`,
|
|
115
115
|
})
|
|
116
116
|
|
|
117
117
|
if (!resourceGroup) throw `Resource group undefined for ${id}`
|