@gradientedge/cdk-utils 8.121.0 → 8.123.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 +7 -9
- package/dist/src/lib/aws/common/types.d.ts +2 -8
- package/dist/src/lib/aws/construct/api-to-any-target/main.js +24 -26
- package/dist/src/lib/aws/construct/api-to-eventbridge-target/main.js +85 -103
- package/dist/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.js +94 -120
- package/dist/src/lib/aws/construct/api-to-lambda-target/main.js +8 -10
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/lambda-with-iam-access/main.js +5 -1
- package/dist/src/lib/aws/construct/rest-api-lambda/main.js +7 -3
- package/dist/src/lib/aws/construct/rest-api-lambda-with-cache/main.js +5 -1
- package/dist/src/lib/aws/construct/site-with-ecs-backend/main.js +8 -6
- package/dist/src/lib/aws/construct/static-asset-deployment/main.js +5 -1
- package/dist/src/lib/aws/services/api-gateway/main.js +18 -10
- package/dist/src/lib/aws/services/cloudfront/main.js +11 -7
- package/dist/src/lib/aws/services/cloudwatch/logs.js +8 -4
- package/dist/src/lib/aws/services/cloudwatch/main.js +36 -78
- package/dist/src/lib/aws/services/dynamodb/main.js +6 -2
- package/dist/src/lib/aws/services/elastic-container-service/main.js +8 -4
- package/dist/src/lib/aws/services/elastic-file-system/main.js +5 -1
- package/dist/src/lib/aws/services/elasticache/main.js +6 -2
- package/dist/src/lib/aws/services/eventbridge/main.js +8 -4
- package/dist/src/lib/aws/services/lambda/main.js +7 -3
- package/dist/src/lib/aws/services/simple-notification-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-queue-service/main.js +6 -2
- package/dist/src/lib/aws/services/simple-storage-service/main.js +8 -4
- package/dist/src/lib/aws/services/step-function/main.js +52 -32
- package/dist/src/lib/aws/services/virtual-private-cloud/main.js +8 -4
- 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 +134 -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 +33 -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 +9 -7
- package/setup.js +2 -0
- package/src/lib/aws/common/construct.ts +2 -13
- package/src/lib/aws/common/stack.ts +6 -8
- package/src/lib/aws/common/types.ts +2 -8
- package/src/lib/aws/construct/api-to-any-target/main.ts +25 -27
- package/src/lib/aws/construct/api-to-eventbridge-target/main.ts +85 -103
- package/src/lib/aws/construct/api-to-eventbridge-target-with-sns/main.ts +94 -120
- package/src/lib/aws/construct/api-to-lambda-target/main.ts +8 -10
- package/src/lib/aws/construct/graphql-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/lambda-with-iam-access/main.ts +2 -1
- package/src/lib/aws/construct/rest-api-lambda/main.ts +4 -3
- package/src/lib/aws/construct/rest-api-lambda-with-cache/main.ts +2 -1
- package/src/lib/aws/construct/site-with-ecs-backend/main.ts +8 -9
- package/src/lib/aws/construct/static-asset-deployment/main.ts +2 -1
- package/src/lib/aws/services/api-gateway/main.ts +9 -6
- package/src/lib/aws/services/cloudfront/main.ts +8 -7
- package/src/lib/aws/services/cloudwatch/logs.ts +6 -5
- package/src/lib/aws/services/cloudwatch/main.ts +35 -81
- package/src/lib/aws/services/dynamodb/main.ts +3 -2
- package/src/lib/aws/services/elastic-container-service/main.ts +5 -4
- package/src/lib/aws/services/elastic-file-system/main.ts +2 -1
- package/src/lib/aws/services/elasticache/main.ts +3 -2
- package/src/lib/aws/services/eventbridge/main.ts +5 -4
- package/src/lib/aws/services/lambda/main.ts +4 -3
- package/src/lib/aws/services/simple-notification-service/main.ts +3 -2
- package/src/lib/aws/services/simple-queue-service/main.ts +3 -2
- package/src/lib/aws/services/simple-storage-service/main.ts +5 -4
- package/src/lib/aws/services/step-function/main.ts +17 -16
- package/src/lib/aws/services/virtual-private-cloud/main.ts +5 -4
- 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 +143 -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 +18 -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,20 @@
|
|
|
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("./common"), exports);
|
|
18
|
+
__exportStar(require("./services"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./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,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,33 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.applyMixins = void 0;
|
|
21
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
22
|
+
__exportStar(require("./construct"), exports);
|
|
23
|
+
__exportStar(require("./stack"), exports);
|
|
24
|
+
__exportStar(require("./types"), exports);
|
|
25
|
+
__exportStar(require("./utils"), exports);
|
|
26
|
+
const applyMixins = (derivedCtor, constructors) => {
|
|
27
|
+
lodash_1.default.forEach(constructors, baseConstructor => {
|
|
28
|
+
Object.getOwnPropertyNames(baseConstructor.prototype).forEach(name => {
|
|
29
|
+
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseConstructor.prototype, name) || Object.create(null));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
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.123.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -46,14 +46,16 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
50
|
-
"@aws-sdk/credential-providers": "^3.
|
|
51
|
-
"@aws-sdk/types": "^3.
|
|
52
|
-
"@
|
|
49
|
+
"@aws-sdk/client-secrets-manager": "^3.408.0",
|
|
50
|
+
"@aws-sdk/credential-providers": "^3.408.0",
|
|
51
|
+
"@aws-sdk/types": "^3.408.0",
|
|
52
|
+
"@cdktf/provider-azurerm": "^10.0.2",
|
|
53
|
+
"@types/lodash": "^4.14.198",
|
|
53
54
|
"@types/node": "^20.5.9",
|
|
54
55
|
"@types/uuid": "^9.0.3",
|
|
55
56
|
"app-root-path": "^3.1.0",
|
|
56
|
-
"aws-cdk-lib": "^2.
|
|
57
|
+
"aws-cdk-lib": "^2.95.0",
|
|
58
|
+
"cdktf": "^0.18.0",
|
|
57
59
|
"constructs": "^10.2.70",
|
|
58
60
|
"lodash": "^4.17.21",
|
|
59
61
|
"moment": "^2.29.4",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"@types/jest": "^29.5.4",
|
|
70
72
|
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
|
71
73
|
"@typescript-eslint/parser": "^6.6.0",
|
|
72
|
-
"aws-cdk": "^2.
|
|
74
|
+
"aws-cdk": "^2.95.0",
|
|
73
75
|
"better-docs": "^2.7.2",
|
|
74
76
|
"codecov": "^3.8.3",
|
|
75
77
|
"commitizen": "^4.3.0",
|
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,12 @@
|
|
|
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 _ from 'lodash'
|
|
9
|
+
import { isDevStage } from '../../common'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
@@ -75,7 +76,7 @@ export class CommonStack extends Stack {
|
|
|
75
76
|
return
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
_.forEach(extraContexts, (context: string) => {
|
|
79
80
|
const extraContextPath = `${appRoot.path}/${context}`
|
|
80
81
|
|
|
81
82
|
/* scenario where extra context is configured in cdk.json but absent in file system */
|
|
@@ -89,7 +90,7 @@ export class CommonStack extends Stack {
|
|
|
89
90
|
const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'))
|
|
90
91
|
|
|
91
92
|
/* set each of the property into the cdk node context */
|
|
92
|
-
|
|
93
|
+
_.keys(extraContextProps).forEach((propKey: any) => {
|
|
93
94
|
this.node.setContext(propKey, extraContextProps[propKey])
|
|
94
95
|
})
|
|
95
96
|
})
|
|
@@ -125,13 +126,10 @@ export class CommonStack extends Stack {
|
|
|
125
126
|
const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'))
|
|
126
127
|
|
|
127
128
|
/* set each of the property into the cdk node context */
|
|
128
|
-
|
|
129
|
+
_.keys(stageContextProps).forEach((propKey: any) => {
|
|
129
130
|
/* handle object, array properties */
|
|
130
131
|
if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
|
|
131
|
-
this.node.setContext(propKey,
|
|
132
|
-
...this.node.tryGetContext(propKey),
|
|
133
|
-
...stageContextProps[propKey],
|
|
134
|
-
})
|
|
132
|
+
this.node.setContext(propKey, _.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]))
|
|
135
133
|
} else {
|
|
136
134
|
/* handle all other primitive properties */
|
|
137
135
|
this.node.setContext(propKey, stageContextProps[propKey])
|
|
@@ -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
|