@gradientedge/cdk-utils 8.121.0 → 8.122.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/README.md +2 -1
- package/dist/src/lib/aws/common/construct.d.ts +0 -1
- package/dist/src/lib/aws/common/construct.js +6 -13
- package/dist/src/lib/aws/common/stack.js +2 -2
- package/dist/src/lib/aws/common/types.d.ts +2 -8
- package/dist/src/lib/aws/types/index.d.ts +6 -1
- package/dist/src/lib/aws/types/index.js +0 -15
- package/dist/src/lib/aws/utils/index.d.ts +13 -23
- package/dist/src/lib/aws/utils/index.js +37 -46
- package/dist/src/lib/azure/common/construct.d.ts +35 -0
- package/dist/src/lib/azure/common/construct.js +49 -0
- package/dist/src/lib/azure/common/index.d.ts +3 -0
- package/dist/src/lib/azure/common/index.js +19 -0
- package/dist/src/lib/azure/common/stack.d.ts +52 -0
- package/dist/src/lib/azure/common/stack.js +136 -0
- package/dist/src/lib/azure/common/types.d.ts +7 -0
- package/dist/src/lib/azure/index.d.ts +4 -0
- package/dist/src/lib/azure/index.js +20 -0
- package/dist/src/lib/azure/services/index.d.ts +1 -0
- package/dist/src/lib/azure/services/index.js +17 -0
- package/dist/src/lib/azure/services/storage/index.d.ts +2 -0
- package/dist/src/lib/azure/services/storage/index.js +18 -0
- package/dist/src/lib/azure/services/storage/main.d.ts +43 -0
- package/dist/src/lib/azure/services/storage/main.js +124 -0
- package/dist/src/lib/azure/services/storage/types.d.ts +10 -0
- package/dist/src/lib/azure/services/storage/types.js +2 -0
- package/dist/src/lib/azure/types/index.d.ts +3 -0
- package/dist/src/lib/azure/types/index.js +2 -0
- package/dist/src/lib/azure/utils/index.d.ts +3 -0
- package/dist/src/lib/azure/utils/index.js +20 -0
- package/dist/src/lib/common/construct.d.ts +29 -0
- package/dist/src/lib/common/construct.js +8 -0
- package/dist/src/lib/common/index.d.ts +5 -0
- package/dist/src/lib/common/index.js +29 -0
- package/dist/src/lib/common/stack.d.ts +21 -0
- package/dist/src/lib/common/stack.js +8 -0
- package/dist/src/lib/common/types.d.ts +9 -0
- package/dist/src/lib/common/types.js +2 -0
- package/dist/src/lib/common/utils.d.ts +26 -0
- package/dist/src/lib/common/utils.js +34 -0
- package/dist/src/lib/index.d.ts +2 -0
- package/dist/src/lib/index.js +2 -0
- package/package.json +3 -1
- package/setup.js +2 -0
- package/src/lib/aws/common/construct.ts +2 -13
- package/src/lib/aws/common/stack.ts +1 -1
- package/src/lib/aws/common/types.ts +2 -8
- package/src/lib/aws/types/index.ts +6 -1
- package/src/lib/aws/utils/index.ts +41 -29
- package/src/lib/azure/common/construct.ts +57 -0
- package/src/lib/azure/common/index.ts +3 -0
- package/src/lib/azure/common/stack.ts +145 -0
- package/src/lib/azure/common/types.ts +8 -0
- package/src/lib/azure/index.ts +4 -0
- package/src/lib/azure/services/index.ts +1 -0
- package/src/lib/azure/services/storage/index.ts +2 -0
- package/src/lib/azure/services/storage/main.ts +134 -0
- package/src/lib/azure/services/storage/types.ts +10 -0
- package/src/lib/azure/types/index.ts +3 -0
- package/src/lib/azure/utils/index.ts +23 -0
- package/src/lib/common/construct.ts +35 -0
- package/src/lib/common/index.ts +16 -0
- package/src/lib/common/stack.ts +26 -0
- package/src/lib/common/types.ts +9 -0
- package/src/lib/common/utils.ts +27 -0
- package/src/lib/index.ts +2 -0
- package/dist/src/lib/aws/types/aws/index.d.ts +0 -6
- package/dist/src/lib/aws/utils/aws/index.d.ts +0 -17
- package/dist/src/lib/aws/utils/aws/index.js +0 -40
- package/src/lib/aws/types/aws/index.ts +0 -6
- package/src/lib/aws/utils/aws/index.ts +0 -41
- /package/dist/src/lib/{aws/types/aws/index.js → azure/common/types.js} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CommonAzureConstruct } from '../../common';
|
|
2
|
+
import { StorageAccountProps, StorageBlobProps, StorageContainerProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @classdesc Provides operations on Azure Storage
|
|
5
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
6
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
7
|
+
* @example
|
|
8
|
+
* ```
|
|
9
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
10
|
+
*
|
|
11
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
12
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
13
|
+
* super(parent, id, props)
|
|
14
|
+
* this.props = props
|
|
15
|
+
* this.storageManager.createStorageAccount('MyAccount', this, props)
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* @see [CDKTF S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class AzureStorageManager {
|
|
22
|
+
/**
|
|
23
|
+
* @summary Method to create a new storage account
|
|
24
|
+
* @param id scoped id of the resource
|
|
25
|
+
* @param scope scope in which this resource is defined
|
|
26
|
+
* @param props storage account properties
|
|
27
|
+
*/
|
|
28
|
+
createStorageAccount(id: string, scope: CommonAzureConstruct, props: StorageAccountProps): void;
|
|
29
|
+
/**
|
|
30
|
+
* @summary Method to create a new storage container
|
|
31
|
+
* @param id scoped id of the resource
|
|
32
|
+
* @param scope scope in which this resource is defined
|
|
33
|
+
* @param props storage container properties
|
|
34
|
+
*/
|
|
35
|
+
createStorageContainer(id: string, scope: CommonAzureConstruct, props: StorageContainerProps): void;
|
|
36
|
+
/**
|
|
37
|
+
* @summary Method to create a new storage blob
|
|
38
|
+
* @param id scoped id of the resource
|
|
39
|
+
* @param scope scope in which this resource is defined
|
|
40
|
+
* @param props storage blob properties
|
|
41
|
+
*/
|
|
42
|
+
createStorageBlob(id: string, scope: CommonAzureConstruct, props: StorageBlobProps): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureStorageManager = void 0;
|
|
4
|
+
const data_azurerm_resource_group_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-resource-group");
|
|
5
|
+
const data_azurerm_storage_account_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-storage-account");
|
|
6
|
+
const data_azurerm_storage_container_1 = require("@cdktf/provider-azurerm/lib/data-azurerm-storage-container");
|
|
7
|
+
const storage_account_1 = require("@cdktf/provider-azurerm/lib/storage-account");
|
|
8
|
+
const storage_blob_1 = require("@cdktf/provider-azurerm/lib/storage-blob");
|
|
9
|
+
const storage_container_1 = require("@cdktf/provider-azurerm/lib/storage-container");
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
/**
|
|
12
|
+
* @classdesc Provides operations on Azure Storage
|
|
13
|
+
* - A new instance of this class is injected into {@link CommonAzureConstruct} constructor.
|
|
14
|
+
* - If a custom construct extends {@link CommonAzureConstruct}, an instance is available within the context.
|
|
15
|
+
* @example
|
|
16
|
+
* ```
|
|
17
|
+
* import { CommonAzureConstruct, CommonAzureStackProps } from '@gradientedge/cdk-utils'
|
|
18
|
+
*
|
|
19
|
+
* class CustomConstruct extends CommonAzureConstruct {
|
|
20
|
+
* constructor(parent: Construct, id: string, props: CommonAzureStackProps) {
|
|
21
|
+
* super(parent, id, props)
|
|
22
|
+
* this.props = props
|
|
23
|
+
* this.storageManager.createStorageAccount('MyAccount', this, props)
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* @see [CDKTF S3 Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3-readme.html}
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class AzureStorageManager {
|
|
30
|
+
/**
|
|
31
|
+
* @summary Method to create a new storage account
|
|
32
|
+
* @param id scoped id of the resource
|
|
33
|
+
* @param scope scope in which this resource is defined
|
|
34
|
+
* @param props storage account properties
|
|
35
|
+
*/
|
|
36
|
+
createStorageAccount(id, scope, props) {
|
|
37
|
+
if (!props)
|
|
38
|
+
throw `Props undefined for ${id}`;
|
|
39
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
40
|
+
name: scope.props.resourceGroupName
|
|
41
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
42
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
43
|
+
});
|
|
44
|
+
if (!resourceGroup)
|
|
45
|
+
throw `Resource group undefined for ${id}`;
|
|
46
|
+
const storageAccount = new storage_account_1.StorageAccount(scope, `${id}-sa`, {
|
|
47
|
+
...props,
|
|
48
|
+
accountTier: props.accountTier ?? 'Standard',
|
|
49
|
+
location: props.location ?? resourceGroup.location,
|
|
50
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
51
|
+
resourceGroupName: resourceGroup.name,
|
|
52
|
+
tags: props.tags ?? {
|
|
53
|
+
environment: scope.props.stage,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
(0, utils_1.createTfOutput)(`${id}-storageAccountName`, scope, storageAccount.name);
|
|
57
|
+
(0, utils_1.createTfOutput)(`${id}-storageAccountFriendlyUniqueId`, scope, storageAccount.friendlyUniqueId);
|
|
58
|
+
(0, utils_1.createTfOutput)(`${id}-storageAccountId`, scope, storageAccount.id);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @summary Method to create a new storage container
|
|
62
|
+
* @param id scoped id of the resource
|
|
63
|
+
* @param scope scope in which this resource is defined
|
|
64
|
+
* @param props storage container properties
|
|
65
|
+
*/
|
|
66
|
+
createStorageContainer(id, scope, props) {
|
|
67
|
+
if (!props)
|
|
68
|
+
throw `Props undefined for ${id}`;
|
|
69
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sc-rg`, {
|
|
70
|
+
name: scope.props.resourceGroupName
|
|
71
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
72
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
73
|
+
});
|
|
74
|
+
if (!resourceGroup)
|
|
75
|
+
throw `Resource group undefined for ${id}`;
|
|
76
|
+
const storageAccount = new data_azurerm_storage_account_1.DataAzurermStorageAccount(scope, `${id}-sa`, {
|
|
77
|
+
name: `${props.storageAccountName}-${scope.props.stage}`,
|
|
78
|
+
resourceGroupName: resourceGroup.name,
|
|
79
|
+
});
|
|
80
|
+
const storageContainer = new storage_container_1.StorageContainer(scope, `${id}-sc`, {
|
|
81
|
+
...props,
|
|
82
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
83
|
+
storageAccountName: storageAccount.name,
|
|
84
|
+
});
|
|
85
|
+
(0, utils_1.createTfOutput)(`${id}-storageContainerName`, scope, storageContainer.name);
|
|
86
|
+
(0, utils_1.createTfOutput)(`${id}-storageContainerFriendlyUniqueId`, scope, storageContainer.friendlyUniqueId);
|
|
87
|
+
(0, utils_1.createTfOutput)(`${id}-storageContainerId`, scope, storageContainer.id);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @summary Method to create a new storage blob
|
|
91
|
+
* @param id scoped id of the resource
|
|
92
|
+
* @param scope scope in which this resource is defined
|
|
93
|
+
* @param props storage blob properties
|
|
94
|
+
*/
|
|
95
|
+
createStorageBlob(id, scope, props) {
|
|
96
|
+
if (!props)
|
|
97
|
+
throw `Props undefined for ${id}`;
|
|
98
|
+
const resourceGroup = new data_azurerm_resource_group_1.DataAzurermResourceGroup(scope, `${id}-sb-rg`, {
|
|
99
|
+
name: scope.props.resourceGroupName
|
|
100
|
+
? `${scope.props.resourceGroupName}-${scope.props.stage}`
|
|
101
|
+
: `${props.resourceGroupName}-${scope.props.stage}`,
|
|
102
|
+
});
|
|
103
|
+
if (!resourceGroup)
|
|
104
|
+
throw `Resource group undefined for ${id}`;
|
|
105
|
+
const storageAccount = new data_azurerm_storage_account_1.DataAzurermStorageAccount(scope, `${id}-sa`, {
|
|
106
|
+
name: `${props.storageAccountName}-${scope.props.stage}`,
|
|
107
|
+
resourceGroupName: resourceGroup.name,
|
|
108
|
+
});
|
|
109
|
+
const storageContainer = new data_azurerm_storage_container_1.DataAzurermStorageContainer(scope, `${id}-sc`, {
|
|
110
|
+
name: `${props.storageContainerName}-${scope.props.stage}`,
|
|
111
|
+
storageAccountName: storageAccount.name,
|
|
112
|
+
});
|
|
113
|
+
const storageBlob = new storage_blob_1.StorageBlob(scope, `${id}-sb`, {
|
|
114
|
+
...props,
|
|
115
|
+
name: `${props.name}-${scope.props.stage}`,
|
|
116
|
+
storageAccountName: storageAccount.name,
|
|
117
|
+
storageContainerName: storageContainer.name,
|
|
118
|
+
});
|
|
119
|
+
(0, utils_1.createTfOutput)(`${id}-storageBlobName`, scope, storageBlob.name);
|
|
120
|
+
(0, utils_1.createTfOutput)(`${id}-storageBlobFriendlyUniqueId`, scope, storageBlob.friendlyUniqueId);
|
|
121
|
+
(0, utils_1.createTfOutput)(`${id}-storageBlobId`, scope, storageBlob.id);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.AzureStorageManager = AzureStorageManager;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageAccountConfig } from '@cdktf/provider-azurerm/lib/storage-account';
|
|
2
|
+
import { StorageBlobConfig } from '@cdktf/provider-azurerm/lib/storage-blob';
|
|
3
|
+
import { StorageContainerConfig } from '@cdktf/provider-azurerm/lib/storage-container';
|
|
4
|
+
import { BaseConfigProps } from '../../types';
|
|
5
|
+
export interface StorageAccountProps extends StorageAccountConfig {
|
|
6
|
+
}
|
|
7
|
+
export interface StorageContainerProps extends BaseConfigProps, StorageContainerConfig {
|
|
8
|
+
}
|
|
9
|
+
export interface StorageBlobProps extends BaseConfigProps, StorageBlobConfig {
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createTfOutput = void 0;
|
|
7
|
+
const cdktf_1 = require("cdktf");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
const createTfOutput = (id, scope, value, description, sensitive, overrideId = true) => {
|
|
10
|
+
const output = new cdktf_1.TerraformOutput(scope, id, {
|
|
11
|
+
description,
|
|
12
|
+
sensitive,
|
|
13
|
+
value,
|
|
14
|
+
});
|
|
15
|
+
if (overrideId) {
|
|
16
|
+
output.overrideLogicalId(lodash_1.default.camelCase(id));
|
|
17
|
+
}
|
|
18
|
+
return output;
|
|
19
|
+
};
|
|
20
|
+
exports.createTfOutput = createTfOutput;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { BaseProps } from './types';
|
|
3
|
+
export declare abstract class BaseConstruct extends Construct {
|
|
4
|
+
props: BaseProps;
|
|
5
|
+
/**
|
|
6
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
7
|
+
*/
|
|
8
|
+
abstract determineFullyQualifiedDomain(): void;
|
|
9
|
+
/**
|
|
10
|
+
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
11
|
+
* This is determined by the stage property injected via cdk context
|
|
12
|
+
*/
|
|
13
|
+
abstract isDevelopmentStage(): void;
|
|
14
|
+
/**
|
|
15
|
+
* @summary Utility method to determine if the initialisation is in test (tst) stage
|
|
16
|
+
* This is determined by the stage property injected via cdk context
|
|
17
|
+
*/
|
|
18
|
+
abstract isTestStage(): void;
|
|
19
|
+
/**
|
|
20
|
+
* @summary Utility method to determine if the initialisation is in uat (uat) stage
|
|
21
|
+
* This is determined by the stage property injected via cdk context
|
|
22
|
+
*/
|
|
23
|
+
abstract isUatStage(): void;
|
|
24
|
+
/**
|
|
25
|
+
* @summary Utility method to determine if the initialisation is in production (prd) stage
|
|
26
|
+
* This is determined by the stage property injected via cdk context
|
|
27
|
+
*/
|
|
28
|
+
abstract isProductionStage(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseConstruct = void 0;
|
|
4
|
+
const constructs_1 = require("constructs");
|
|
5
|
+
class BaseConstruct extends constructs_1.Construct {
|
|
6
|
+
props;
|
|
7
|
+
}
|
|
8
|
+
exports.BaseConstruct = BaseConstruct;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
exports.applyMixins = void 0;
|
|
18
|
+
__exportStar(require("./construct"), exports);
|
|
19
|
+
__exportStar(require("./stack"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
|
22
|
+
const applyMixins = (derivedCtor, constructors) => {
|
|
23
|
+
constructors.forEach(baseCtor => {
|
|
24
|
+
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
|
|
25
|
+
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
exports.applyMixins = applyMixins;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import { BaseProps } from './types';
|
|
3
|
+
export declare abstract class BaseStack extends Construct {
|
|
4
|
+
props: BaseProps;
|
|
5
|
+
/**
|
|
6
|
+
* @summary Method to determine the core CDK construct properties injected via context cdktf.json
|
|
7
|
+
*/
|
|
8
|
+
protected abstract determineConstructProps(props: BaseProps): void;
|
|
9
|
+
/**
|
|
10
|
+
* @summary Method to determine extra cdk contexts apart from the main cdktf.json
|
|
11
|
+
*/
|
|
12
|
+
abstract determineExtraContexts(): void;
|
|
13
|
+
/**
|
|
14
|
+
* @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
|
|
15
|
+
*/
|
|
16
|
+
abstract determineStageContexts(): void;
|
|
17
|
+
/**
|
|
18
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
19
|
+
*/
|
|
20
|
+
abstract fullyQualifiedDomain(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*/
|
|
3
|
+
export declare enum LogLevel {
|
|
4
|
+
DEBUG = "DEBUG",
|
|
5
|
+
INFO = "INFO",
|
|
6
|
+
WARNING = "WARNING",
|
|
7
|
+
TRACE = "TRACE",
|
|
8
|
+
ERROR = "ERROR",
|
|
9
|
+
CRITICAL = "CRITICAL"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param stage
|
|
13
|
+
*/
|
|
14
|
+
export declare const isDevStage: (stage: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @param stage
|
|
17
|
+
*/
|
|
18
|
+
export declare const isTestStage: (stage: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @param stage
|
|
21
|
+
*/
|
|
22
|
+
export declare const isUatStage: (stage: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @param stage
|
|
25
|
+
*/
|
|
26
|
+
export declare const isPrdStage: (stage: string) => boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrdStage = exports.isUatStage = exports.isTestStage = exports.isDevStage = exports.LogLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*/
|
|
6
|
+
var LogLevel;
|
|
7
|
+
(function (LogLevel) {
|
|
8
|
+
LogLevel["DEBUG"] = "DEBUG";
|
|
9
|
+
LogLevel["INFO"] = "INFO";
|
|
10
|
+
LogLevel["WARNING"] = "WARNING";
|
|
11
|
+
LogLevel["TRACE"] = "TRACE";
|
|
12
|
+
LogLevel["ERROR"] = "ERROR";
|
|
13
|
+
LogLevel["CRITICAL"] = "CRITICAL";
|
|
14
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
15
|
+
/**
|
|
16
|
+
* @param stage
|
|
17
|
+
*/
|
|
18
|
+
const isDevStage = (stage) => stage === 'dev';
|
|
19
|
+
exports.isDevStage = isDevStage;
|
|
20
|
+
/**
|
|
21
|
+
* @param stage
|
|
22
|
+
*/
|
|
23
|
+
const isTestStage = (stage) => stage === 'tst';
|
|
24
|
+
exports.isTestStage = isTestStage;
|
|
25
|
+
/**
|
|
26
|
+
* @param stage
|
|
27
|
+
*/
|
|
28
|
+
const isUatStage = (stage) => stage === 'uat';
|
|
29
|
+
exports.isUatStage = isUatStage;
|
|
30
|
+
/**
|
|
31
|
+
* @param stage
|
|
32
|
+
*/
|
|
33
|
+
const isPrdStage = (stage) => stage === 'prd';
|
|
34
|
+
exports.isPrdStage = isPrdStage;
|
package/dist/src/lib/index.d.ts
CHANGED
package/dist/src/lib/index.js
CHANGED
|
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./aws"), exports);
|
|
18
|
+
__exportStar(require("./azure"), exports);
|
|
19
|
+
__exportStar(require("./common"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.122.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -49,11 +49,13 @@
|
|
|
49
49
|
"@aws-sdk/client-secrets-manager": "^3.405.0",
|
|
50
50
|
"@aws-sdk/credential-providers": "^3.405.0",
|
|
51
51
|
"@aws-sdk/types": "^3.398.0",
|
|
52
|
+
"@cdktf/provider-azurerm": "^10.0.1",
|
|
52
53
|
"@types/lodash": "^4.14.197",
|
|
53
54
|
"@types/node": "^20.5.9",
|
|
54
55
|
"@types/uuid": "^9.0.3",
|
|
55
56
|
"app-root-path": "^3.1.0",
|
|
56
57
|
"aws-cdk-lib": "^2.94.0",
|
|
58
|
+
"cdktf": "^0.18.0",
|
|
57
59
|
"constructs": "^10.2.70",
|
|
58
60
|
"lodash": "^4.17.21",
|
|
59
61
|
"moment": "^2.29.4",
|
package/setup.js
ADDED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CfnOutput } from 'aws-cdk-lib'
|
|
2
2
|
import { Construct } from 'constructs'
|
|
3
|
+
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common'
|
|
3
4
|
import {
|
|
4
5
|
AcmManager,
|
|
5
6
|
ApiManager,
|
|
@@ -31,7 +32,7 @@ import {
|
|
|
31
32
|
VpcManager,
|
|
32
33
|
WafManager,
|
|
33
34
|
} from '../services'
|
|
34
|
-
import { createCfnOutput
|
|
35
|
+
import { createCfnOutput } from '../utils'
|
|
35
36
|
import { CommonStackProps } from './types'
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -161,15 +162,3 @@ export class CommonConstruct extends Construct {
|
|
|
161
162
|
*/
|
|
162
163
|
public isProductionStage = () => isPrdStage(this.props.stage)
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
-
export const applyMixins = (derivedCtor: any, constructors: any[]) => {
|
|
166
|
-
constructors.forEach(baseCtor => {
|
|
167
|
-
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
|
|
168
|
-
Object.defineProperty(
|
|
169
|
-
derivedCtor.prototype,
|
|
170
|
-
name,
|
|
171
|
-
Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null)
|
|
172
|
-
)
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { App, Stack, StackProps } from 'aws-cdk-lib'
|
|
2
2
|
import { Runtime } from 'aws-cdk-lib/aws-lambda'
|
|
3
3
|
import fs from 'fs'
|
|
4
|
-
import { isDevStage } from '../utils'
|
|
5
4
|
import { CommonConstruct } from './construct'
|
|
6
5
|
import { CommonStackProps } from './types'
|
|
7
6
|
|
|
8
7
|
import appRoot from 'app-root-path'
|
|
8
|
+
import { isDevStage } from '../../common'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { StackProps } from 'aws-cdk-lib'
|
|
2
2
|
import { Runtime, Tracing } from 'aws-cdk-lib/aws-lambda'
|
|
3
3
|
import { RetentionDays } from 'aws-cdk-lib/aws-logs'
|
|
4
|
+
import { BaseProps } from '../../common'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*/
|
|
7
|
-
export interface CommonStackProps extends StackProps {
|
|
8
|
-
name: string
|
|
8
|
+
export interface CommonStackProps extends BaseProps, StackProps {
|
|
9
9
|
region: string
|
|
10
|
-
stage: string
|
|
11
|
-
domainName: string
|
|
12
|
-
subDomain?: string
|
|
13
|
-
extraContexts?: string[]
|
|
14
|
-
stageContextPath?: string
|
|
15
|
-
skipStageForARecords: boolean
|
|
16
10
|
logRetention?: RetentionDays
|
|
17
11
|
defaultReservedLambdaConcurrentExecutions?: number
|
|
18
12
|
defaultTracing?: Tracing
|
|
@@ -1,43 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import { fromEnv, fromIni } from '@aws-sdk/credential-providers'
|
|
2
|
+
import { AwsCredentialIdentityProvider } from '@aws-sdk/types'
|
|
3
|
+
import { CfnOutput } from 'aws-cdk-lib'
|
|
4
|
+
import _ from 'lodash'
|
|
5
|
+
import { CommonConstruct } from '../common'
|
|
2
6
|
|
|
3
7
|
/**
|
|
8
|
+
* @summary Helper method to add CloudFormation outputs from the construct
|
|
9
|
+
* @param id scoped id of the resource
|
|
10
|
+
* @param scope scope in which this resource is defined
|
|
11
|
+
* @param value the value of the exported output
|
|
12
|
+
* @param description optional description for the output
|
|
13
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
14
|
+
* @returns The CloudFormation output
|
|
4
15
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
export function createCfnOutput(
|
|
17
|
+
id: string,
|
|
18
|
+
scope: CommonConstruct,
|
|
19
|
+
value?: string,
|
|
20
|
+
description?: string,
|
|
21
|
+
overrideId = true
|
|
22
|
+
): CfnOutput {
|
|
23
|
+
const camelName = _.camelCase(id)
|
|
24
|
+
const output = new CfnOutput(scope, id, {
|
|
25
|
+
description,
|
|
26
|
+
exportName: `${scope.props.stackName}-${camelName}`,
|
|
27
|
+
value: value ?? '',
|
|
28
|
+
})
|
|
29
|
+
if (overrideId) {
|
|
30
|
+
output.overrideLogicalId(camelName)
|
|
31
|
+
}
|
|
32
|
+
return output
|
|
12
33
|
}
|
|
13
34
|
|
|
14
35
|
/**
|
|
36
|
+
*
|
|
15
37
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
WARNING = 'WARNING',
|
|
20
|
-
TRACE = 'TRACE',
|
|
21
|
-
ERROR = 'ERROR',
|
|
22
|
-
CRITICAL = 'CRITICAL',
|
|
38
|
+
export function determineCredentials(): AwsCredentialIdentityProvider {
|
|
39
|
+
if (process.env.AWS_PROFILE) return fromIni()
|
|
40
|
+
return fromEnv()
|
|
23
41
|
}
|
|
24
42
|
|
|
25
43
|
/**
|
|
26
|
-
* @param stage
|
|
27
|
-
*/
|
|
28
|
-
export const isDevStage = (stage: string) => stage === 'dev'
|
|
29
|
-
/**
|
|
30
|
-
* @param stage
|
|
31
|
-
*/
|
|
32
|
-
export const isTestStage = (stage: string) => stage === 'tst'
|
|
33
|
-
/**
|
|
34
|
-
* @param stage
|
|
35
|
-
*/
|
|
36
|
-
export const isUatStage = (stage: string) => stage === 'uat'
|
|
37
|
-
/**
|
|
38
|
-
* @param stage
|
|
39
44
|
*/
|
|
40
|
-
|
|
45
|
+
const defaultResponseObject = {
|
|
46
|
+
body: '',
|
|
47
|
+
headers: {
|
|
48
|
+
'Access-Control-Allow-Origin': '*',
|
|
49
|
+
},
|
|
50
|
+
isBase64Encoded: false,
|
|
51
|
+
statusCode: 200,
|
|
52
|
+
}
|
|
41
53
|
|
|
42
54
|
/**
|
|
43
55
|
* @param error
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AzurermProvider } from '@cdktf/provider-azurerm/lib/provider'
|
|
2
|
+
import { TerraformStack } from 'cdktf'
|
|
3
|
+
import { Construct } from 'constructs'
|
|
4
|
+
import { isDevStage, isPrdStage, isTestStage, isUatStage } from '../../common'
|
|
5
|
+
import { AzureStorageManager } from '../services'
|
|
6
|
+
import { CommonAzureStackProps } from './types'
|
|
7
|
+
|
|
8
|
+
export class CommonAzureConstruct extends TerraformStack {
|
|
9
|
+
declare props: CommonAzureStackProps
|
|
10
|
+
id: string
|
|
11
|
+
fullyQualifiedDomainName: string
|
|
12
|
+
storageManager: AzureStorageManager
|
|
13
|
+
|
|
14
|
+
constructor(scope: Construct, id: string, props: CommonAzureStackProps) {
|
|
15
|
+
super(scope, id)
|
|
16
|
+
this.props = props
|
|
17
|
+
this.id = id
|
|
18
|
+
|
|
19
|
+
this.storageManager = new AzureStorageManager()
|
|
20
|
+
|
|
21
|
+
this.determineFullyQualifiedDomain()
|
|
22
|
+
new AzurermProvider(this, `${this.id}-provider`, this.props)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
27
|
+
*/
|
|
28
|
+
protected determineFullyQualifiedDomain(): void {
|
|
29
|
+
this.fullyQualifiedDomainName = this.props.subDomain
|
|
30
|
+
? `${this.props.subDomain}.${this.props.domainName}`
|
|
31
|
+
: this.props.domainName
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
36
|
+
* This is determined by the stage property injected via cdk context
|
|
37
|
+
*/
|
|
38
|
+
public isDevelopmentStage = () => isDevStage(this.props.stage)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @summary Utility method to determine if the initialisation is in test (tst) stage
|
|
42
|
+
* This is determined by the stage property injected via cdk context
|
|
43
|
+
*/
|
|
44
|
+
public isTestStage = () => isTestStage(this.props.stage)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @summary Utility method to determine if the initialisation is in uat (uat) stage
|
|
48
|
+
* This is determined by the stage property injected via cdk context
|
|
49
|
+
*/
|
|
50
|
+
public isUatStage = () => isUatStage(this.props.stage)
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @summary Utility method to determine if the initialisation is in production (prd) stage
|
|
54
|
+
* This is determined by the stage property injected via cdk context
|
|
55
|
+
*/
|
|
56
|
+
public isProductionStage = () => isPrdStage(this.props.stage)
|
|
57
|
+
}
|