@sylvesterllc/aws-constructs 1.1.37 → 1.1.39
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/.github/workflows/publish.yml +56 -56
- package/__tests__/app-config.test.ts +32 -32
- package/__tests__/data/testConfig.ts +146 -146
- package/__tests__/mocks/ResourceMock.ts +9 -9
- package/__tests__/router.test.ts +194 -194
- package/dist/config/AppConfig.js +1 -1
- package/dist/config/Constants.js +1 -1
- package/dist/config/Environments.js +1 -1
- package/dist/config/MicroserviceAppConfig.js +1 -1
- package/dist/config/ServiceBundleConfig.js +1 -1
- package/dist/config/bishopConfig.js +1 -1
- package/dist/config/customConfigs/ApiAppConfig.js +1 -1
- package/dist/config/customConfigs/GlobalAppConfig.js +1 -1
- package/dist/config/customConfigs/IAppConfig.js +1 -1
- package/dist/config/customConfigs/ResourceAppConfig.js +1 -1
- package/dist/config/microServiceConfig.js +1 -1
- package/dist/config/types/LogDuration.js +1 -1
- package/dist/config/types/TsgAuthorizerProp.js +1 -1
- package/dist/config/types/TsgAuthorizerType.js +1 -1
- package/dist/config/types/TsgCdkConfigType.js +1 -1
- package/dist/config/types/TsgCognitoConfig.js +1 -1
- package/dist/config/types/TsgDnsConfig.js +1 -1
- package/dist/config/types/TsgDynamoDbProp.js +1 -1
- package/dist/config/types/TsgDynamoIndex.js +1 -1
- package/dist/config/types/TsgDynamoProp.js +1 -1
- package/dist/config/types/TsgDynamoTable.js +1 -1
- package/dist/config/types/TsgDynamoTableRef.js +1 -1
- package/dist/config/types/TsgEc2Prop.js +1 -1
- package/dist/config/types/TsgKeyPair.js +1 -1
- package/dist/config/types/TsgLambda.js +1 -1
- package/dist/config/types/TsgLambdaLayerProp.js +1 -1
- package/dist/config/types/TsgLambdaMap.js +1 -1
- package/dist/config/types/TsgLambdaName.js +1 -1
- package/dist/config/types/TsgLambdaNode.js +1 -1
- package/dist/config/types/TsgLambdaProp.js +1 -1
- package/dist/config/types/TsgLambdaProps.js +1 -1
- package/dist/config/types/TsgLambdaRoutable.js +1 -1
- package/dist/config/types/index.js +1 -1
- package/dist/constants/aws-service-principal-constants.js +1 -1
- package/dist/constructs/BasicLambda.js +1 -1
- package/dist/constructs/DynamoDbSingleTable.js +4 -2
- package/dist/constructs/MicroService.js +1 -1
- package/dist/constructs/basic-queue.d.ts +9 -0
- package/dist/constructs/basic-queue.js +16 -0
- package/dist/constructs/index.d.ts +1 -0
- package/dist/constructs/index.js +16 -1
- package/dist/constructs/timer-job.js +1 -1
- package/dist/helpers/logger.js +1 -1
- package/dist/helpers/util-helper.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/ApiLambdaResult.js +1 -1
- package/dist/interfaces/BaseResourceProps.js +1 -1
- package/dist/interfaces/CreateLambdaFunctionInput.js +1 -1
- package/dist/interfaces/MicroserviceProps.js +1 -1
- package/dist/interfaces/lambda/index.js +1 -1
- package/dist/interfaces/lambda/lambda-props.js +1 -1
- package/dist/interfaces/timer-job/timer-job-props.js +1 -1
- package/dist/resources/base/baseResource.js +1 -1
- package/dist/resources/base/tsgBaseResource.js +1 -1
- package/dist/resources/certificate/createCertificate.js +1 -1
- package/dist/resources/cognito/createCognito.js +1 -1
- package/dist/resources/cognito/createCognitoProps.js +1 -1
- package/dist/resources/customResource/createSeedDatabaseCustomResource.js +1 -1
- package/dist/resources/dynamodb/CreateDynamo.js +1 -1
- package/dist/resources/dynamodb/CreateDynamoSingleTableDesign.d.ts +2 -1
- package/dist/resources/dynamodb/CreateDynamoSingleTableDesign.js +29 -28
- package/dist/resources/ec2/create-ec2-instance.js +3 -3
- package/dist/resources/ecr/CreateEcr.js +2 -2
- package/dist/resources/gateway/CreateApiAndAttachLambdas.js +1 -1
- package/dist/resources/gateway/createApi.js +1 -1
- package/dist/resources/gateway/createApiKey.js +1 -1
- package/dist/resources/helpers/createCommonLayer.js +1 -1
- package/dist/resources/helpers/createRoutes.js +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/resources/lambda/create-basic-lambda-helper.js +11 -24
- package/dist/resources/lambda/create-basic-lambda.js +8 -21
- package/dist/resources/lambda/createLambda.js +1 -1
- package/dist/resources/lambda/lambdaHelper.js +1 -1
- package/dist/resources/lambda-authorizer/TsgJwtTokenAuthorizer.js +1 -1
- package/dist/resources/lambda-authorizer/TsgRequestAuthorizer.js +1 -1
- package/dist/resources/lambda-authorizer/createAuthorizerHelpers.js +1 -1
- package/dist/resources/lambda-layer/createLambdaLayer.js +1 -1
- package/dist/resources/layers/common/src/nodejs/api-response/responses.js +1 -1
- package/dist/resources/layers/common/src/nodejs/index.js +1 -1
- package/dist/resources/layers/common/src/nodejs/logger/IContext.js +1 -1
- package/dist/resources/layers/common/src/nodejs/logger/index.js +1 -1
- package/dist/resources/layers/common/src/nodejs/logger/logger.js +1 -1
- package/dist/resources/resources/iam/policyDocuments/cognitoPolicy.js +1 -1
- package/dist/resources/resources/iam/roles/createRole.js +1 -1
- package/dist/resources/route53/CreateZone.js +1 -1
- package/dist/resources/route53/create-zones.js +1 -1
- package/dist/resources/securityManager/index.js +1 -1
- package/dist/resources/sqs/create-sqs-resource.d.ts +3 -0
- package/dist/resources/sqs/create-sqs-resource.js +21 -0
- package/jest.config.js +8 -8
- package/jest.config.ts.old +20 -20
- package/package.json +57 -55
- package/readme.md +147 -147
- package/src/config/AppConfig.ts +106 -106
- package/src/config/Constants.ts +26 -26
- package/src/config/Environments.ts +1 -1
- package/src/config/MicroserviceAppConfig.ts +8 -8
- package/src/config/ServiceBundleConfig.ts +17 -17
- package/src/config/bishopConfig.ts +82 -82
- package/src/config/customConfigs/ApiAppConfig.ts +5 -5
- package/src/config/customConfigs/GlobalAppConfig.ts +10 -10
- package/src/config/customConfigs/IAppConfig.ts +12 -12
- package/src/config/customConfigs/ResourceAppConfig.ts +15 -15
- package/src/config/microServiceConfig.ts +83 -83
- package/src/config/types/LogDuration.ts +7 -7
- package/src/config/types/TsgAuthorizerProp.ts +8 -8
- package/src/config/types/TsgAuthorizerType.ts +4 -4
- package/src/config/types/TsgCdkConfigType.ts +2 -2
- package/src/config/types/TsgCognitoConfig.ts +5 -5
- package/src/config/types/TsgDnsConfig.ts +10 -10
- package/src/config/types/TsgDynamoDbProp.ts +9 -9
- package/src/config/types/TsgDynamoIndex.ts +15 -15
- package/src/config/types/TsgDynamoProp.ts +16 -16
- package/src/config/types/TsgDynamoTable.ts +4 -4
- package/src/config/types/TsgDynamoTableRef.ts +3 -3
- package/src/config/types/TsgEc2Prop.ts +8 -8
- package/src/config/types/TsgKeyPair.ts +5 -5
- package/src/config/types/TsgLambda.ts +5 -5
- package/src/config/types/TsgLambdaLayerProp.ts +4 -4
- package/src/config/types/TsgLambdaMap.ts +3 -3
- package/src/config/types/TsgLambdaName.ts +3 -3
- package/src/config/types/TsgLambdaNode.ts +3 -3
- package/src/config/types/TsgLambdaProp.ts +19 -19
- package/src/config/types/TsgLambdaProps.ts +17 -17
- package/src/config/types/TsgLambdaRoutable.ts +8 -8
- package/src/config/types/index.ts +11 -11
- package/src/constants/aws-service-principal-constants.ts +2 -2
- package/src/constructs/BasicLambda.ts +19 -19
- package/src/constructs/DynamoDbSingleTable.ts +13 -12
- package/src/constructs/MicroService.ts +131 -131
- package/src/constructs/basic-queue.ts +19 -0
- package/src/constructs/index.ts +6 -5
- package/src/constructs/timer-job.ts +19 -19
- package/src/helpers/logger.ts +12 -12
- package/src/helpers/util-helper.ts +19 -19
- package/src/index.ts +8 -8
- package/src/interfaces/ApiLambdaResult.ts +6 -6
- package/src/interfaces/BaseResourceProps.ts +6 -6
- package/src/interfaces/CreateLambdaFunctionInput.ts +10 -10
- package/src/interfaces/MicroserviceProps.ts +10 -10
- package/src/interfaces/lambda/index.ts +1 -1
- package/src/interfaces/lambda/lambda-props.ts +15 -15
- package/src/interfaces/timer-job/timer-job-props.ts +6 -6
- package/src/resources/base/baseResource.ts +14 -14
- package/src/resources/base/tsgBaseResource.ts +21 -21
- package/src/resources/certificate/createCertificate.ts +57 -57
- package/src/resources/cognito/createCognito.ts +47 -47
- package/src/resources/cognito/createCognitoProps.ts +46 -46
- package/src/resources/customResource/createSeedDatabaseCustomResource.ts +36 -36
- package/src/resources/dynamodb/CreateDynamo.ts +110 -110
- package/src/resources/dynamodb/CreateDynamoSingleTableDesign.ts +112 -118
- package/src/resources/ec2/create-ec2-instance.ts +52 -52
- package/src/resources/ecr/CreateEcr.ts +57 -57
- package/src/resources/gateway/CreateApiAndAttachLambdas.ts +161 -161
- package/src/resources/gateway/createApi.ts +173 -173
- package/src/resources/gateway/createApiKey.ts +88 -88
- package/src/resources/helpers/createCommonLayer.ts +18 -18
- package/src/resources/helpers/createRoutes.ts +74 -74
- package/src/resources/index.ts +1 -1
- package/src/resources/lambda/create-basic-lambda-helper.ts +124 -146
- package/src/resources/lambda/create-basic-lambda.ts +159 -173
- package/src/resources/lambda/createLambda.ts +203 -203
- package/src/resources/lambda/lambdaHelper.ts +133 -133
- package/src/resources/lambda-authorizer/TsgJwtTokenAuthorizer.ts +107 -107
- package/src/resources/lambda-authorizer/TsgRequestAuthorizer.ts +44 -44
- package/src/resources/lambda-authorizer/createAuthorizerHelpers.ts +76 -76
- package/src/resources/lambda-layer/createLambdaLayer.ts +39 -39
- package/src/resources/layers/common/package.json +22 -22
- package/src/resources/layers/common/src/nodejs/api-response/responses.ts +41 -41
- package/src/resources/layers/common/src/nodejs/index.ts +3 -3
- package/src/resources/layers/common/src/nodejs/logger/IContext.ts +6 -6
- package/src/resources/layers/common/src/nodejs/logger/index.ts +1 -1
- package/src/resources/layers/common/src/nodejs/logger/logger.ts +10 -10
- package/src/resources/layers/common/tsconfig.json +7 -7
- package/src/resources/resources/iam/policyDocuments/cognitoPolicy.ts +54 -54
- package/src/resources/resources/iam/roles/createRole.ts +29 -29
- package/src/resources/route53/CreateZone.ts +61 -61
- package/src/resources/route53/create-zones.ts +40 -40
- package/src/resources/securityManager/index.ts +23 -23
- package/src/resources/sqs/create-sqs-resource.ts +22 -0
- package/tsconfig.json +44 -44
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
import { CfnOutput, Duration } from "aws-cdk-lib";
|
|
2
|
-
import { TokenAuthorizer } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
-
import { Alarm, ComparisonOperator, IAlarmAction } from "aws-cdk-lib/aws-cloudwatch";
|
|
4
|
-
import { IRole, ManagedPolicy } from "aws-cdk-lib/aws-iam";
|
|
5
|
-
import { LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
6
|
-
import { NodejsFunction, NodejsFunctionProps, SourceMapMode } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
7
|
-
import { Construct } from "constructs";
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import { AppConfig } from "../../config/AppConfig";
|
|
10
|
-
import { TsgLambdaProp } from "../../config/types";
|
|
11
|
-
|
|
12
|
-
import { TsgLambdaProps } from "../../config/types/TsgLambdaProps";
|
|
13
|
-
import { CreateLambdaFunctionInput } from "../../interfaces/CreateLambdaFunctionInput";
|
|
14
|
-
import { BaseResource } from "../base/baseResource";
|
|
15
|
-
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
16
|
-
import { LambdaHelper } from "./lambdaHelper";
|
|
17
|
-
import { getUUID } from "../../helpers/util-helper";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export class CreateLambda extends BaseResource<NodejsFunction> {
|
|
21
|
-
|
|
22
|
-
public Lambdas: NodejsFunction[] = [];
|
|
23
|
-
public LambdaRecords: Record<string, NodejsFunction> = {};
|
|
24
|
-
|
|
25
|
-
constructor(scope: Construct, config: AppConfig, private layers?: LayerVersion[]) {
|
|
26
|
-
super(scope, config);
|
|
27
|
-
|
|
28
|
-
const resources = this.createResource(scope);
|
|
29
|
-
|
|
30
|
-
this.createdResources = [...resources];
|
|
31
|
-
|
|
32
|
-
this.Lambdas = [...resources];
|
|
33
|
-
|
|
34
|
-
this.createAlarmsForLambdas(this.Lambdas);
|
|
35
|
-
|
|
36
|
-
this.LambdaRecords = this.createRecordForLambda(this.Lambdas);
|
|
37
|
-
|
|
38
|
-
this.createOutput(scope, resources);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
protected createResource(scope: Construct): NodejsFunction[] {
|
|
42
|
-
|
|
43
|
-
const result = this.createLambdas(this.config);
|
|
44
|
-
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected createOutput<T>(scope: Construct, createdAssets: T[]): void {
|
|
49
|
-
createdAssets.forEach((x, idx) => {
|
|
50
|
-
|
|
51
|
-
new CfnOutput(scope, `lambda-${idx}`, {
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
value: x.functionName
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private createLambdas(config: AppConfig): NodejsFunction[] {
|
|
59
|
-
|
|
60
|
-
const createdLambdas: NodejsFunction[] = this.createLambdaFunctions(this.scope, undefined, this.layers);
|
|
61
|
-
|
|
62
|
-
return createdLambdas;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private createLambdaFunctions(scope: Construct, role?: IRole, layers?: LayerVersion[]) {
|
|
66
|
-
|
|
67
|
-
const createdLambdas = this.config.RESOURCES.LAMBDA.map((config: TsgLambdaProp) => {
|
|
68
|
-
|
|
69
|
-
let lambdaProps = this.createLambdaProps(config, role, layers);
|
|
70
|
-
|
|
71
|
-
const lambdaId = CreateLambda.getIdForLambda(config, this.config);
|
|
72
|
-
let fctn = new NodejsFunction(scope, lambdaId, lambdaProps);
|
|
73
|
-
|
|
74
|
-
return fctn;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return createdLambdas || [];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private createLambdaProps(prop: TsgLambdaProp, role?: IRole, layers?: LayerVersion[], props?: TsgLambdaProps) {
|
|
81
|
-
|
|
82
|
-
return this.createLambdaFunctionProps({
|
|
83
|
-
prop,
|
|
84
|
-
role,
|
|
85
|
-
layers,
|
|
86
|
-
props
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private createLambdaFunctionProps(props: CreateLambdaFunctionInput) {
|
|
91
|
-
const { prop, role, layers } = props;
|
|
92
|
-
|
|
93
|
-
const lambdaProp: NodejsFunctionProps = {
|
|
94
|
-
entry: path.join(prop.codePath),
|
|
95
|
-
functionName: `${this.config.AppPrefix}-${prop.name}`,
|
|
96
|
-
handler: prop.handler,
|
|
97
|
-
logRetention: (!prop.logDuration) ? RetentionDays.FIVE_DAYS : LambdaHelper.getDayToSaveLogs(prop.logDuration),
|
|
98
|
-
runtime: prop.runtime || this.config.GLOBALS.stackRuntime,
|
|
99
|
-
timeout: prop.duration || Duration.minutes(2),
|
|
100
|
-
memorySize: prop.memory || 512,
|
|
101
|
-
environment: {
|
|
102
|
-
"VERBOSE_LOGGING": "true",
|
|
103
|
-
...prop.environment
|
|
104
|
-
},
|
|
105
|
-
bundling: {
|
|
106
|
-
minify: false,
|
|
107
|
-
target: 'es2020',
|
|
108
|
-
sourceMap: true,
|
|
109
|
-
sourceMapMode: SourceMapMode.EXTERNAL,
|
|
110
|
-
environment: prop.environment || prop.environment,
|
|
111
|
-
},
|
|
112
|
-
role,
|
|
113
|
-
layers
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return lambdaProp;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
private createAlarmsForLambdas(lambdas: NodejsFunction[]) {
|
|
121
|
-
|
|
122
|
-
const lambdaRecords = this.createRecordForLambda(lambdas);
|
|
123
|
-
|
|
124
|
-
// console.log('Lambda Records:', lambdaRecords);
|
|
125
|
-
// const lambdaNames = Object.keys(lambdaRecords);
|
|
126
|
-
// console.log('lambda Names from Records', lambdaNames);
|
|
127
|
-
|
|
128
|
-
lambdas.forEach((lambda, idx) => {
|
|
129
|
-
|
|
130
|
-
const errorMetric = lambda.metricErrors({
|
|
131
|
-
period: Duration.minutes(3),
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const durationMetric = lambda.metricDuration({
|
|
136
|
-
period: Duration.minutes(3),
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const invocationMetric = lambda.metricInvocations({
|
|
140
|
-
period: Duration.minutes(3),
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const uuid = getUUID().split('-')[0];
|
|
144
|
-
|
|
145
|
-
new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-error-alarm`, {
|
|
146
|
-
metric: errorMetric,
|
|
147
|
-
threshold: 5,
|
|
148
|
-
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
149
|
-
evaluationPeriods: 3,
|
|
150
|
-
alarmDescription: `${this.config.AppPrefix} errors over 3 min period`,
|
|
151
|
-
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-error-alarm`
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-duration-alarm`, {
|
|
155
|
-
metric: durationMetric,
|
|
156
|
-
threshold: 1,
|
|
157
|
-
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
158
|
-
evaluationPeriods: 3,
|
|
159
|
-
alarmDescription: `${this.config.AppPrefix}-${lambda.node.id} duration errors over 3 min period`,
|
|
160
|
-
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-duration-alarm`
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const invocationAlarm = new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-invocation-alarm`, {
|
|
164
|
-
metric: errorMetric,
|
|
165
|
-
threshold: 1000,
|
|
166
|
-
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
167
|
-
evaluationPeriods: 3,
|
|
168
|
-
alarmDescription: `${this.config.AppPrefix}-${lambda.node.id} errors over 3 min period`,
|
|
169
|
-
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-invocation-Metric-alarm`
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
public static getIdForLambda(lambdaProp: TsgLambdaProp, appConfig: AppConfig) {
|
|
175
|
-
return `${appConfig.AppPrefix}-${lambdaProp.name}`.toLowerCase();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private createRecordForLambda(lambdas: NodejsFunction[]) {
|
|
179
|
-
|
|
180
|
-
const names = this.config.RESOURCES.LAMBDA.map((lambda) => {
|
|
181
|
-
return lambda.name;
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const lambdaNames = [...names] as const;
|
|
185
|
-
|
|
186
|
-
type LambdaName = typeof lambdaNames[number];
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const lambdaRecord: Record<LambdaName, NodejsFunction> = {} as Record<LambdaName, NodejsFunction>;
|
|
190
|
-
|
|
191
|
-
lambdas.forEach((lambda, idx) => {
|
|
192
|
-
lambdaRecord[lambdaNames[idx] as LambdaName] = lambdas[idx];
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
return lambdaRecord;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
1
|
+
import { CfnOutput, Duration } from "aws-cdk-lib";
|
|
2
|
+
import { TokenAuthorizer } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import { Alarm, ComparisonOperator, IAlarmAction } from "aws-cdk-lib/aws-cloudwatch";
|
|
4
|
+
import { IRole, ManagedPolicy } from "aws-cdk-lib/aws-iam";
|
|
5
|
+
import { LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
6
|
+
import { NodejsFunction, NodejsFunctionProps, SourceMapMode } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
7
|
+
import { Construct } from "constructs";
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { AppConfig } from "../../config/AppConfig";
|
|
10
|
+
import { TsgLambdaProp } from "../../config/types";
|
|
11
|
+
|
|
12
|
+
import { TsgLambdaProps } from "../../config/types/TsgLambdaProps";
|
|
13
|
+
import { CreateLambdaFunctionInput } from "../../interfaces/CreateLambdaFunctionInput";
|
|
14
|
+
import { BaseResource } from "../base/baseResource";
|
|
15
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
16
|
+
import { LambdaHelper } from "./lambdaHelper";
|
|
17
|
+
import { getUUID } from "../../helpers/util-helper";
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export class CreateLambda extends BaseResource<NodejsFunction> {
|
|
21
|
+
|
|
22
|
+
public Lambdas: NodejsFunction[] = [];
|
|
23
|
+
public LambdaRecords: Record<string, NodejsFunction> = {};
|
|
24
|
+
|
|
25
|
+
constructor(scope: Construct, config: AppConfig, private layers?: LayerVersion[]) {
|
|
26
|
+
super(scope, config);
|
|
27
|
+
|
|
28
|
+
const resources = this.createResource(scope);
|
|
29
|
+
|
|
30
|
+
this.createdResources = [...resources];
|
|
31
|
+
|
|
32
|
+
this.Lambdas = [...resources];
|
|
33
|
+
|
|
34
|
+
this.createAlarmsForLambdas(this.Lambdas);
|
|
35
|
+
|
|
36
|
+
this.LambdaRecords = this.createRecordForLambda(this.Lambdas);
|
|
37
|
+
|
|
38
|
+
this.createOutput(scope, resources);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
protected createResource(scope: Construct): NodejsFunction[] {
|
|
42
|
+
|
|
43
|
+
const result = this.createLambdas(this.config);
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected createOutput<T>(scope: Construct, createdAssets: T[]): void {
|
|
49
|
+
createdAssets.forEach((x, idx) => {
|
|
50
|
+
|
|
51
|
+
new CfnOutput(scope, `lambda-${idx}`, {
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
value: x.functionName
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private createLambdas(config: AppConfig): NodejsFunction[] {
|
|
59
|
+
|
|
60
|
+
const createdLambdas: NodejsFunction[] = this.createLambdaFunctions(this.scope, undefined, this.layers);
|
|
61
|
+
|
|
62
|
+
return createdLambdas;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private createLambdaFunctions(scope: Construct, role?: IRole, layers?: LayerVersion[]) {
|
|
66
|
+
|
|
67
|
+
const createdLambdas = this.config.RESOURCES.LAMBDA.map((config: TsgLambdaProp) => {
|
|
68
|
+
|
|
69
|
+
let lambdaProps = this.createLambdaProps(config, role, layers);
|
|
70
|
+
|
|
71
|
+
const lambdaId = CreateLambda.getIdForLambda(config, this.config);
|
|
72
|
+
let fctn = new NodejsFunction(scope, lambdaId, lambdaProps);
|
|
73
|
+
|
|
74
|
+
return fctn;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return createdLambdas || [];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private createLambdaProps(prop: TsgLambdaProp, role?: IRole, layers?: LayerVersion[], props?: TsgLambdaProps) {
|
|
81
|
+
|
|
82
|
+
return this.createLambdaFunctionProps({
|
|
83
|
+
prop,
|
|
84
|
+
role,
|
|
85
|
+
layers,
|
|
86
|
+
props
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private createLambdaFunctionProps(props: CreateLambdaFunctionInput) {
|
|
91
|
+
const { prop, role, layers } = props;
|
|
92
|
+
|
|
93
|
+
const lambdaProp: NodejsFunctionProps = {
|
|
94
|
+
entry: path.join(prop.codePath),
|
|
95
|
+
functionName: `${this.config.AppPrefix}-${prop.name}`,
|
|
96
|
+
handler: prop.handler,
|
|
97
|
+
logRetention: (!prop.logDuration) ? RetentionDays.FIVE_DAYS : LambdaHelper.getDayToSaveLogs(prop.logDuration),
|
|
98
|
+
runtime: prop.runtime || this.config.GLOBALS.stackRuntime,
|
|
99
|
+
timeout: prop.duration || Duration.minutes(2),
|
|
100
|
+
memorySize: prop.memory || 512,
|
|
101
|
+
environment: {
|
|
102
|
+
"VERBOSE_LOGGING": "true",
|
|
103
|
+
...prop.environment
|
|
104
|
+
},
|
|
105
|
+
bundling: {
|
|
106
|
+
minify: false,
|
|
107
|
+
target: 'es2020',
|
|
108
|
+
sourceMap: true,
|
|
109
|
+
sourceMapMode: SourceMapMode.EXTERNAL,
|
|
110
|
+
environment: prop.environment || prop.environment,
|
|
111
|
+
},
|
|
112
|
+
role,
|
|
113
|
+
layers
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return lambdaProp;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
private createAlarmsForLambdas(lambdas: NodejsFunction[]) {
|
|
121
|
+
|
|
122
|
+
const lambdaRecords = this.createRecordForLambda(lambdas);
|
|
123
|
+
|
|
124
|
+
// console.log('Lambda Records:', lambdaRecords);
|
|
125
|
+
// const lambdaNames = Object.keys(lambdaRecords);
|
|
126
|
+
// console.log('lambda Names from Records', lambdaNames);
|
|
127
|
+
|
|
128
|
+
lambdas.forEach((lambda, idx) => {
|
|
129
|
+
|
|
130
|
+
const errorMetric = lambda.metricErrors({
|
|
131
|
+
period: Duration.minutes(3),
|
|
132
|
+
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const durationMetric = lambda.metricDuration({
|
|
136
|
+
period: Duration.minutes(3),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const invocationMetric = lambda.metricInvocations({
|
|
140
|
+
period: Duration.minutes(3),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const uuid = getUUID().split('-')[0];
|
|
144
|
+
|
|
145
|
+
new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-error-alarm`, {
|
|
146
|
+
metric: errorMetric,
|
|
147
|
+
threshold: 5,
|
|
148
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
149
|
+
evaluationPeriods: 3,
|
|
150
|
+
alarmDescription: `${this.config.AppPrefix} errors over 3 min period`,
|
|
151
|
+
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-error-alarm`
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-duration-alarm`, {
|
|
155
|
+
metric: durationMetric,
|
|
156
|
+
threshold: 1,
|
|
157
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
158
|
+
evaluationPeriods: 3,
|
|
159
|
+
alarmDescription: `${this.config.AppPrefix}-${lambda.node.id} duration errors over 3 min period`,
|
|
160
|
+
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-duration-alarm`
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const invocationAlarm = new Alarm(this.scope, `${this.config.AppPrefix}-${lambda.node.id}-invocation-alarm`, {
|
|
164
|
+
metric: errorMetric,
|
|
165
|
+
threshold: 1000,
|
|
166
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
167
|
+
evaluationPeriods: 3,
|
|
168
|
+
alarmDescription: `${this.config.AppPrefix}-${lambda.node.id} errors over 3 min period`,
|
|
169
|
+
alarmName: `${this.config.AppPrefix}-${lambda.node.id}-invocation-Metric-alarm`
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public static getIdForLambda(lambdaProp: TsgLambdaProp, appConfig: AppConfig) {
|
|
175
|
+
return `${appConfig.AppPrefix}-${lambdaProp.name}`.toLowerCase();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private createRecordForLambda(lambdas: NodejsFunction[]) {
|
|
179
|
+
|
|
180
|
+
const names = this.config.RESOURCES.LAMBDA.map((lambda) => {
|
|
181
|
+
return lambda.name;
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const lambdaNames = [...names] as const;
|
|
185
|
+
|
|
186
|
+
type LambdaName = typeof lambdaNames[number];
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
const lambdaRecord: Record<LambdaName, NodejsFunction> = {} as Record<LambdaName, NodejsFunction>;
|
|
190
|
+
|
|
191
|
+
lambdas.forEach((lambda, idx) => {
|
|
192
|
+
lambdaRecord[lambdaNames[idx] as LambdaName] = lambdas[idx];
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return lambdaRecord;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
@@ -1,134 +1,134 @@
|
|
|
1
|
-
import { IRole } from "aws-cdk-lib/aws-iam";
|
|
2
|
-
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
3
|
-
import { Construct } from "constructs";
|
|
4
|
-
import { TsgLambdaProp } from "../../config/types";
|
|
5
|
-
import { NodejsFunction, NodejsFunctionProps, SourceMapMode } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
6
|
-
import { TsgLambdaProps } from "../../config/types/TsgLambdaProps";
|
|
7
|
-
import { CreateLambdaFunctionInput } from "../../interfaces/CreateLambdaFunctionInput";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import { AppConfig } from "../../config/AppConfig";
|
|
10
|
-
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
11
|
-
import { Duration } from "aws-cdk-lib";
|
|
12
|
-
import { LogDuration } from "../../config/types/LogDuration";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export class LambdaHelper {
|
|
16
|
-
|
|
17
|
-
public static createLambdaFunctions(scope: Construct,
|
|
18
|
-
config: AppConfig,
|
|
19
|
-
lambdaConfigs: TsgLambdaProp | TsgLambdaProp[],
|
|
20
|
-
role?: IRole,
|
|
21
|
-
layers?: LayerVersion[]) {
|
|
22
|
-
|
|
23
|
-
const isArrayOfLambdaProps = Array.isArray(lambdaConfigs);
|
|
24
|
-
|
|
25
|
-
const appConfig = config;
|
|
26
|
-
|
|
27
|
-
if (isArrayOfLambdaProps) {
|
|
28
|
-
const createdLambdas = lambdaConfigs.map((config: TsgLambdaProp) => {
|
|
29
|
-
|
|
30
|
-
return LambdaHelper.createLambda(config, role, layers, appConfig, scope);
|
|
31
|
-
});
|
|
32
|
-
return createdLambdas || [];
|
|
33
|
-
} else {
|
|
34
|
-
return LambdaHelper.createLambda(lambdaConfigs as TsgLambdaProp, role, layers, config, scope);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private static createLambda(config: TsgLambdaProp,
|
|
39
|
-
role: IRole | undefined,
|
|
40
|
-
layers: LayerVersion[] | undefined,
|
|
41
|
-
appConfig: AppConfig,
|
|
42
|
-
scope: Construct) {
|
|
43
|
-
|
|
44
|
-
let lambdaProps = this.createLambdaProps(config, role, layers, {
|
|
45
|
-
appConfig: appConfig,
|
|
46
|
-
role,
|
|
47
|
-
layers,
|
|
48
|
-
scope
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const lambdaId = this.getIdForLambda(config, appConfig);
|
|
52
|
-
let fctn = new NodejsFunction(scope, lambdaId, lambdaProps);
|
|
53
|
-
|
|
54
|
-
if (lambdaId !== fctn.node.id) {
|
|
55
|
-
console.error(`can not find Lambda for : ${fctn.node.id}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return fctn;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private static createLambdaProps(prop: TsgLambdaProp,
|
|
62
|
-
role?: IRole,
|
|
63
|
-
layers?: LayerVersion[],
|
|
64
|
-
props?: TsgLambdaProps) {
|
|
65
|
-
|
|
66
|
-
return this.createLambdaFunctionProps({
|
|
67
|
-
prop,
|
|
68
|
-
role,
|
|
69
|
-
layers,
|
|
70
|
-
props
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private static createLambdaFunctionProps(props: CreateLambdaFunctionInput) {
|
|
75
|
-
const { prop, role, layers } = props;
|
|
76
|
-
|
|
77
|
-
const config = props.props?.appConfig;
|
|
78
|
-
|
|
79
|
-
const lambdaProp: NodejsFunctionProps = {
|
|
80
|
-
entry: path.join(prop.codePath),
|
|
81
|
-
functionName: `${config?.AppPrefix}-${prop.name}`,
|
|
82
|
-
handler: prop.handler,
|
|
83
|
-
logRetention: (!prop.logDuration) ? RetentionDays.FIVE_DAYS :
|
|
84
|
-
LambdaHelper.getDayToSaveLogs(prop.logDuration),
|
|
85
|
-
runtime: prop.runtime || config?.GLOBALS.stackRuntime,
|
|
86
|
-
timeout: prop.duration || Duration.minutes(2),
|
|
87
|
-
memorySize: prop.memory || 512,
|
|
88
|
-
environment: {
|
|
89
|
-
"VERBOSE_LOGGING": "true",
|
|
90
|
-
...prop.environment
|
|
91
|
-
},
|
|
92
|
-
bundling: {
|
|
93
|
-
minify: true,
|
|
94
|
-
target: "ESNext",
|
|
95
|
-
sourceMap: true,
|
|
96
|
-
sourceMapMode: SourceMapMode.EXTERNAL,
|
|
97
|
-
environment: prop.environment || prop.environment,
|
|
98
|
-
},
|
|
99
|
-
role,
|
|
100
|
-
layers
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
return lambdaProp;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
public static getDayToSaveLogs(saveLogDuration: LogDuration): RetentionDays {
|
|
107
|
-
|
|
108
|
-
switch (saveLogDuration) {
|
|
109
|
-
case LogDuration.ONE_DAY:
|
|
110
|
-
return RetentionDays.ONE_DAY;
|
|
111
|
-
|
|
112
|
-
case LogDuration.ONE_WEEK:
|
|
113
|
-
return RetentionDays.ONE_WEEK;
|
|
114
|
-
|
|
115
|
-
case LogDuration.ONE_MONTH:
|
|
116
|
-
return RetentionDays.ONE_MONTH;
|
|
117
|
-
|
|
118
|
-
case LogDuration.ONE_YEAR:
|
|
119
|
-
return RetentionDays.ONE_YEAR;
|
|
120
|
-
|
|
121
|
-
case LogDuration.FIVE_YEARS:
|
|
122
|
-
return RetentionDays.FIVE_YEARS;
|
|
123
|
-
|
|
124
|
-
case LogDuration.FOREVER:
|
|
125
|
-
return RetentionDays.INFINITE;
|
|
126
|
-
default:
|
|
127
|
-
return RetentionDays.FIVE_DAYS;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public static getIdForLambda(lambdaProp: TsgLambdaProp, appConfig: AppConfig) {
|
|
132
|
-
return `${appConfig.AppPrefix}-${lambdaProp.name}`.toLowerCase();
|
|
133
|
-
}
|
|
1
|
+
import { IRole } from "aws-cdk-lib/aws-iam";
|
|
2
|
+
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
import { TsgLambdaProp } from "../../config/types";
|
|
5
|
+
import { NodejsFunction, NodejsFunctionProps, SourceMapMode } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
6
|
+
import { TsgLambdaProps } from "../../config/types/TsgLambdaProps";
|
|
7
|
+
import { CreateLambdaFunctionInput } from "../../interfaces/CreateLambdaFunctionInput";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { AppConfig } from "../../config/AppConfig";
|
|
10
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
11
|
+
import { Duration } from "aws-cdk-lib";
|
|
12
|
+
import { LogDuration } from "../../config/types/LogDuration";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export class LambdaHelper {
|
|
16
|
+
|
|
17
|
+
public static createLambdaFunctions(scope: Construct,
|
|
18
|
+
config: AppConfig,
|
|
19
|
+
lambdaConfigs: TsgLambdaProp | TsgLambdaProp[],
|
|
20
|
+
role?: IRole,
|
|
21
|
+
layers?: LayerVersion[]) {
|
|
22
|
+
|
|
23
|
+
const isArrayOfLambdaProps = Array.isArray(lambdaConfigs);
|
|
24
|
+
|
|
25
|
+
const appConfig = config;
|
|
26
|
+
|
|
27
|
+
if (isArrayOfLambdaProps) {
|
|
28
|
+
const createdLambdas = lambdaConfigs.map((config: TsgLambdaProp) => {
|
|
29
|
+
|
|
30
|
+
return LambdaHelper.createLambda(config, role, layers, appConfig, scope);
|
|
31
|
+
});
|
|
32
|
+
return createdLambdas || [];
|
|
33
|
+
} else {
|
|
34
|
+
return LambdaHelper.createLambda(lambdaConfigs as TsgLambdaProp, role, layers, config, scope);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static createLambda(config: TsgLambdaProp,
|
|
39
|
+
role: IRole | undefined,
|
|
40
|
+
layers: LayerVersion[] | undefined,
|
|
41
|
+
appConfig: AppConfig,
|
|
42
|
+
scope: Construct) {
|
|
43
|
+
|
|
44
|
+
let lambdaProps = this.createLambdaProps(config, role, layers, {
|
|
45
|
+
appConfig: appConfig,
|
|
46
|
+
role,
|
|
47
|
+
layers,
|
|
48
|
+
scope
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const lambdaId = this.getIdForLambda(config, appConfig);
|
|
52
|
+
let fctn = new NodejsFunction(scope, lambdaId, lambdaProps);
|
|
53
|
+
|
|
54
|
+
if (lambdaId !== fctn.node.id) {
|
|
55
|
+
console.error(`can not find Lambda for : ${fctn.node.id}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return fctn;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private static createLambdaProps(prop: TsgLambdaProp,
|
|
62
|
+
role?: IRole,
|
|
63
|
+
layers?: LayerVersion[],
|
|
64
|
+
props?: TsgLambdaProps) {
|
|
65
|
+
|
|
66
|
+
return this.createLambdaFunctionProps({
|
|
67
|
+
prop,
|
|
68
|
+
role,
|
|
69
|
+
layers,
|
|
70
|
+
props
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private static createLambdaFunctionProps(props: CreateLambdaFunctionInput) {
|
|
75
|
+
const { prop, role, layers } = props;
|
|
76
|
+
|
|
77
|
+
const config = props.props?.appConfig;
|
|
78
|
+
|
|
79
|
+
const lambdaProp: NodejsFunctionProps = {
|
|
80
|
+
entry: path.join(prop.codePath),
|
|
81
|
+
functionName: `${config?.AppPrefix}-${prop.name}`,
|
|
82
|
+
handler: prop.handler,
|
|
83
|
+
logRetention: (!prop.logDuration) ? RetentionDays.FIVE_DAYS :
|
|
84
|
+
LambdaHelper.getDayToSaveLogs(prop.logDuration),
|
|
85
|
+
runtime: prop.runtime || config?.GLOBALS.stackRuntime,
|
|
86
|
+
timeout: prop.duration || Duration.minutes(2),
|
|
87
|
+
memorySize: prop.memory || 512,
|
|
88
|
+
environment: {
|
|
89
|
+
"VERBOSE_LOGGING": "true",
|
|
90
|
+
...prop.environment
|
|
91
|
+
},
|
|
92
|
+
bundling: {
|
|
93
|
+
minify: true,
|
|
94
|
+
target: "ESNext",
|
|
95
|
+
sourceMap: true,
|
|
96
|
+
sourceMapMode: SourceMapMode.EXTERNAL,
|
|
97
|
+
environment: prop.environment || prop.environment,
|
|
98
|
+
},
|
|
99
|
+
role,
|
|
100
|
+
layers
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
return lambdaProp;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
public static getDayToSaveLogs(saveLogDuration: LogDuration): RetentionDays {
|
|
107
|
+
|
|
108
|
+
switch (saveLogDuration) {
|
|
109
|
+
case LogDuration.ONE_DAY:
|
|
110
|
+
return RetentionDays.ONE_DAY;
|
|
111
|
+
|
|
112
|
+
case LogDuration.ONE_WEEK:
|
|
113
|
+
return RetentionDays.ONE_WEEK;
|
|
114
|
+
|
|
115
|
+
case LogDuration.ONE_MONTH:
|
|
116
|
+
return RetentionDays.ONE_MONTH;
|
|
117
|
+
|
|
118
|
+
case LogDuration.ONE_YEAR:
|
|
119
|
+
return RetentionDays.ONE_YEAR;
|
|
120
|
+
|
|
121
|
+
case LogDuration.FIVE_YEARS:
|
|
122
|
+
return RetentionDays.FIVE_YEARS;
|
|
123
|
+
|
|
124
|
+
case LogDuration.FOREVER:
|
|
125
|
+
return RetentionDays.INFINITE;
|
|
126
|
+
default:
|
|
127
|
+
return RetentionDays.FIVE_DAYS;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public static getIdForLambda(lambdaProp: TsgLambdaProp, appConfig: AppConfig) {
|
|
132
|
+
return `${appConfig.AppPrefix}-${lambdaProp.name}`.toLowerCase();
|
|
133
|
+
}
|
|
134
134
|
}
|