@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
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.SfnManager = void 0;
|
|
4
7
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
8
|
const aws_stepfunctions_1 = require("aws-cdk-lib/aws-stepfunctions");
|
|
6
9
|
const aws_stepfunctions_tasks_1 = require("aws-cdk-lib/aws-stepfunctions-tasks");
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
11
|
const uuid_1 = require("uuid");
|
|
8
12
|
const utils_1 = require("../../utils");
|
|
9
13
|
const DEFAULT_RETRY_CONFIG = [
|
|
@@ -160,10 +164,12 @@ class SfnManager {
|
|
|
160
164
|
if (!retries || retries.length === 0) {
|
|
161
165
|
retries = DEFAULT_RETRY_CONFIG;
|
|
162
166
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
lodash_1.default.forEach(retries, retry => {
|
|
168
|
+
step.addRetry({
|
|
169
|
+
...retry,
|
|
170
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
171
|
+
});
|
|
172
|
+
});
|
|
167
173
|
return step;
|
|
168
174
|
}
|
|
169
175
|
/**
|
|
@@ -202,10 +208,12 @@ class SfnManager {
|
|
|
202
208
|
if (!retries || retries.length === 0) {
|
|
203
209
|
retries = DEFAULT_RETRY_CONFIG;
|
|
204
210
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
lodash_1.default.forEach(retries, retry => {
|
|
212
|
+
step.addRetry({
|
|
213
|
+
...retry,
|
|
214
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
215
|
+
});
|
|
216
|
+
});
|
|
209
217
|
return step;
|
|
210
218
|
}
|
|
211
219
|
/**
|
|
@@ -244,10 +252,12 @@ class SfnManager {
|
|
|
244
252
|
if (!retries || retries.length === 0) {
|
|
245
253
|
retries = DEFAULT_RETRY_CONFIG;
|
|
246
254
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
255
|
+
lodash_1.default.forEach(retries, retry => {
|
|
256
|
+
step.addRetry({
|
|
257
|
+
...retry,
|
|
258
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
259
|
+
});
|
|
260
|
+
});
|
|
251
261
|
return step;
|
|
252
262
|
}
|
|
253
263
|
/**
|
|
@@ -284,10 +294,12 @@ class SfnManager {
|
|
|
284
294
|
if (!retries || retries.length === 0) {
|
|
285
295
|
retries = DEFAULT_RETRY_CONFIG;
|
|
286
296
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
297
|
+
lodash_1.default.forEach(retries, retry => {
|
|
298
|
+
step.addRetry({
|
|
299
|
+
...retry,
|
|
300
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
301
|
+
});
|
|
302
|
+
});
|
|
291
303
|
return step;
|
|
292
304
|
}
|
|
293
305
|
/**
|
|
@@ -311,10 +323,12 @@ class SfnManager {
|
|
|
311
323
|
if (!retries || retries.length === 0) {
|
|
312
324
|
retries = DEFAULT_RETRY_CONFIG;
|
|
313
325
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
326
|
+
lodash_1.default.forEach(retries, retry => {
|
|
327
|
+
step.addRetry({
|
|
328
|
+
...retry,
|
|
329
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
330
|
+
});
|
|
331
|
+
});
|
|
318
332
|
return step;
|
|
319
333
|
}
|
|
320
334
|
/**
|
|
@@ -341,10 +355,12 @@ class SfnManager {
|
|
|
341
355
|
if (!retries || retries.length === 0) {
|
|
342
356
|
retries = DEFAULT_RETRY_CONFIG;
|
|
343
357
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
358
|
+
lodash_1.default.forEach(retries, retry => {
|
|
359
|
+
step.addRetry({
|
|
360
|
+
...retry,
|
|
361
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
362
|
+
});
|
|
363
|
+
});
|
|
348
364
|
return step;
|
|
349
365
|
}
|
|
350
366
|
/**
|
|
@@ -369,10 +385,12 @@ class SfnManager {
|
|
|
369
385
|
if (!retries || retries.length === 0) {
|
|
370
386
|
retries = DEFAULT_RETRY_CONFIG;
|
|
371
387
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
388
|
+
lodash_1.default.forEach(retries, retry => {
|
|
389
|
+
step.addRetry({
|
|
390
|
+
...retry,
|
|
391
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
392
|
+
});
|
|
393
|
+
});
|
|
376
394
|
return step;
|
|
377
395
|
}
|
|
378
396
|
/**
|
|
@@ -394,10 +412,12 @@ class SfnManager {
|
|
|
394
412
|
if (!retries || retries.length === 0) {
|
|
395
413
|
retries = DEFAULT_RETRY_CONFIG;
|
|
396
414
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
415
|
+
lodash_1.default.forEach(retries, retry => {
|
|
416
|
+
step.addRetry({
|
|
417
|
+
...retry,
|
|
418
|
+
...{ interval: retry.intervalInSecs ? aws_cdk_lib_1.Duration.seconds(retry.intervalInSecs) : retry.interval },
|
|
419
|
+
});
|
|
420
|
+
});
|
|
401
421
|
return step;
|
|
402
422
|
}
|
|
403
423
|
/**
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.VpcManager = void 0;
|
|
4
7
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
8
|
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
|
6
9
|
const utils_1 = require("../../utils");
|
|
10
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
11
|
/**
|
|
8
12
|
*/
|
|
9
13
|
const CommonVpcIdentifier = 'CommonVpc';
|
|
@@ -38,10 +42,10 @@ class VpcManager {
|
|
|
38
42
|
maxAzs: props.maxAzs,
|
|
39
43
|
});
|
|
40
44
|
(0, utils_1.createCfnOutput)(`${id}Id`, scope, vpc.vpcId);
|
|
41
|
-
(0, utils_1.createCfnOutput)(`${id}PublicSubnetIds`, scope,
|
|
42
|
-
(0, utils_1.createCfnOutput)(`${id}PrivateSubnetIds`, scope,
|
|
43
|
-
(0, utils_1.createCfnOutput)(`${id}PublicSubnetRouteTableIds`, scope,
|
|
44
|
-
(0, utils_1.createCfnOutput)(`${id}PrivateSubnetRouteTableIds`, scope,
|
|
45
|
+
(0, utils_1.createCfnOutput)(`${id}PublicSubnetIds`, scope, lodash_1.default.map(vpc.publicSubnets, subnet => subnet.subnetId).toString());
|
|
46
|
+
(0, utils_1.createCfnOutput)(`${id}PrivateSubnetIds`, scope, lodash_1.default.map(vpc.privateSubnets, subnet => subnet.subnetId).toString());
|
|
47
|
+
(0, utils_1.createCfnOutput)(`${id}PublicSubnetRouteTableIds`, scope, lodash_1.default.map(vpc.publicSubnets, subnet => subnet.routeTable.routeTableId).toString());
|
|
48
|
+
(0, utils_1.createCfnOutput)(`${id}PrivateSubnetRouteTableIds`, scope, lodash_1.default.map(vpc.privateSubnets, subnet => subnet.routeTable.routeTableId).toString());
|
|
45
49
|
(0, utils_1.createCfnOutput)(`${id}AvailabilityZones`, scope, vpc.availabilityZones.toString());
|
|
46
50
|
(0, utils_1.createCfnOutput)(`${id}DefaultSecurityGroup`, scope, vpc.vpcDefaultSecurityGroup.toString());
|
|
47
51
|
return vpc;
|
|
@@ -1,17 +1,2 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./aws"), exports);
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
+
import { CfnOutput } from 'aws-cdk-lib';
|
|
3
|
+
import { CommonConstruct } from '../common';
|
|
2
4
|
/**
|
|
5
|
+
* @summary Helper method to add CloudFormation outputs from the construct
|
|
6
|
+
* @param id scoped id of the resource
|
|
7
|
+
* @param scope scope in which this resource is defined
|
|
8
|
+
* @param value the value of the exported output
|
|
9
|
+
* @param description optional description for the output
|
|
10
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
11
|
+
* @returns The CloudFormation output
|
|
3
12
|
*/
|
|
4
|
-
export declare
|
|
5
|
-
DEBUG = "DEBUG",
|
|
6
|
-
INFO = "INFO",
|
|
7
|
-
WARNING = "WARNING",
|
|
8
|
-
TRACE = "TRACE",
|
|
9
|
-
ERROR = "ERROR",
|
|
10
|
-
CRITICAL = "CRITICAL"
|
|
11
|
-
}
|
|
13
|
+
export declare function createCfnOutput(id: string, scope: CommonConstruct, value?: string, description?: string, overrideId?: boolean): CfnOutput;
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
*
|
|
14
16
|
*/
|
|
15
|
-
export declare
|
|
16
|
-
/**
|
|
17
|
-
* @param stage
|
|
18
|
-
*/
|
|
19
|
-
export declare const isTestStage: (stage: string) => boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @param stage
|
|
22
|
-
*/
|
|
23
|
-
export declare const isUatStage: (stage: string) => boolean;
|
|
24
|
-
/**
|
|
25
|
-
* @param stage
|
|
26
|
-
*/
|
|
27
|
-
export declare const isPrdStage: (stage: string) => boolean;
|
|
17
|
+
export declare function determineCredentials(): AwsCredentialIdentityProvider;
|
|
28
18
|
/**
|
|
29
19
|
* @param error
|
|
30
20
|
*/
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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);
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.redirectSuccess = exports.redirectError = exports.
|
|
18
|
-
|
|
6
|
+
exports.redirectSuccess = exports.redirectError = exports.determineCredentials = exports.createCfnOutput = void 0;
|
|
7
|
+
const credential_providers_1 = require("@aws-sdk/credential-providers");
|
|
8
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
/**
|
|
11
|
+
* @summary Helper method to add CloudFormation outputs from the construct
|
|
12
|
+
* @param id scoped id of the resource
|
|
13
|
+
* @param scope scope in which this resource is defined
|
|
14
|
+
* @param value the value of the exported output
|
|
15
|
+
* @param description optional description for the output
|
|
16
|
+
* @param overrideId Flag which indicates whether to override the default logical id of the output
|
|
17
|
+
* @returns The CloudFormation output
|
|
18
|
+
*/
|
|
19
|
+
function createCfnOutput(id, scope, value, description, overrideId = true) {
|
|
20
|
+
const camelName = lodash_1.default.camelCase(id);
|
|
21
|
+
const output = new aws_cdk_lib_1.CfnOutput(scope, id, {
|
|
22
|
+
description,
|
|
23
|
+
exportName: `${scope.props.stackName}-${camelName}`,
|
|
24
|
+
value: value ?? '',
|
|
25
|
+
});
|
|
26
|
+
if (overrideId) {
|
|
27
|
+
output.overrideLogicalId(camelName);
|
|
28
|
+
}
|
|
29
|
+
return output;
|
|
30
|
+
}
|
|
31
|
+
exports.createCfnOutput = createCfnOutput;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
function determineCredentials() {
|
|
36
|
+
if (process.env.AWS_PROFILE)
|
|
37
|
+
return (0, credential_providers_1.fromIni)();
|
|
38
|
+
return (0, credential_providers_1.fromEnv)();
|
|
39
|
+
}
|
|
40
|
+
exports.determineCredentials = determineCredentials;
|
|
19
41
|
/**
|
|
20
42
|
*/
|
|
21
43
|
const defaultResponseObject = {
|
|
@@ -26,37 +48,6 @@ const defaultResponseObject = {
|
|
|
26
48
|
isBase64Encoded: false,
|
|
27
49
|
statusCode: 200,
|
|
28
50
|
};
|
|
29
|
-
/**
|
|
30
|
-
*/
|
|
31
|
-
var LogLevel;
|
|
32
|
-
(function (LogLevel) {
|
|
33
|
-
LogLevel["DEBUG"] = "DEBUG";
|
|
34
|
-
LogLevel["INFO"] = "INFO";
|
|
35
|
-
LogLevel["WARNING"] = "WARNING";
|
|
36
|
-
LogLevel["TRACE"] = "TRACE";
|
|
37
|
-
LogLevel["ERROR"] = "ERROR";
|
|
38
|
-
LogLevel["CRITICAL"] = "CRITICAL";
|
|
39
|
-
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
40
|
-
/**
|
|
41
|
-
* @param stage
|
|
42
|
-
*/
|
|
43
|
-
const isDevStage = (stage) => stage === 'dev';
|
|
44
|
-
exports.isDevStage = isDevStage;
|
|
45
|
-
/**
|
|
46
|
-
* @param stage
|
|
47
|
-
*/
|
|
48
|
-
const isTestStage = (stage) => stage === 'tst';
|
|
49
|
-
exports.isTestStage = isTestStage;
|
|
50
|
-
/**
|
|
51
|
-
* @param stage
|
|
52
|
-
*/
|
|
53
|
-
const isUatStage = (stage) => stage === 'uat';
|
|
54
|
-
exports.isUatStage = isUatStage;
|
|
55
|
-
/**
|
|
56
|
-
* @param stage
|
|
57
|
-
*/
|
|
58
|
-
const isPrdStage = (stage) => stage === 'prd';
|
|
59
|
-
exports.isPrdStage = isPrdStage;
|
|
60
51
|
/**
|
|
61
52
|
* @param error
|
|
62
53
|
*/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TerraformStack } from 'cdktf';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import { AzureStorageManager } from '../services';
|
|
4
|
+
import { CommonAzureStackProps } from './types';
|
|
5
|
+
export declare class CommonAzureConstruct extends TerraformStack {
|
|
6
|
+
props: CommonAzureStackProps;
|
|
7
|
+
id: string;
|
|
8
|
+
fullyQualifiedDomainName: string;
|
|
9
|
+
storageManager: AzureStorageManager;
|
|
10
|
+
constructor(scope: Construct, id: string, props: CommonAzureStackProps);
|
|
11
|
+
/**
|
|
12
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
13
|
+
*/
|
|
14
|
+
protected determineFullyQualifiedDomain(): void;
|
|
15
|
+
/**
|
|
16
|
+
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
17
|
+
* This is determined by the stage property injected via cdk context
|
|
18
|
+
*/
|
|
19
|
+
isDevelopmentStage: () => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* @summary Utility method to determine if the initialisation is in test (tst) stage
|
|
22
|
+
* This is determined by the stage property injected via cdk context
|
|
23
|
+
*/
|
|
24
|
+
isTestStage: () => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @summary Utility method to determine if the initialisation is in uat (uat) stage
|
|
27
|
+
* This is determined by the stage property injected via cdk context
|
|
28
|
+
*/
|
|
29
|
+
isUatStage: () => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @summary Utility method to determine if the initialisation is in production (prd) stage
|
|
32
|
+
* This is determined by the stage property injected via cdk context
|
|
33
|
+
*/
|
|
34
|
+
isProductionStage: () => boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonAzureConstruct = void 0;
|
|
4
|
+
const provider_1 = require("@cdktf/provider-azurerm/lib/provider");
|
|
5
|
+
const cdktf_1 = require("cdktf");
|
|
6
|
+
const common_1 = require("../../common");
|
|
7
|
+
const services_1 = require("../services");
|
|
8
|
+
class CommonAzureConstruct extends cdktf_1.TerraformStack {
|
|
9
|
+
id;
|
|
10
|
+
fullyQualifiedDomainName;
|
|
11
|
+
storageManager;
|
|
12
|
+
constructor(scope, id, props) {
|
|
13
|
+
super(scope, id);
|
|
14
|
+
this.props = props;
|
|
15
|
+
this.id = id;
|
|
16
|
+
this.storageManager = new services_1.AzureStorageManager();
|
|
17
|
+
this.determineFullyQualifiedDomain();
|
|
18
|
+
new provider_1.AzurermProvider(this, `${this.id}-provider`, this.props);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
22
|
+
*/
|
|
23
|
+
determineFullyQualifiedDomain() {
|
|
24
|
+
this.fullyQualifiedDomainName = this.props.subDomain
|
|
25
|
+
? `${this.props.subDomain}.${this.props.domainName}`
|
|
26
|
+
: this.props.domainName;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @summary Utility method to determine if the initialisation is in development (dev) stage
|
|
30
|
+
* This is determined by the stage property injected via cdk context
|
|
31
|
+
*/
|
|
32
|
+
isDevelopmentStage = () => (0, common_1.isDevStage)(this.props.stage);
|
|
33
|
+
/**
|
|
34
|
+
* @summary Utility method to determine if the initialisation is in test (tst) stage
|
|
35
|
+
* This is determined by the stage property injected via cdk context
|
|
36
|
+
*/
|
|
37
|
+
isTestStage = () => (0, common_1.isTestStage)(this.props.stage);
|
|
38
|
+
/**
|
|
39
|
+
* @summary Utility method to determine if the initialisation is in uat (uat) stage
|
|
40
|
+
* This is determined by the stage property injected via cdk context
|
|
41
|
+
*/
|
|
42
|
+
isUatStage = () => (0, common_1.isUatStage)(this.props.stage);
|
|
43
|
+
/**
|
|
44
|
+
* @summary Utility method to determine if the initialisation is in production (prd) stage
|
|
45
|
+
* This is determined by the stage property injected via cdk context
|
|
46
|
+
*/
|
|
47
|
+
isProductionStage = () => (0, common_1.isPrdStage)(this.props.stage);
|
|
48
|
+
}
|
|
49
|
+
exports.CommonAzureConstruct = CommonAzureConstruct;
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./construct"), exports);
|
|
18
|
+
__exportStar(require("./stack"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CommonAzureConstruct } from './construct';
|
|
2
|
+
import { CommonAzureStackProps } from './types';
|
|
3
|
+
import { TerraformStack } from 'cdktf';
|
|
4
|
+
import { Construct } from 'constructs';
|
|
5
|
+
/**
|
|
6
|
+
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
7
|
+
* @example
|
|
8
|
+
* import { CommonAzureStack } from '@gradientedge/cdk-utils'
|
|
9
|
+
*
|
|
10
|
+
* class CustomStack extends CommonAzureStack {
|
|
11
|
+
* constructor(parent: App, name: string, props: StackProps) {
|
|
12
|
+
* super(parent, name, props)
|
|
13
|
+
* // provision resources
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
export declare class CommonAzureStack extends TerraformStack {
|
|
18
|
+
construct: CommonAzureConstruct;
|
|
19
|
+
props: CommonAzureStackProps;
|
|
20
|
+
constructor(parent: Construct, name: string, props: CommonAzureStackProps);
|
|
21
|
+
/**
|
|
22
|
+
* @summary Method to determine the core CDK construct properties injected via context cdktf.json
|
|
23
|
+
* @param props The stack properties
|
|
24
|
+
* @returns The stack properties
|
|
25
|
+
*/
|
|
26
|
+
protected determineConstructProps(props: CommonAzureStackProps): {
|
|
27
|
+
domainName: any;
|
|
28
|
+
extraContexts: any;
|
|
29
|
+
features: any;
|
|
30
|
+
name: any;
|
|
31
|
+
resourceGroupName: any;
|
|
32
|
+
skipStageForARecords: any;
|
|
33
|
+
stage: any;
|
|
34
|
+
subDomain: any;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @summary Method to determine extra cdk contexts apart from the main cdktf.json
|
|
38
|
+
* - Sets the properties from the extra contexts into cdk node context
|
|
39
|
+
* - Primary use is to have layered config in separate files to enable easier maintenance and readability
|
|
40
|
+
*/
|
|
41
|
+
protected determineExtraContexts(): void;
|
|
42
|
+
/**
|
|
43
|
+
* @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
|
|
44
|
+
* - Sets the properties from the extra stage contexts into cdk node context
|
|
45
|
+
* - Primary use is to have layered config for each environment which is injected into the context
|
|
46
|
+
*/
|
|
47
|
+
protected determineStageContexts(): void;
|
|
48
|
+
/**
|
|
49
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
50
|
+
*/
|
|
51
|
+
protected fullyQualifiedDomain(): any;
|
|
52
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.CommonAzureStack = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const construct_1 = require("./construct");
|
|
9
|
+
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
10
|
+
const cdktf_1 = require("cdktf");
|
|
11
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
12
|
+
const common_1 = require("../../common");
|
|
13
|
+
/**
|
|
14
|
+
* @classdesc Common stack to use as a base for all higher level constructs.
|
|
15
|
+
* @example
|
|
16
|
+
* import { CommonAzureStack } from '@gradientedge/cdk-utils'
|
|
17
|
+
*
|
|
18
|
+
* class CustomStack extends CommonAzureStack {
|
|
19
|
+
* constructor(parent: App, name: string, props: StackProps) {
|
|
20
|
+
* super(parent, name, props)
|
|
21
|
+
* // provision resources
|
|
22
|
+
* }
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
class CommonAzureStack extends cdktf_1.TerraformStack {
|
|
26
|
+
construct;
|
|
27
|
+
props;
|
|
28
|
+
constructor(parent, name, props) {
|
|
29
|
+
super(parent, name);
|
|
30
|
+
/* determine extra cdk contexts */
|
|
31
|
+
this.determineExtraContexts();
|
|
32
|
+
/* determine extra cdk stage contexts */
|
|
33
|
+
this.determineStageContexts();
|
|
34
|
+
this.props = this.determineConstructProps(props);
|
|
35
|
+
/* initialise the construct */
|
|
36
|
+
this.construct = new construct_1.CommonAzureConstruct(this, 'cdk-utils', this.props);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @summary Method to determine the core CDK construct properties injected via context cdktf.json
|
|
40
|
+
* @param props The stack properties
|
|
41
|
+
* @returns The stack properties
|
|
42
|
+
*/
|
|
43
|
+
determineConstructProps(props) {
|
|
44
|
+
return {
|
|
45
|
+
domainName: this.node.tryGetContext('domainName'),
|
|
46
|
+
extraContexts: this.node.tryGetContext('extraContexts'),
|
|
47
|
+
features: this.node.tryGetContext('features'),
|
|
48
|
+
name: this.node.tryGetContext('resourceGroupName'),
|
|
49
|
+
resourceGroupName: this.node.tryGetContext('resourceGroupName'),
|
|
50
|
+
skipStageForARecords: this.node.tryGetContext('skipStageForARecords'),
|
|
51
|
+
stage: this.node.tryGetContext('stage'),
|
|
52
|
+
subDomain: this.node.tryGetContext('subDomain'),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @summary Method to determine extra cdk contexts apart from the main cdktf.json
|
|
57
|
+
* - Sets the properties from the extra contexts into cdk node context
|
|
58
|
+
* - Primary use is to have layered config in separate files to enable easier maintenance and readability
|
|
59
|
+
*/
|
|
60
|
+
determineExtraContexts() {
|
|
61
|
+
const extraContexts = this.node.tryGetContext('extraContexts');
|
|
62
|
+
const debug = this.node.tryGetContext('debug');
|
|
63
|
+
if (!extraContexts) {
|
|
64
|
+
if (debug)
|
|
65
|
+
console.debug(`No additional contexts provided. Using default context properties from cdktf.json`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
lodash_1.default.forEach(extraContexts, (context) => {
|
|
69
|
+
const extraContextPath = `${app_root_path_1.default.path}/${context}`;
|
|
70
|
+
/* scenario where extra context is configured in cdk.json but absent in file system */
|
|
71
|
+
if (!fs_1.default.existsSync(extraContextPath))
|
|
72
|
+
throw `Extra context properties unavailable in path:${extraContextPath}`;
|
|
73
|
+
/* read the extra properties */
|
|
74
|
+
const extraContextPropsBuffer = fs_1.default.readFileSync(extraContextPath);
|
|
75
|
+
if (debug)
|
|
76
|
+
console.debug(`Adding additional contexts provided in ${extraContextPath}`);
|
|
77
|
+
/* parse as JSON properties */
|
|
78
|
+
const extraContextProps = JSON.parse(extraContextPropsBuffer.toString('utf-8'));
|
|
79
|
+
/* set each of the property into the cdk node context */
|
|
80
|
+
lodash_1.default.keys(extraContextProps).forEach((propKey) => {
|
|
81
|
+
this.node.setContext(propKey, extraContextProps[propKey]);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @summary Method to determine extra cdk stage contexts apart from the main cdktf.json
|
|
87
|
+
* - Sets the properties from the extra stage contexts into cdk node context
|
|
88
|
+
* - Primary use is to have layered config for each environment which is injected into the context
|
|
89
|
+
*/
|
|
90
|
+
determineStageContexts() {
|
|
91
|
+
const stage = this.node.tryGetContext('stage');
|
|
92
|
+
const stageContextPath = this.node.tryGetContext('stageContextPath') || 'cdkEnv';
|
|
93
|
+
const stageContextFilePath = `${app_root_path_1.default.path}/${stageContextPath}/${stage}.json`;
|
|
94
|
+
const debug = this.node.tryGetContext('debug');
|
|
95
|
+
if ((0, common_1.isDevStage)(stage)) {
|
|
96
|
+
if (debug)
|
|
97
|
+
console.debug(`Development stage. Using default stage context properties`);
|
|
98
|
+
}
|
|
99
|
+
/* alert default context usage when extra stage config is missing */
|
|
100
|
+
if (!fs_1.default.existsSync(stageContextFilePath)) {
|
|
101
|
+
if (debug)
|
|
102
|
+
console.debug(`Stage specific context properties unavailable in path:${stageContextFilePath}`);
|
|
103
|
+
if (debug)
|
|
104
|
+
console.debug(`Using default stage context properties for ${stage} stage`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
/* read the extra properties */
|
|
108
|
+
const stageContextPropsBuffer = fs_1.default.readFileSync(stageContextFilePath);
|
|
109
|
+
if (debug)
|
|
110
|
+
console.debug(`Adding additional stage contexts provided in ${stageContextFilePath}`);
|
|
111
|
+
/* parse as JSON properties */
|
|
112
|
+
const stageContextProps = JSON.parse(stageContextPropsBuffer.toString('utf-8'));
|
|
113
|
+
/* set each of the property into the cdk node context */
|
|
114
|
+
lodash_1.default.keys(stageContextProps).forEach((propKey) => {
|
|
115
|
+
/* handle object, array properties */
|
|
116
|
+
if (typeof stageContextProps[propKey] === 'object' && !Array.isArray(stageContextProps[propKey])) {
|
|
117
|
+
this.node.setContext(propKey, lodash_1.default.merge(this.node.tryGetContext(propKey), stageContextProps[propKey]));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
/* handle all other primitive properties */
|
|
121
|
+
this.node.setContext(propKey, stageContextProps[propKey]);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @summary Determine the fully qualified domain name based on domainName & subDomain
|
|
127
|
+
*/
|
|
128
|
+
fullyQualifiedDomain() {
|
|
129
|
+
const domainName = this.node.tryGetContext('domainName');
|
|
130
|
+
const subDomain = this.node.tryGetContext('subDomain');
|
|
131
|
+
return subDomain ? `${subDomain}.${domainName}` : domainName;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.CommonAzureStack = CommonAzureStack;
|