@gradientedge/cdk-utils 8.117.0 → 8.119.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/app/api-destined-function/package.json +1 -1
- package/dist/src/lib/common/construct.d.ts +32 -32
- package/dist/src/lib/common/construct.js +36 -59
- package/dist/src/lib/common/stack.d.ts +8 -7
- package/dist/src/lib/common/stack.js +17 -37
- package/dist/src/lib/common/types.d.ts +2 -2
- package/dist/src/lib/construct/api-to-eventbridge-target/api.d.ts +22 -22
- package/dist/src/lib/construct/api-to-eventbridge-target/event.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target/main.js +37 -60
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.d.ts +9 -9
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.d.ts +3 -3
- package/dist/src/lib/construct/api-to-eventbridge-target-with-sns/main.js +40 -63
- package/dist/src/lib/construct/api-to-lambda-target/api.d.ts +23 -23
- package/dist/src/lib/construct/api-to-lambda-target/main.d.ts +2 -2
- package/dist/src/lib/construct/api-to-lambda-target/main.js +15 -38
- package/dist/src/lib/construct/application-configuration/main.d.ts +7 -7
- package/dist/src/lib/construct/application-configuration/main.js +17 -41
- package/dist/src/lib/construct/graphql-api-lambda/main.d.ts +17 -17
- package/dist/src/lib/construct/graphql-api-lambda/main.js +6 -29
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +7 -7
- package/dist/src/lib/construct/lambda-with-iam-access/main.d.ts +16 -16
- package/dist/src/lib/construct/lambda-with-iam-access/main.js +8 -31
- package/dist/src/lib/construct/lambda-with-iam-access/types.d.ts +4 -4
- package/dist/src/lib/construct/rest-api-lambda/main.d.ts +16 -16
- package/dist/src/lib/construct/rest-api-lambda/main.js +5 -28
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.d.ts +5 -5
- package/dist/src/lib/construct/rest-api-lambda-with-cache/main.js +9 -32
- package/dist/src/lib/construct/site-with-ecs-backend/main.d.ts +38 -39
- package/dist/src/lib/construct/site-with-ecs-backend/main.js +33 -54
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +4 -4
- package/dist/src/lib/construct/static-asset-deployment/main.js +3 -26
- package/dist/src/lib/construct/static-site/main.d.ts +15 -15
- package/dist/src/lib/construct/static-site/main.js +4 -27
- package/dist/src/lib/services/aws/api-gateway/main.d.ts +10 -10
- package/dist/src/lib/services/aws/api-gateway/main.js +21 -44
- package/dist/src/lib/services/aws/api-gateway/types.d.ts +2 -2
- package/dist/src/lib/services/aws/appconfig/main.d.ts +7 -7
- package/dist/src/lib/services/aws/appconfig/main.js +14 -37
- package/dist/src/lib/services/aws/certificate-manager/main.d.ts +5 -5
- package/dist/src/lib/services/aws/certificate-manager/main.js +10 -33
- package/dist/src/lib/services/aws/certificate-manager/types.d.ts +2 -2
- package/dist/src/lib/services/aws/cloudfront/main.d.ts +18 -18
- package/dist/src/lib/services/aws/cloudfront/main.js +46 -45
- package/dist/src/lib/services/aws/cloudfront/types.d.ts +2 -3
- package/dist/src/lib/services/aws/cloudtrail/main.d.ts +5 -5
- package/dist/src/lib/services/aws/cloudtrail/main.js +5 -28
- package/dist/src/lib/services/aws/codebuild/main.d.ts +3 -3
- package/dist/src/lib/services/aws/codebuild/main.js +7 -30
- package/dist/src/lib/services/aws/dynamodb/main.d.ts +3 -3
- package/dist/src/lib/services/aws/dynamodb/main.js +8 -31
- package/dist/src/lib/services/aws/elastic-container-registry/main.d.ts +2 -2
- package/dist/src/lib/services/aws/elastic-container-registry/main.js +4 -27
- package/dist/src/lib/services/aws/elastic-container-service/main.d.ts +10 -10
- package/dist/src/lib/services/aws/elastic-container-service/main.js +27 -50
- package/dist/src/lib/services/aws/elastic-container-service/types.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-file-system/main.d.ts +3 -3
- package/dist/src/lib/services/aws/elastic-file-system/main.js +12 -35
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elastic-kubernetes-service/main.js +8 -31
- package/dist/src/lib/services/aws/elasticache/main.d.ts +4 -4
- package/dist/src/lib/services/aws/elasticache/main.js +10 -33
- package/dist/src/lib/services/aws/eventbridge/main.d.ts +13 -13
- package/dist/src/lib/services/aws/eventbridge/main.js +26 -49
- package/dist/src/lib/services/aws/eventbridge/target.d.ts +10 -10
- package/dist/src/lib/services/aws/eventbridge/target.js +6 -29
- package/dist/src/lib/services/aws/evidently/main.d.ts +7 -7
- package/dist/src/lib/services/aws/evidently/main.js +18 -41
- package/dist/src/lib/services/aws/identity-access-management/main.d.ts +48 -49
- package/dist/src/lib/services/aws/identity-access-management/main.js +110 -133
- package/dist/src/lib/services/aws/key-management-service/main.d.ts +2 -2
- package/dist/src/lib/services/aws/key-management-service/main.js +5 -28
- package/dist/src/lib/services/aws/lambda/main.d.ts +11 -13
- package/dist/src/lib/services/aws/lambda/main.js +31 -58
- package/dist/src/lib/services/aws/route53/main.d.ts +9 -9
- package/dist/src/lib/services/aws/route53/main.js +21 -44
- package/dist/src/lib/services/aws/secrets-manager/main.d.ts +5 -6
- package/dist/src/lib/services/aws/secrets-manager/main.js +10 -33
- package/dist/src/lib/services/aws/simple-notification-service/main.d.ts +4 -4
- package/dist/src/lib/services/aws/simple-notification-service/main.js +11 -34
- package/dist/src/lib/services/aws/simple-queue-service/main.d.ts +6 -7
- package/dist/src/lib/services/aws/simple-queue-service/main.js +15 -38
- package/dist/src/lib/services/aws/simple-storage-service/main.d.ts +10 -11
- package/dist/src/lib/services/aws/simple-storage-service/main.js +31 -54
- package/dist/src/lib/services/aws/step-function/main.d.ts +31 -32
- package/dist/src/lib/services/aws/step-function/main.js +33 -57
- package/dist/src/lib/services/aws/systems-manager/main.d.ts +4 -4
- package/dist/src/lib/services/aws/systems-manager/main.js +10 -33
- package/dist/src/lib/services/aws/virtual-private-cloud/main.d.ts +5 -6
- package/dist/src/lib/services/aws/virtual-private-cloud/main.js +14 -37
- package/dist/src/lib/services/aws/web-application-firewall/main.d.ts +3 -3
- package/dist/src/lib/services/aws/web-application-firewall/main.js +8 -31
- package/dist/src/lib/utils/aws/index.d.ts +6 -3
- package/dist/src/lib/utils/aws/index.js +9 -26
- package/package.json +21 -21
- package/src/lib/common/construct.ts +97 -67
- package/src/lib/common/stack.ts +12 -12
- package/src/lib/common/types.ts +2 -2
- package/src/lib/construct/api-to-eventbridge-target/api.ts +31 -22
- package/src/lib/construct/api-to-eventbridge-target/event.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target/main.ts +56 -41
- package/src/lib/construct/api-to-eventbridge-target-with-sns/api-destined-lambda.ts +9 -9
- package/src/lib/construct/api-to-eventbridge-target-with-sns/main.ts +62 -47
- package/src/lib/construct/api-to-lambda-target/api.ts +33 -23
- package/src/lib/construct/api-to-lambda-target/main.ts +24 -18
- package/src/lib/construct/application-configuration/main.ts +31 -24
- package/src/lib/construct/graphql-api-lambda/main.ts +22 -22
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +13 -13
- package/src/lib/construct/lambda-with-iam-access/main.ts +25 -25
- package/src/lib/construct/lambda-with-iam-access/types.ts +4 -4
- package/src/lib/construct/rest-api-lambda/main.ts +21 -21
- package/src/lib/construct/rest-api-lambda-with-cache/main.ts +14 -14
- package/src/lib/construct/site-with-ecs-backend/main.ts +79 -60
- package/src/lib/construct/static-asset-deployment/main.ts +6 -6
- package/src/lib/construct/static-site/main.ts +23 -17
- package/src/lib/services/aws/api-gateway/main.ts +42 -36
- package/src/lib/services/aws/api-gateway/types.ts +2 -2
- package/src/lib/services/aws/appconfig/main.ts +19 -19
- package/src/lib/services/aws/certificate-manager/main.ts +14 -14
- package/src/lib/services/aws/certificate-manager/types.ts +2 -2
- package/src/lib/services/aws/cloudfront/main.ts +88 -74
- package/src/lib/services/aws/cloudfront/types.ts +6 -3
- package/src/lib/services/aws/cloudtrail/main.ts +11 -11
- package/src/lib/services/aws/codebuild/main.ts +7 -7
- package/src/lib/services/aws/dynamodb/main.ts +8 -8
- package/src/lib/services/aws/elastic-container-registry/main.ts +4 -4
- package/src/lib/services/aws/elastic-container-service/main.ts +48 -37
- package/src/lib/services/aws/elastic-container-service/types.ts +4 -4
- package/src/lib/services/aws/elastic-file-system/main.ts +16 -16
- package/src/lib/services/aws/elastic-kubernetes-service/main.ts +11 -11
- package/src/lib/services/aws/elasticache/main.ts +10 -10
- package/src/lib/services/aws/eventbridge/main.ts +37 -37
- package/src/lib/services/aws/eventbridge/target.ts +14 -14
- package/src/lib/services/aws/evidently/main.ts +18 -18
- package/src/lib/services/aws/identity-access-management/main.ts +142 -134
- package/src/lib/services/aws/key-management-service/main.ts +5 -5
- package/src/lib/services/aws/lambda/main.ts +65 -59
- package/src/lib/services/aws/route53/main.ts +31 -31
- package/src/lib/services/aws/secrets-manager/main.ts +11 -15
- package/src/lib/services/aws/simple-notification-service/main.ts +13 -13
- package/src/lib/services/aws/simple-queue-service/main.ts +18 -18
- package/src/lib/services/aws/simple-storage-service/main.ts +40 -40
- package/src/lib/services/aws/step-function/main.ts +77 -65
- package/src/lib/services/aws/systems-manager/main.ts +17 -12
- package/src/lib/services/aws/virtual-private-cloud/main.ts +16 -16
- package/src/lib/services/aws/web-application-firewall/main.ts +8 -8
- package/src/lib/utils/aws/index.ts +8 -5
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
6
|
-
import { IVersion } from 'aws-cdk-lib/aws-lambda';
|
|
1
|
+
import { ISecurityGroup, IVpc, SubnetSelection } from 'aws-cdk-lib/aws-ec2';
|
|
2
|
+
import { IAccessPoint } from 'aws-cdk-lib/aws-efs';
|
|
3
|
+
import { CfnRole, Role } from 'aws-cdk-lib/aws-iam';
|
|
4
|
+
import { Alias, AssetCode, DockerImageCode, DockerImageFunction, Function, ILayerVersion, IVersion, LayerVersion } from 'aws-cdk-lib/aws-lambda';
|
|
7
5
|
import { CommonConstruct } from '../../../common';
|
|
8
6
|
import { LambdaAliasProps, LambdaEdgeProps, LambdaProps } from './types';
|
|
9
7
|
/**
|
|
10
|
-
* @classdesc Provides operations on AWS Lambda
|
|
8
|
+
* @classdesc Provides operations on AWS Lambda
|
|
11
9
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
12
10
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
13
11
|
* @example
|
|
14
12
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
15
13
|
*
|
|
16
14
|
* class CustomConstruct extends CommonConstruct {
|
|
17
|
-
* constructor(parent:
|
|
15
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
18
16
|
* super(parent, id, props)
|
|
19
17
|
* this.props = props
|
|
20
18
|
* this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
@@ -29,7 +27,7 @@ export declare class LambdaManager {
|
|
|
29
27
|
* @param scope scope in which this resource is defined
|
|
30
28
|
* @param code
|
|
31
29
|
*/
|
|
32
|
-
createLambdaLayer(id: string, scope: CommonConstruct, code:
|
|
30
|
+
createLambdaLayer(id: string, scope: CommonConstruct, code: AssetCode): LayerVersion;
|
|
33
31
|
/**
|
|
34
32
|
* @summary Method to create a lambda function (nodejs)
|
|
35
33
|
* @param id scoped id of the resource
|
|
@@ -46,7 +44,7 @@ export declare class LambdaManager {
|
|
|
46
44
|
* @param mountPath
|
|
47
45
|
* @param vpcSubnets
|
|
48
46
|
*/
|
|
49
|
-
createLambdaFunction(id: string, scope: CommonConstruct, props: LambdaProps, role:
|
|
47
|
+
createLambdaFunction(id: string, scope: CommonConstruct, props: LambdaProps, role: Role | CfnRole, layers: ILayerVersion[], code: AssetCode, handler?: string, environment?: any, vpc?: IVpc, securityGroups?: ISecurityGroup[], accessPoint?: IAccessPoint, mountPath?: string, vpcSubnets?: SubnetSelection): Function;
|
|
50
48
|
/**
|
|
51
49
|
* @summary Method to provision a Lambda@Edge function
|
|
52
50
|
* @param id scoped id of the resource
|
|
@@ -61,7 +59,7 @@ export declare class LambdaManager {
|
|
|
61
59
|
* @param accessPoint
|
|
62
60
|
* @param mountPath
|
|
63
61
|
*/
|
|
64
|
-
createEdgeFunction(id: string, scope: CommonConstruct, props: LambdaEdgeProps, layers:
|
|
62
|
+
createEdgeFunction(id: string, scope: CommonConstruct, props: LambdaEdgeProps, layers: ILayerVersion[], code: AssetCode, role: Role, environment?: any, vpc?: IVpc, securityGroups?: ISecurityGroup[], accessPoint?: IAccessPoint, mountPath?: string): import("aws-cdk-lib/aws-cloudfront/lib/experimental").EdgeFunction;
|
|
65
63
|
/**
|
|
66
64
|
* @summary Method to create a lambda function (nodejs) with docker image
|
|
67
65
|
* @param id scoped id of the resource
|
|
@@ -76,7 +74,7 @@ export declare class LambdaManager {
|
|
|
76
74
|
* @param mountPath
|
|
77
75
|
* @param vpcSubnets
|
|
78
76
|
*/
|
|
79
|
-
createLambdaDockerFunction(id: string, scope: CommonConstruct, props: LambdaProps, role:
|
|
77
|
+
createLambdaDockerFunction(id: string, scope: CommonConstruct, props: LambdaProps, role: Role | CfnRole, code: DockerImageCode, environment?: any, vpc?: IVpc, securityGroups?: ISecurityGroup[], accessPoint?: IAccessPoint, mountPath?: string, vpcSubnets?: SubnetSelection): DockerImageFunction;
|
|
80
78
|
/**
|
|
81
79
|
* @summary Method to create a lambda function Alias
|
|
82
80
|
* @param id scoped id of the resource
|
|
@@ -84,5 +82,5 @@ export declare class LambdaManager {
|
|
|
84
82
|
* @param props
|
|
85
83
|
* @param lambdaVersion
|
|
86
84
|
*/
|
|
87
|
-
createLambdaFunctionAlias(id: string, scope: CommonConstruct, props: LambdaAliasProps, lambdaVersion: IVersion):
|
|
85
|
+
createLambdaFunctionAlias(id: string, scope: CommonConstruct, props: LambdaAliasProps, lambdaVersion: IVersion): Alias;
|
|
88
86
|
}
|
|
@@ -1,46 +1,23 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.LambdaManager = void 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const utils = __importStar(require("../../../utils"));
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
const aws_iam_1 = require("aws-cdk-lib/aws-iam");
|
|
6
|
+
const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
|
|
7
|
+
const aws_lambda_event_sources_1 = require("aws-cdk-lib/aws-lambda-event-sources");
|
|
32
8
|
const common_1 = require("../../../common");
|
|
9
|
+
const utils_1 = require("../../../utils");
|
|
33
10
|
const cloudfront_1 = require("../cloudfront");
|
|
34
11
|
const systems_manager_1 = require("../systems-manager");
|
|
35
12
|
/**
|
|
36
|
-
* @classdesc Provides operations on AWS Lambda
|
|
13
|
+
* @classdesc Provides operations on AWS Lambda
|
|
37
14
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
38
15
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
39
16
|
* @example
|
|
40
17
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
41
18
|
*
|
|
42
19
|
* class CustomConstruct extends CommonConstruct {
|
|
43
|
-
* constructor(parent:
|
|
20
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
44
21
|
* super(parent, id, props)
|
|
45
22
|
* this.props = props
|
|
46
23
|
* this.lambdaManager.createLambdaFunction('MyFunction', this, role, layers, code)
|
|
@@ -56,13 +33,13 @@ class LambdaManager {
|
|
|
56
33
|
* @param code
|
|
57
34
|
*/
|
|
58
35
|
createLambdaLayer(id, scope, code) {
|
|
59
|
-
const lambdaLayer = new
|
|
36
|
+
const lambdaLayer = new aws_lambda_1.LayerVersion(scope, `${id}`, {
|
|
60
37
|
code: code,
|
|
61
38
|
compatibleRuntimes: [scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME],
|
|
62
39
|
description: `${id}`,
|
|
63
40
|
layerVersionName: `${id}-${scope.props.stage}`,
|
|
64
41
|
});
|
|
65
|
-
|
|
42
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaLayerArn`, scope, lambdaLayer.layerVersionArn);
|
|
66
43
|
return lambdaLayer;
|
|
67
44
|
}
|
|
68
45
|
/**
|
|
@@ -90,11 +67,11 @@ class LambdaManager {
|
|
|
90
67
|
const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
|
|
91
68
|
deadLetterQueue = scope.sqsManager.createDeadLetterQueueForLambda(`${id}-dlq`, scope, props, redriveQueue);
|
|
92
69
|
}
|
|
93
|
-
const lambdaFunction = new
|
|
70
|
+
const lambdaFunction = new aws_lambda_1.Function(scope, `${id}`, {
|
|
94
71
|
...props,
|
|
95
72
|
...{
|
|
96
73
|
allowPublicSubnet: !!vpc,
|
|
97
|
-
architecture: props.architecture ??
|
|
74
|
+
architecture: props.architecture ?? aws_lambda_1.Architecture.ARM_64,
|
|
98
75
|
code: code,
|
|
99
76
|
deadLetterQueue: deadLetterQueue,
|
|
100
77
|
environment: {
|
|
@@ -105,26 +82,24 @@ class LambdaManager {
|
|
|
105
82
|
STAGE: scope.props.stage,
|
|
106
83
|
...environment,
|
|
107
84
|
},
|
|
108
|
-
filesystem: accessPoint
|
|
109
|
-
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
110
|
-
: undefined,
|
|
85
|
+
filesystem: accessPoint ? aws_lambda_1.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg') : undefined,
|
|
111
86
|
functionName: functionName,
|
|
112
87
|
handler: handler || 'index.lambda_handler',
|
|
113
88
|
insightsVersion: props.insightsVersion,
|
|
114
89
|
layers: layers,
|
|
115
90
|
logRetention: scope.props.logRetention ?? props.logRetention,
|
|
116
91
|
reservedConcurrentExecutions: props.reservedConcurrentExecutions ?? scope.props.defaultReservedLambdaConcurrentExecutions,
|
|
117
|
-
role: role instanceof
|
|
92
|
+
role: role instanceof aws_iam_1.Role ? role : undefined,
|
|
118
93
|
runtime: props.runtime ?? scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME,
|
|
119
94
|
securityGroups: securityGroups,
|
|
120
|
-
timeout: props.timeoutInSecs ?
|
|
95
|
+
timeout: props.timeoutInSecs ? aws_cdk_lib_1.Duration.seconds(props.timeoutInSecs) : aws_cdk_lib_1.Duration.minutes(15),
|
|
121
96
|
tracing: scope.props.defaultTracing ?? props.tracing,
|
|
122
97
|
vpc,
|
|
123
98
|
vpcSubnets,
|
|
124
99
|
},
|
|
125
100
|
});
|
|
126
101
|
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
127
|
-
lambdaFunction.addEventSource(new
|
|
102
|
+
lambdaFunction.addEventSource(new aws_lambda_event_sources_1.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
128
103
|
batchSize: props.dlq.retryBatchSize ?? 1,
|
|
129
104
|
reportBatchItemFailures: true,
|
|
130
105
|
}));
|
|
@@ -133,8 +108,8 @@ class LambdaManager {
|
|
|
133
108
|
props.lambdaAliases.forEach(alias => {
|
|
134
109
|
const aliasId = alias.id ?? `${id}-${alias.aliasName}`;
|
|
135
110
|
const functionAlias = this.createLambdaFunctionAlias(`${aliasId}`, scope, alias, lambdaFunction.currentVersion);
|
|
136
|
-
|
|
137
|
-
|
|
111
|
+
(0, utils_1.createCfnOutput)(`${id}-${alias.aliasName}AliasArn`, scope, functionAlias.functionArn);
|
|
112
|
+
(0, utils_1.createCfnOutput)(`${id}-${alias.aliasName}AliasName`, scope, functionAlias.aliasName);
|
|
138
113
|
if (alias.provisionedConcurrency) {
|
|
139
114
|
const functionAutoScaling = functionAlias.addAutoScaling(alias.provisionedConcurrency);
|
|
140
115
|
functionAutoScaling.scaleOnUtilization({
|
|
@@ -145,11 +120,11 @@ class LambdaManager {
|
|
|
145
120
|
}
|
|
146
121
|
if (props.tags && props.tags.length > 0) {
|
|
147
122
|
props.tags.forEach(tag => {
|
|
148
|
-
|
|
123
|
+
aws_cdk_lib_1.Tags.of(lambdaFunction).add(tag.key, tag.value);
|
|
149
124
|
});
|
|
150
125
|
}
|
|
151
|
-
|
|
152
|
-
|
|
126
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
|
|
127
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaName`, scope, lambdaFunction.functionName);
|
|
153
128
|
return lambdaFunction;
|
|
154
129
|
}
|
|
155
130
|
/**
|
|
@@ -192,11 +167,11 @@ class LambdaManager {
|
|
|
192
167
|
const redriveQueue = scope.sqsManager.createRedriveQueueForLambda(`${id}-rdq`, scope, props);
|
|
193
168
|
deadLetterQueue = scope.sqsManager.createDeadLetterQueueForLambda(`${id}-dlq`, scope, props, redriveQueue);
|
|
194
169
|
}
|
|
195
|
-
const lambdaFunction = new
|
|
170
|
+
const lambdaFunction = new aws_lambda_1.DockerImageFunction(scope, `${id}`, {
|
|
196
171
|
...props,
|
|
197
172
|
...{
|
|
198
173
|
allowPublicSubnet: !!vpc,
|
|
199
|
-
architecture: props.architecture ??
|
|
174
|
+
architecture: props.architecture ?? aws_lambda_1.Architecture.ARM_64,
|
|
200
175
|
code: code,
|
|
201
176
|
deadLetterQueue: deadLetterQueue,
|
|
202
177
|
environment: {
|
|
@@ -207,30 +182,28 @@ class LambdaManager {
|
|
|
207
182
|
STAGE: scope.props.stage,
|
|
208
183
|
...environment,
|
|
209
184
|
},
|
|
210
|
-
filesystem: accessPoint
|
|
211
|
-
? lambda.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg')
|
|
212
|
-
: undefined,
|
|
185
|
+
filesystem: accessPoint ? aws_lambda_1.FileSystem.fromEfsAccessPoint(accessPoint, mountPath || '/mnt/msg') : undefined,
|
|
213
186
|
functionName: functionName,
|
|
214
187
|
insightsVersion: props.insightsVersion,
|
|
215
188
|
logRetention: scope.props.logRetention ?? props.logRetention,
|
|
216
189
|
reservedConcurrentExecutions: props.reservedConcurrentExecutions,
|
|
217
|
-
role: role instanceof
|
|
190
|
+
role: role instanceof aws_iam_1.Role ? role : undefined,
|
|
218
191
|
runtime: props.runtime ?? scope.props.nodejsRuntime ?? common_1.CommonStack.NODEJS_RUNTIME,
|
|
219
192
|
securityGroups: securityGroups,
|
|
220
|
-
timeout: props.timeoutInSecs ?
|
|
193
|
+
timeout: props.timeoutInSecs ? aws_cdk_lib_1.Duration.seconds(props.timeoutInSecs) : aws_cdk_lib_1.Duration.minutes(1),
|
|
221
194
|
tracing: props.tracing,
|
|
222
195
|
vpc,
|
|
223
196
|
vpcSubnets,
|
|
224
197
|
},
|
|
225
198
|
});
|
|
226
199
|
if (lambdaFunction.deadLetterQueue && props.dlq?.retriesEnabled) {
|
|
227
|
-
lambdaFunction.addEventSource(new
|
|
200
|
+
lambdaFunction.addEventSource(new aws_lambda_event_sources_1.SqsEventSource(lambdaFunction.deadLetterQueue, {
|
|
228
201
|
batchSize: props.dlq.retryBatchSize ?? 1,
|
|
229
202
|
reportBatchItemFailures: true,
|
|
230
203
|
}));
|
|
231
204
|
}
|
|
232
|
-
|
|
233
|
-
|
|
205
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
|
|
206
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaName`, scope, lambdaFunction.functionName);
|
|
234
207
|
return lambdaFunction;
|
|
235
208
|
}
|
|
236
209
|
/**
|
|
@@ -243,7 +216,7 @@ class LambdaManager {
|
|
|
243
216
|
createLambdaFunctionAlias(id, scope, props, lambdaVersion) {
|
|
244
217
|
if (!props)
|
|
245
218
|
throw `Lambda Alias props undefined for ${id}`;
|
|
246
|
-
const lambdaFunctionAlias = new
|
|
219
|
+
const lambdaFunctionAlias = new aws_lambda_1.Alias(scope, `${id}`, {
|
|
247
220
|
...props,
|
|
248
221
|
...{
|
|
249
222
|
additionalVersions: props.additionalVersions,
|
|
@@ -257,8 +230,8 @@ class LambdaManager {
|
|
|
257
230
|
version: lambdaVersion,
|
|
258
231
|
},
|
|
259
232
|
});
|
|
260
|
-
|
|
261
|
-
|
|
233
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaAliasName`, scope, lambdaFunctionAlias.functionArn);
|
|
234
|
+
(0, utils_1.createCfnOutput)(`${id}-lambdaAliasArn`, scope, lambdaFunctionAlias.functionName);
|
|
262
235
|
return lambdaFunctionAlias;
|
|
263
236
|
}
|
|
264
237
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { DomainName } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { IDistribution } from 'aws-cdk-lib/aws-cloudfront';
|
|
3
|
+
import { ARecord, IHostedZone } from 'aws-cdk-lib/aws-route53';
|
|
4
4
|
import { CommonConstruct } from '../../../common';
|
|
5
5
|
import { Route53Props } from './types';
|
|
6
6
|
/**
|
|
7
|
-
* @classdesc Provides operations on AWS Route53
|
|
7
|
+
* @classdesc Provides operations on AWS Route53
|
|
8
8
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
9
9
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
10
10
|
* @example
|
|
@@ -26,14 +26,14 @@ export declare class Route53Manager {
|
|
|
26
26
|
* @param scope scope in which this resource is defined
|
|
27
27
|
* @param props
|
|
28
28
|
*/
|
|
29
|
-
createHostedZone(id: string, scope: CommonConstruct, props: Route53Props):
|
|
29
|
+
createHostedZone(id: string, scope: CommonConstruct, props: Route53Props): IHostedZone;
|
|
30
30
|
/**
|
|
31
31
|
* @summary Method to create/lookup a hosted zone
|
|
32
32
|
* @param id scoped id of the resource
|
|
33
33
|
* @param scope scope in which this resource is defined
|
|
34
34
|
* @param useExistingHostedZone Flag to indicate whether to lookup vs create new hosted zone
|
|
35
35
|
*/
|
|
36
|
-
withHostedZoneFromFullyQualifiedDomainName(id: string, scope: CommonConstruct, useExistingHostedZone: boolean):
|
|
36
|
+
withHostedZoneFromFullyQualifiedDomainName(id: string, scope: CommonConstruct, useExistingHostedZone: boolean): IHostedZone;
|
|
37
37
|
/**
|
|
38
38
|
* @summary Method to create a-record for cloudfront target
|
|
39
39
|
* @param id scoped id of the resource
|
|
@@ -43,7 +43,7 @@ export declare class Route53Manager {
|
|
|
43
43
|
* @param recordName
|
|
44
44
|
* @param skipStageFromRecord
|
|
45
45
|
*/
|
|
46
|
-
createCloudFrontTargetARecord(id: string, scope: CommonConstruct, distribution?:
|
|
46
|
+
createCloudFrontTargetARecord(id: string, scope: CommonConstruct, distribution?: IDistribution, hostedZone?: IHostedZone, recordName?: string, skipStageFromRecord?: boolean): ARecord;
|
|
47
47
|
/**
|
|
48
48
|
* @summary Method to create a-record for cloudfront target
|
|
49
49
|
* @param id scoped id of the resource
|
|
@@ -52,7 +52,7 @@ export declare class Route53Manager {
|
|
|
52
52
|
* @param hostedZone
|
|
53
53
|
* @param recordName
|
|
54
54
|
*/
|
|
55
|
-
createCloudFrontTargetARecordV2(id: string, scope: CommonConstruct, distribution?:
|
|
55
|
+
createCloudFrontTargetARecordV2(id: string, scope: CommonConstruct, distribution?: IDistribution, hostedZone?: IHostedZone, recordName?: string): ARecord;
|
|
56
56
|
/**
|
|
57
57
|
* @summary Method to create a-record for restApi gateway target
|
|
58
58
|
* @param id scoped id of the resource
|
|
@@ -62,5 +62,5 @@ export declare class Route53Manager {
|
|
|
62
62
|
* @param hostedZone
|
|
63
63
|
* @param skipStageFromRecord
|
|
64
64
|
*/
|
|
65
|
-
createApiGatewayARecord(id: string, scope: CommonConstruct, recordName: string, apiDomain:
|
|
65
|
+
createApiGatewayARecord(id: string, scope: CommonConstruct, recordName: string, apiDomain: DomainName, hostedZone: IHostedZone, skipStageFromRecord?: boolean): ARecord;
|
|
66
66
|
}
|
|
@@ -1,34 +1,11 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.Route53Manager = void 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
4
|
+
const aws_route53_1 = require("aws-cdk-lib/aws-route53");
|
|
5
|
+
const aws_route53_targets_1 = require("aws-cdk-lib/aws-route53-targets");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
30
7
|
/**
|
|
31
|
-
* @classdesc Provides operations on AWS Route53
|
|
8
|
+
* @classdesc Provides operations on AWS Route53
|
|
32
9
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
33
10
|
* - If a custom construct extends {@link CommonConstruct}, an instance is available within the context.
|
|
34
11
|
* @example
|
|
@@ -55,18 +32,18 @@ class Route53Manager {
|
|
|
55
32
|
if (!props)
|
|
56
33
|
throw `Route53 props undefined for ${id}`;
|
|
57
34
|
if (props.useExistingHostedZone) {
|
|
58
|
-
hostedZone =
|
|
35
|
+
hostedZone = aws_route53_1.HostedZone.fromLookup(scope, `${id}`, {
|
|
59
36
|
domainName: scope.props.domainName,
|
|
60
37
|
});
|
|
61
38
|
}
|
|
62
39
|
else {
|
|
63
|
-
hostedZone = new
|
|
40
|
+
hostedZone = new aws_route53_1.HostedZone(scope, `${id}`, {
|
|
64
41
|
comment: `Hosted zone for ${scope.props.domainName}`,
|
|
65
42
|
zoneName: scope.props.domainName,
|
|
66
43
|
});
|
|
67
44
|
}
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
(0, utils_1.createCfnOutput)(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId);
|
|
46
|
+
(0, utils_1.createCfnOutput)(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn);
|
|
70
47
|
return hostedZone;
|
|
71
48
|
}
|
|
72
49
|
/**
|
|
@@ -78,18 +55,18 @@ class Route53Manager {
|
|
|
78
55
|
withHostedZoneFromFullyQualifiedDomainName(id, scope, useExistingHostedZone) {
|
|
79
56
|
let hostedZone;
|
|
80
57
|
if (useExistingHostedZone) {
|
|
81
|
-
hostedZone =
|
|
58
|
+
hostedZone = aws_route53_1.HostedZone.fromLookup(scope, `${id}`, {
|
|
82
59
|
domainName: scope.fullyQualifiedDomainName,
|
|
83
60
|
});
|
|
84
61
|
}
|
|
85
62
|
else {
|
|
86
|
-
hostedZone = new
|
|
63
|
+
hostedZone = new aws_route53_1.HostedZone(scope, `${id}`, {
|
|
87
64
|
comment: `Hosted zone for ${scope.fullyQualifiedDomainName}`,
|
|
88
65
|
zoneName: scope.fullyQualifiedDomainName,
|
|
89
66
|
});
|
|
90
67
|
}
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
(0, utils_1.createCfnOutput)(`${id}-hostedZoneId`, scope, hostedZone.hostedZoneId);
|
|
69
|
+
(0, utils_1.createCfnOutput)(`${id}-hostedZoneArn`, scope, hostedZone.hostedZoneArn);
|
|
93
70
|
return hostedZone;
|
|
94
71
|
}
|
|
95
72
|
/**
|
|
@@ -106,14 +83,14 @@ class Route53Manager {
|
|
|
106
83
|
throw `Distribution undefined for ${id}`;
|
|
107
84
|
if (!hostedZone)
|
|
108
85
|
throw `HostedZone undefined for ${id}`;
|
|
109
|
-
const aRecord = new
|
|
86
|
+
const aRecord = new aws_route53_1.ARecord(scope, `${id}`, {
|
|
110
87
|
recordName: (recordName && scope.isProductionStage()) || skipStageFromRecord
|
|
111
88
|
? `${recordName}`
|
|
112
89
|
: `${recordName}-${scope.props.stage}`,
|
|
113
|
-
target:
|
|
90
|
+
target: aws_route53_1.RecordTarget.fromAlias(new aws_route53_targets_1.CloudFrontTarget(distribution)),
|
|
114
91
|
zone: hostedZone,
|
|
115
92
|
});
|
|
116
|
-
|
|
93
|
+
(0, utils_1.createCfnOutput)(`${id}-aRecordDomainName`, scope, aRecord.domainName);
|
|
117
94
|
return aRecord;
|
|
118
95
|
}
|
|
119
96
|
/**
|
|
@@ -129,12 +106,12 @@ class Route53Manager {
|
|
|
129
106
|
throw `Distribution undefined for ${id}`;
|
|
130
107
|
if (!hostedZone)
|
|
131
108
|
throw `HostedZone undefined for ${id}`;
|
|
132
|
-
const aRecord = new
|
|
109
|
+
const aRecord = new aws_route53_1.ARecord(scope, `${id}`, {
|
|
133
110
|
recordName: recordName,
|
|
134
|
-
target:
|
|
111
|
+
target: aws_route53_1.RecordTarget.fromAlias(new aws_route53_targets_1.CloudFrontTarget(distribution)),
|
|
135
112
|
zone: hostedZone,
|
|
136
113
|
});
|
|
137
|
-
|
|
114
|
+
(0, utils_1.createCfnOutput)(`${id}-aRecordDomainName`, scope, aRecord.domainName);
|
|
138
115
|
return aRecord;
|
|
139
116
|
}
|
|
140
117
|
/**
|
|
@@ -151,12 +128,12 @@ class Route53Manager {
|
|
|
151
128
|
if (recordName && recordName !== '')
|
|
152
129
|
apiRecordName =
|
|
153
130
|
scope.isProductionStage() || skipStageFromRecord ? `${recordName}` : `${recordName}-${scope.props.stage}`;
|
|
154
|
-
const apiARecord = new
|
|
131
|
+
const apiARecord = new aws_route53_1.ARecord(scope, `${id}`, {
|
|
155
132
|
recordName: apiRecordName,
|
|
156
|
-
target:
|
|
133
|
+
target: aws_route53_1.RecordTarget.fromAlias(new aws_route53_targets_1.ApiGatewayDomain(apiDomain)),
|
|
157
134
|
zone: hostedZone,
|
|
158
135
|
});
|
|
159
|
-
|
|
136
|
+
(0, utils_1.createCfnOutput)(`${id}-a-record-domain-name`, scope, apiARecord.domainName);
|
|
160
137
|
return apiARecord;
|
|
161
138
|
}
|
|
162
139
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as secretsManager from 'aws-cdk-lib/aws-secretsmanager';
|
|
1
|
+
import { Secret, SecretProps } from 'aws-cdk-lib/aws-secretsmanager';
|
|
3
2
|
import { CommonConstruct } from '../../../common';
|
|
4
3
|
/**
|
|
5
4
|
* @classdesc Provides operations on AWS Secrets Manager.
|
|
@@ -9,10 +8,10 @@ import { CommonConstruct } from '../../../common';
|
|
|
9
8
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
10
9
|
*
|
|
11
10
|
* class CustomConstruct extends CommonConstruct {
|
|
12
|
-
* constructor(parent:
|
|
11
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
13
12
|
* super(parent, id, props)
|
|
14
13
|
* this.props = props
|
|
15
|
-
* this.
|
|
14
|
+
* this.loadSecret('MySecretName', 'eu-west-1')
|
|
16
15
|
* }
|
|
17
16
|
* }
|
|
18
17
|
* @see [CDK Secrets Manager Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager-readme.html}
|
|
@@ -24,7 +23,7 @@ export declare class SecretsManager {
|
|
|
24
23
|
* @param scope scope in which this resource is defined
|
|
25
24
|
* @param props the secret properties
|
|
26
25
|
*/
|
|
27
|
-
createSecret(id: string, scope: CommonConstruct, props:
|
|
26
|
+
createSecret(id: string, scope: CommonConstruct, props: SecretProps): Secret;
|
|
28
27
|
/**
|
|
29
28
|
* @summary Method to retrieve a secret from secrets manager with a cloudformation export
|
|
30
29
|
* @param id
|
|
@@ -32,7 +31,7 @@ export declare class SecretsManager {
|
|
|
32
31
|
* @param stackName
|
|
33
32
|
* @param exportName
|
|
34
33
|
*/
|
|
35
|
-
retrieveSecretFromSecretsManager(id: string, scope: CommonConstruct, stackName: string, exportName: string): cdk.
|
|
34
|
+
retrieveSecretFromSecretsManager(id: string, scope: CommonConstruct, stackName: string, exportName: string): import("aws-cdk-lib/aws-secretsmanager").ISecret;
|
|
36
35
|
/**
|
|
37
36
|
* @summary Method to resolve secret value from a secret using AWS SDK
|
|
38
37
|
* @param region the region in which the secret is defined
|
|
@@ -1,33 +1,10 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.SecretsManager = void 0;
|
|
27
4
|
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
5
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
6
|
+
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
31
8
|
/**
|
|
32
9
|
* @classdesc Provides operations on AWS Secrets Manager.
|
|
33
10
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
@@ -36,10 +13,10 @@ const utils = __importStar(require("../../../utils"));
|
|
|
36
13
|
* import { CommonConstruct } from '@gradientedge/cdk-utils'
|
|
37
14
|
*
|
|
38
15
|
* class CustomConstruct extends CommonConstruct {
|
|
39
|
-
* constructor(parent:
|
|
16
|
+
* constructor(parent: Construct, id: string, props: common.CommonStackProps) {
|
|
40
17
|
* super(parent, id, props)
|
|
41
18
|
* this.props = props
|
|
42
|
-
* this.
|
|
19
|
+
* this.loadSecret('MySecretName', 'eu-west-1')
|
|
43
20
|
* }
|
|
44
21
|
* }
|
|
45
22
|
* @see [CDK Secrets Manager Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager-readme.html}
|
|
@@ -52,12 +29,12 @@ class SecretsManager {
|
|
|
52
29
|
* @param props the secret properties
|
|
53
30
|
*/
|
|
54
31
|
createSecret(id, scope, props) {
|
|
55
|
-
const secret = new
|
|
32
|
+
const secret = new aws_secretsmanager_1.Secret(scope, `${id}`, {
|
|
56
33
|
...props,
|
|
57
34
|
secretName: `${props.secretName}-${scope.props.stage}`,
|
|
58
35
|
});
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
(0, utils_1.createCfnOutput)(`${id}-secretName`, scope, secret.secretName);
|
|
37
|
+
(0, utils_1.createCfnOutput)(`${id}-secretArn`, scope, secret.secretArn);
|
|
61
38
|
return secret;
|
|
62
39
|
}
|
|
63
40
|
/**
|
|
@@ -68,7 +45,7 @@ class SecretsManager {
|
|
|
68
45
|
* @param exportName
|
|
69
46
|
*/
|
|
70
47
|
retrieveSecretFromSecretsManager(id, scope, stackName, exportName) {
|
|
71
|
-
return
|
|
48
|
+
return aws_secretsmanager_1.Secret.fromSecretNameV2(scope, `${id}`, aws_cdk_lib_1.Fn.importValue(`${stackName}-${scope.props.stage}-${exportName}`));
|
|
72
49
|
}
|
|
73
50
|
/**
|
|
74
51
|
* @summary Method to resolve secret value from a secret using AWS SDK
|
|
@@ -78,7 +55,7 @@ class SecretsManager {
|
|
|
78
55
|
*/
|
|
79
56
|
async resolveSecretValue(region, secretId, secretKey) {
|
|
80
57
|
const client = new client_secrets_manager_1.SecretsManagerClient({
|
|
81
|
-
credentials:
|
|
58
|
+
credentials: (0, utils_1.determineCredentials)(),
|
|
82
59
|
region: region,
|
|
83
60
|
});
|
|
84
61
|
const command = new client_secrets_manager_1.GetSecretValueCommand({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IFunction } from 'aws-cdk-lib/aws-lambda';
|
|
2
|
+
import { Topic } from 'aws-cdk-lib/aws-sns';
|
|
3
3
|
import { CommonConstruct } from '../../../common';
|
|
4
4
|
import { SubscriptionProps } from './types';
|
|
5
5
|
/**
|
|
@@ -26,7 +26,7 @@ export declare class SnsManager {
|
|
|
26
26
|
* @param props
|
|
27
27
|
* @param emails
|
|
28
28
|
*/
|
|
29
|
-
createEmailNotificationService(id: string, scope: CommonConstruct, props: SubscriptionProps, emails: string[]):
|
|
29
|
+
createEmailNotificationService(id: string, scope: CommonConstruct, props: SubscriptionProps, emails: string[]): Topic;
|
|
30
30
|
/**
|
|
31
31
|
* @summary Method to create a lambda notification service
|
|
32
32
|
* @param id scoped id of the resource
|
|
@@ -34,5 +34,5 @@ export declare class SnsManager {
|
|
|
34
34
|
* @param props
|
|
35
35
|
* @param lambdaFunction
|
|
36
36
|
*/
|
|
37
|
-
createLambdaNotificationService(id: string, scope: CommonConstruct, props: SubscriptionProps, lambdaFunction:
|
|
37
|
+
createLambdaNotificationService(id: string, scope: CommonConstruct, props: SubscriptionProps, lambdaFunction: IFunction): Topic;
|
|
38
38
|
}
|