@gradientedge/cdk-utils 9.31.0 → 9.33.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/constants.d.ts +4 -0
- package/dist/src/lib/azure/common/constants.js +8 -0
- package/dist/src/lib/azure/common/construct.d.ts +8 -1
- package/dist/src/lib/azure/common/construct.js +36 -0
- package/dist/src/lib/azure/common/index.d.ts +1 -0
- package/dist/src/lib/azure/common/index.js +1 -0
- package/dist/src/lib/azure/common/stack.d.ts +1 -0
- package/dist/src/lib/azure/common/stack.js +1 -3
- package/dist/src/lib/azure/common/types.d.ts +6 -0
- package/dist/src/lib/azure/services/api-management/index.d.ts +2 -0
- package/dist/src/lib/azure/services/api-management/index.js +18 -0
- package/dist/src/lib/azure/services/api-management/main.d.ts +30 -0
- package/dist/src/lib/azure/services/api-management/main.js +56 -0
- package/dist/src/lib/azure/services/api-management/types.d.ts +3 -0
- package/dist/src/lib/azure/services/api-management/types.js +2 -0
- package/dist/src/lib/azure/services/function/index.d.ts +2 -0
- package/dist/src/lib/azure/services/function/index.js +18 -0
- package/dist/src/lib/azure/services/function/main.d.ts +39 -0
- package/dist/src/lib/azure/services/function/main.js +88 -0
- package/dist/src/lib/azure/services/function/types.d.ts +8 -0
- package/dist/src/lib/azure/services/function/types.js +2 -0
- package/dist/src/lib/azure/services/index.d.ts +4 -0
- package/dist/src/lib/azure/services/index.js +4 -0
- package/dist/src/lib/azure/services/key-vault/index.d.ts +2 -0
- package/dist/src/lib/azure/services/key-vault/index.js +18 -0
- package/dist/src/lib/azure/services/key-vault/main.d.ts +30 -0
- package/dist/src/lib/azure/services/key-vault/main.js +58 -0
- package/dist/src/lib/azure/services/key-vault/types.d.ts +3 -0
- package/dist/src/lib/azure/services/key-vault/types.js +2 -0
- package/dist/src/lib/azure/services/resource-group/index.d.ts +2 -0
- package/dist/src/lib/azure/services/resource-group/index.js +18 -0
- package/dist/src/lib/azure/services/resource-group/main.d.ts +30 -0
- package/dist/src/lib/azure/services/resource-group/main.js +48 -0
- package/dist/src/lib/azure/services/resource-group/types.d.ts +3 -0
- package/dist/src/lib/azure/services/resource-group/types.js +2 -0
- package/dist/src/lib/azure/services/storage/main.d.ts +6 -3
- package/dist/src/lib/azure/services/storage/main.js +3 -0
- package/package.json +1 -1
- package/src/lib/aws/common/stack.ts +1 -1
- package/src/lib/azure/common/constants.ts +4 -0
- package/src/lib/azure/common/construct.ts +45 -2
- package/src/lib/azure/common/index.ts +1 -0
- package/src/lib/azure/common/stack.ts +1 -3
- package/src/lib/azure/common/types.ts +7 -0
- package/src/lib/azure/services/api-management/index.ts +2 -0
- package/src/lib/azure/services/api-management/main.ts +58 -0
- package/src/lib/azure/services/api-management/types.ts +3 -0
- package/src/lib/azure/services/function/index.ts +2 -0
- package/src/lib/azure/services/function/main.ts +95 -0
- package/src/lib/azure/services/function/types.ts +9 -0
- package/src/lib/azure/services/index.ts +4 -0
- package/src/lib/azure/services/key-vault/index.ts +2 -0
- package/src/lib/azure/services/key-vault/main.ts +60 -0
- package/src/lib/azure/services/key-vault/types.ts +3 -0
- package/src/lib/azure/services/resource-group/index.ts +2 -0
- package/src/lib/azure/services/resource-group/main.ts +49 -0
- package/src/lib/azure/services/resource-group/types.ts +3 -0
- package/src/lib/azure/services/storage/main.ts +6 -0
|
@@ -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) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureRemoteBackend = void 0;
|
|
4
|
+
var AzureRemoteBackend;
|
|
5
|
+
(function (AzureRemoteBackend) {
|
|
6
|
+
AzureRemoteBackend["local"] = "local";
|
|
7
|
+
AzureRemoteBackend["azurerm"] = "azurerm";
|
|
8
|
+
})(AzureRemoteBackend || (exports.AzureRemoteBackend = AzureRemoteBackend = {}));
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { TerraformStack } from 'cdktf';
|
|
2
2
|
import { Construct } from 'constructs';
|
|
3
|
-
import { AzureStorageManager } from '../services';
|
|
3
|
+
import { AzureStorageManager, AzureKeyVaultManager, AzureApiManagementManager, AzureFunctionManager, AzureResourceGroupManager } 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
|
+
tenantId: string;
|
|
10
|
+
apiManagementtManager: AzureApiManagementManager;
|
|
11
|
+
functiontManager: AzureFunctionManager;
|
|
12
|
+
keyVaultManager: AzureKeyVaultManager;
|
|
13
|
+
resourceGroupManager: AzureResourceGroupManager;
|
|
9
14
|
storageManager: AzureStorageManager;
|
|
10
15
|
constructor(scope: Construct, id: string, props: CommonAzureStackProps);
|
|
11
16
|
/**
|
|
12
17
|
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
13
18
|
*/
|
|
14
19
|
protected determineFullyQualifiedDomain(): void;
|
|
20
|
+
protected determineRemoteBackend(): void;
|
|
21
|
+
protected determineTenantId(): void;
|
|
15
22
|
/**
|
|
16
23
|
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
17
24
|
* This is determined by the stage property injected via cdk context
|
|
@@ -2,19 +2,32 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonAzureConstruct = void 0;
|
|
4
4
|
const provider_1 = require("@cdktf/provider-azurerm/lib/provider");
|
|
5
|
+
const data_azurerm_client_config_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-client-config");
|
|
5
6
|
const cdktf_1 = require("cdktf");
|
|
6
7
|
const common_1 = require("../../common");
|
|
7
8
|
const services_1 = require("../services");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
8
10
|
class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
9
11
|
id;
|
|
10
12
|
fullyQualifiedDomainName;
|
|
13
|
+
tenantId;
|
|
14
|
+
apiManagementtManager;
|
|
15
|
+
functiontManager;
|
|
16
|
+
keyVaultManager;
|
|
17
|
+
resourceGroupManager;
|
|
11
18
|
storageManager;
|
|
12
19
|
constructor(scope, id, props) {
|
|
13
20
|
super(scope, id);
|
|
14
21
|
this.props = props;
|
|
15
22
|
this.id = id;
|
|
23
|
+
this.apiManagementtManager = new services_1.AzureApiManagementManager();
|
|
24
|
+
this.functiontManager = new services_1.AzureFunctionManager();
|
|
25
|
+
this.keyVaultManager = new services_1.AzureKeyVaultManager();
|
|
26
|
+
this.resourceGroupManager = new services_1.AzureResourceGroupManager();
|
|
16
27
|
this.storageManager = new services_1.AzureStorageManager();
|
|
17
28
|
this.determineFullyQualifiedDomain();
|
|
29
|
+
this.determineRemoteBackend();
|
|
30
|
+
this.determineTenantId();
|
|
18
31
|
new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
|
|
19
32
|
}
|
|
20
33
|
/**
|
|
@@ -25,6 +38,29 @@ class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
|
25
38
|
? `${this.props.subDomain}.${this.props.domainName}`
|
|
26
39
|
: this.props.domainName;
|
|
27
40
|
}
|
|
41
|
+
determineRemoteBackend() {
|
|
42
|
+
const debug = this.node.tryGetContext('debug');
|
|
43
|
+
switch (this.props.remoteBackend?.type) {
|
|
44
|
+
case constants_1.AzureRemoteBackend.azurerm:
|
|
45
|
+
new cdktf_1.AzurermBackend(this, {
|
|
46
|
+
storageAccountName: this.props.remoteBackend.storageAccountName,
|
|
47
|
+
containerName: this.props.remoteBackend.containerName,
|
|
48
|
+
key: `${this.id}`,
|
|
49
|
+
subscriptionId: this.props.subscriptionId,
|
|
50
|
+
resourceGroupName: this.props.remoteBackend.resourceGroupName,
|
|
51
|
+
});
|
|
52
|
+
break;
|
|
53
|
+
case constants_1.AzureRemoteBackend.local:
|
|
54
|
+
if (debug)
|
|
55
|
+
console.debug(`Using local backend for ${this.id}`);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
determineTenantId() {
|
|
62
|
+
this.tenantId = new data_azurerm_client_config_1.DataAzurermClientConfig(this, 'current', {}).tenantId;
|
|
63
|
+
}
|
|
28
64
|
/**
|
|
29
65
|
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
30
66
|
* This is determined by the stage property injected via cdk context
|
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
17
18
|
__exportStar(require("./construct"), exports);
|
|
18
19
|
__exportStar(require("./stack"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.CommonAzureStack = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const construct_1 = require("./construct");
|
|
9
8
|
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
10
9
|
const cdktf_1 = require("cdktf");
|
|
11
10
|
const lodash_1 = __importDefault(require("lodash"));
|
|
@@ -33,8 +32,6 @@ class CommonAzureStack extends cdktf_1.TerraformStack {
|
|
|
33
32
|
/* determine extra cdk stage contexts */
|
|
34
33
|
this.determineStageContexts();
|
|
35
34
|
this.props = this.determineConstructProps(props);
|
|
36
|
-
/* initialise the construct */
|
|
37
|
-
this.construct = new construct_1.CommonAzureConstruct(this, 'cdk-utils', this.props);
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
37
|
* @summary Method to determine the core CDK construct properties injected via context cdktf.json
|
|
@@ -51,6 +48,7 @@ class CommonAzureStack extends cdktf_1.TerraformStack {
|
|
|
51
48
|
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
52
49
|
stage: this.node.tryGetContext('stage'),
|
|
53
50
|
subDomain: this.node.tryGetContext('subDomain'),
|
|
51
|
+
subscriptionId: this.node.tryGetContext('subscriptionId'),
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
54
|
/**
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { AzurermProviderConfig } from '@cdktf/provider-azurerm/lib/provider';
|
|
2
2
|
import { BaseProps } from '../../common';
|
|
3
|
+
import { AzureRemoteBackend } from './constants';
|
|
4
|
+
import { AzurermBackendConfig } from 'cdktf';
|
|
3
5
|
/**
|
|
4
6
|
*/
|
|
5
7
|
export interface CommonAzureStackProps extends BaseProps, AzurermProviderConfig {
|
|
6
8
|
resourceGroupName?: string;
|
|
9
|
+
remoteBackend?: AzureRemoteBackendProps;
|
|
10
|
+
}
|
|
11
|
+
export interface AzureRemoteBackendProps extends AzurermBackendConfig {
|
|
12
|
+
type: AzureRemoteBackend;
|
|
7
13
|
}
|
|
@@ -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 { ApiManagement } from '@cdktf/provider-azurerm/lib/api-management';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common';
|
|
3
|
+
import { ApiManagementProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Api Management
|
|
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.apiManagementManager.createApiManagement('MyApiManagement', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureApiManagementManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new api management
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props api management properties
|
|
27
|
+
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createApiManagement(id: string, scope: CommonAzureConstruct, props: ApiManagementProps): ApiManagement;
|
|
30
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureApiManagementManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const api_management_1 = require("@cdktf/provider-azurerm/lib/api-management");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
/**
|
|
8
|
+
* @classdesc Provides operations on Azure Api Management
|
|
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.apiManagementManager.createApiManagement('MyApiManagement', this, props)
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class AzureApiManagementManager {
|
|
25
|
+
/**
|
|
26
|
+
* @summary Method to create a new api management
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props api management properties
|
|
30
|
+
* @see [CDKTF Api management Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/apiManagement.typescript.md}
|
|
31
|
+
*/
|
|
32
|
+
createApiManagement(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}-${scope.props.stage}`,
|
|
39
|
+
});
|
|
40
|
+
if (!resourceGroup)
|
|
41
|
+
throw `Resource group undefined for ${id}`;
|
|
42
|
+
const apiManagement = new api_management_1.ApiManagement(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}-apiManagementName`, scope, apiManagement.name);
|
|
51
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementFriendlyUniqueId`, scope, apiManagement.friendlyUniqueId);
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-apiManagementId`, scope, apiManagement.id);
|
|
53
|
+
return apiManagement;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AzureApiManagementManager = AzureApiManagementManager;
|
|
@@ -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,39 @@
|
|
|
1
|
+
import { FunctionApp } from '@cdktf/provider-azurerm/lib/function-app';
|
|
2
|
+
import { FunctionAppFunction } from '@cdktf/provider-azurerm/lib/function-app-function';
|
|
3
|
+
import { CommonAzureConstruct } from '../../common';
|
|
4
|
+
import { FunctionAppProps, FunctionProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Provides operations on Azure Functions
|
|
7
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
8
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
12
|
+
*
|
|
13
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
14
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
15
|
+
* super(parent, id, props)
|
|
16
|
+
* this.props = props
|
|
17
|
+
* this.functionManager.createFunctionApp('MyFunctionApp', this, props)
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class AzureFunctionManager {
|
|
23
|
+
/**
|
|
24
|
+
* @summary Method to create a new function app
|
|
25
|
+
* @param id scoped id of the resource
|
|
26
|
+
* @param scope scope in which this resource is defined
|
|
27
|
+
* @param props function app properties
|
|
28
|
+
* @see [CDKTF Function App Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionApp.typescript.md}
|
|
29
|
+
*/
|
|
30
|
+
createFunctionApp(id: string, scope: CommonAzureConstruct, props: FunctionAppProps): FunctionApp;
|
|
31
|
+
/**
|
|
32
|
+
* @summary Method to create a new function
|
|
33
|
+
* @param id scoped id of the resource
|
|
34
|
+
* @param scope scope in which this resource is defined
|
|
35
|
+
* @param props function properties
|
|
36
|
+
* @see [CDKTF Function Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionAppFunction.typescript.md}
|
|
37
|
+
*/
|
|
38
|
+
createFunction(id: string, scope: CommonAzureConstruct, props: FunctionProps): FunctionAppFunction;
|
|
39
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureFunctionManager = void 0;
|
|
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");
|
|
7
|
+
const function_app_function_1 = require("@cdktf/provider-azurerm/lib/function-app-function");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
/**
|
|
10
|
+
* @classdesc Provides operations on Azure Functions
|
|
11
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
12
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
16
|
+
*
|
|
17
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
18
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
19
|
+
* super(parent, id, props)
|
|
20
|
+
* this.props = props
|
|
21
|
+
* this.functionManager.createFunctionApp('MyFunctionApp', this, props)
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
class AzureFunctionManager {
|
|
27
|
+
/**
|
|
28
|
+
* @summary Method to create a new function app
|
|
29
|
+
* @param id scoped id of the resource
|
|
30
|
+
* @param scope scope in which this resource is defined
|
|
31
|
+
* @param props function app properties
|
|
32
|
+
* @see [CDKTF Function App Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionApp.typescript.md}
|
|
33
|
+
*/
|
|
34
|
+
createFunctionApp(id, scope, props) {
|
|
35
|
+
if (!props)
|
|
36
|
+
throw `Props undefined for ${id}`;
|
|
37
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-fa-rg`, {
|
|
38
|
+
name: scope.props.resourceGroupName
|
|
39
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
40
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
41
|
+
});
|
|
42
|
+
if (!resourceGroup)
|
|
43
|
+
throw `Resource group undefined for ${id}`;
|
|
44
|
+
const functionApp = new function_app_1.FunctionApp(scope, `${id}-fa`, {
|
|
45
|
+
...props,
|
|
46
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
47
|
+
resourceGroupName: resourceGroup.name,
|
|
48
|
+
tags: props.tags ?? {
|
|
49
|
+
environment: scope.props.stage,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionAppName`, scope, functionApp.name);
|
|
53
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionAppFriendlyUniqueId`, scope, functionApp.friendlyUniqueId);
|
|
54
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionAppId`, scope, functionApp.id);
|
|
55
|
+
return functionApp;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @summary Method to create a new function
|
|
59
|
+
* @param id scoped id of the resource
|
|
60
|
+
* @param scope scope in which this resource is defined
|
|
61
|
+
* @param props function properties
|
|
62
|
+
* @see [CDKTF Function Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/functionAppFunction.typescript.md}
|
|
63
|
+
*/
|
|
64
|
+
createFunction(id, scope, props) {
|
|
65
|
+
if (!props)
|
|
66
|
+
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
|
+
const functionAppFunction = new function_app_function_1.FunctionAppFunction(scope, `${id}-fc`, {
|
|
79
|
+
...props,
|
|
80
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
81
|
+
});
|
|
82
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionName`, scope, functionAppFunction.name);
|
|
83
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionFriendlyUniqueId`, scope, functionAppFunction.friendlyUniqueId);
|
|
84
|
+
(0, utils_1.createAzureTfOutput)(`${id}-functionId`, scope, functionAppFunction.id);
|
|
85
|
+
return functionAppFunction;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.AzureFunctionManager = AzureFunctionManager;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionAppConfig } from '@cdktf/provider-azurerm/lib/function-app';
|
|
2
|
+
import { FunctionAppFunctionConfig } from '@cdktf/provider-azurerm/lib/function-app-function';
|
|
3
|
+
import { BaseAzureConfigProps } from '../../types';
|
|
4
|
+
export interface FunctionAppProps extends FunctionAppConfig {
|
|
5
|
+
}
|
|
6
|
+
export interface FunctionProps extends BaseAzureConfigProps, FunctionAppFunctionConfig {
|
|
7
|
+
functionAppName: string;
|
|
8
|
+
}
|
|
@@ -14,4 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api-management"), exports);
|
|
18
|
+
__exportStar(require("./function"), exports);
|
|
19
|
+
__exportStar(require("./key-vault"), exports);
|
|
20
|
+
__exportStar(require("./resource-group"), exports);
|
|
17
21
|
__exportStar(require("./storage"), exports);
|
|
@@ -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 { KeyVault } from '@cdktf/provider-azurerm/lib/key-vault';
|
|
2
|
+
import { CommonAzureConstruct } from '../../common';
|
|
3
|
+
import { KeyVaultProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @classdesc Provides operations on Azure Key Vault
|
|
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.keyVaultManager.createKeyVault('MyKeyVault', this, props)
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureKeyVaultManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new key vault
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props key vault properties
|
|
27
|
+
* @see [CDKTF Key Vault Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/keyVault.typescript.md}
|
|
28
|
+
*/
|
|
29
|
+
createKeyVault(id: string, scope: CommonAzureConstruct, props: KeyVaultProps): KeyVault;
|
|
30
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureKeyVaultManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const key_vault_1 = require("@cdktf/provider-azurerm/lib/key-vault");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
/**
|
|
8
|
+
* @classdesc Provides operations on Azure Key Vault
|
|
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.keyVaultManager.createKeyVault('MyKeyVault', this, props)
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class AzureKeyVaultManager {
|
|
25
|
+
/**
|
|
26
|
+
* @summary Method to create a new key vault
|
|
27
|
+
* @param id scoped id of the resource
|
|
28
|
+
* @param scope scope in which this resource is defined
|
|
29
|
+
* @param props key vault properties
|
|
30
|
+
* @see [CDKTF Key Vault Module]{@link https://github.com/cdktf/cdktf-provider-azurerm/blob/main/docs/keyVault.typescript.md}
|
|
31
|
+
*/
|
|
32
|
+
createKeyVault(id, scope, props) {
|
|
33
|
+
if (!props)
|
|
34
|
+
throw `Props undefined for ${id}`;
|
|
35
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-kv-rg`, {
|
|
36
|
+
name: scope.props.resourceGroupName
|
|
37
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
38
|
+
: `${props.resourceGroupName}`,
|
|
39
|
+
});
|
|
40
|
+
if (!resourceGroup)
|
|
41
|
+
throw `Resource group undefined for ${id}`;
|
|
42
|
+
const keyVault = new key_vault_1.KeyVault(scope, `${id}-kv`, {
|
|
43
|
+
...props,
|
|
44
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
45
|
+
location: resourceGroup.location,
|
|
46
|
+
resourceGroupName: resourceGroup.name,
|
|
47
|
+
skuName: props.skuName ?? 'standard',
|
|
48
|
+
tags: props.tags ?? {
|
|
49
|
+
environment: scope.props.stage,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
(0, utils_1.createAzureTfOutput)(`${id}-keyVaultName`, scope, keyVault.name);
|
|
53
|
+
(0, utils_1.createAzureTfOutput)(`${id}-keyVaultFriendlyUniqueId`, scope, keyVault.friendlyUniqueId);
|
|
54
|
+
(0, utils_1.createAzureTfOutput)(`${id}-keyVaultId`, scope, keyVault.id);
|
|
55
|
+
return keyVault;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.AzureKeyVaultManager = AzureKeyVaultManager;
|
|
@@ -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);
|