@sylvesterllc/aws-constructs 1.1.60 → 1.1.61
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 +69 -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 +3 -3
- package/dist/constructs/DynamoDbSingleTable.js +1 -1
- package/dist/constructs/MicroService.js +1 -1
- package/dist/constructs/basic-queue.js +1 -1
- package/dist/constructs/index.js +1 -1
- package/dist/constructs/timer-job.js +3 -3
- 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.js +1 -1
- 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 +1 -1
- package/dist/resources/lambda/create-basic-lambda.js +1 -1
- 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.js +1 -1
- package/jest.config.js +8 -8
- package/jest.config.ts.old +20 -20
- package/package.json +1 -1
- 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 +9 -9
- package/src/constructs/MicroService.ts +131 -131
- package/src/constructs/basic-queue.ts +18 -18
- package/src/constructs/index.ts +6 -6
- 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 +118 -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 -124
- package/src/resources/lambda/create-basic-lambda.ts +162 -162
- package/src/resources/lambda/createLambda.ts +239 -239
- 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 +26 -26
- package/tsconfig.json +46 -46
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TsgLambdaProp } from "./TsgLambdaProp";
|
|
2
|
-
|
|
3
|
-
export type TsgLambda = {
|
|
4
|
-
[name: string]: TsgLambdaProp;
|
|
5
|
-
|
|
1
|
+
import { TsgLambdaProp } from "./TsgLambdaProp";
|
|
2
|
+
|
|
3
|
+
export type TsgLambda = {
|
|
4
|
+
[name: string]: TsgLambdaProp;
|
|
5
|
+
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface TsgLambdaLayerProp {
|
|
2
|
-
name: string;
|
|
3
|
-
codePath: string;
|
|
4
|
-
description: string;
|
|
1
|
+
export interface TsgLambdaLayerProp {
|
|
2
|
+
name: string;
|
|
3
|
+
codePath: string;
|
|
4
|
+
description: string;
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
2
|
-
import { TsgLambdaNode } from "./TsgLambdaNode";
|
|
3
|
-
|
|
1
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
2
|
+
import { TsgLambdaNode } from "./TsgLambdaNode";
|
|
3
|
+
|
|
4
4
|
export type TsgLambdaMap = [NodejsFunction[], Map<string, TsgLambdaNode>]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// DO NOT FORGET TO UPDATE TsgLambdaNameHelper
|
|
2
|
-
// WITH NEW LAMBDA NAMES
|
|
3
|
-
export type TsgLambdaName = 'create-account' | 'verify-code' | 'change-password' | 'check-login' |
|
|
1
|
+
// DO NOT FORGET TO UPDATE TsgLambdaNameHelper
|
|
2
|
+
// WITH NEW LAMBDA NAMES
|
|
3
|
+
export type TsgLambdaName = 'create-account' | 'verify-code' | 'change-password' | 'check-login' |
|
|
4
4
|
'get-users' | 'resend-confirmation-code';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodejsFunction, NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
2
|
-
import { TsgLambdaProp } from "./TsgLambdaProp";
|
|
3
|
-
|
|
1
|
+
import { NodejsFunction, NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
2
|
+
import { TsgLambdaProp } from "./TsgLambdaProp";
|
|
3
|
+
|
|
4
4
|
export type TsgLambdaNode = [TsgLambdaProp, NodejsFunction, NodejsFunctionProps];
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Duration } from "aws-cdk-lib";
|
|
2
|
-
import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
3
|
-
import { TsgLambdaRoutable } from "./TsgLambdaRoutable";
|
|
4
|
-
import { LogDuration } from "./LogDuration";
|
|
5
|
-
import { TsgAuthorizerType } from "./TsgAuthorizerType";
|
|
6
|
-
|
|
7
|
-
export interface TsgLambdaProp {
|
|
8
|
-
|
|
9
|
-
name: string;
|
|
10
|
-
codePath: string;
|
|
11
|
-
handler: string;
|
|
12
|
-
duration?: Duration;
|
|
13
|
-
environment?: { [name: string]: string };
|
|
14
|
-
runtime?: Runtime;
|
|
15
|
-
memory?: number;
|
|
16
|
-
apiGateway?: TsgLambdaRoutable;
|
|
17
|
-
managedPolicies?: string[];
|
|
18
|
-
logDuration?: LogDuration;
|
|
19
|
-
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { TsgLambdaRoutable } from "./TsgLambdaRoutable";
|
|
4
|
+
import { LogDuration } from "./LogDuration";
|
|
5
|
+
import { TsgAuthorizerType } from "./TsgAuthorizerType";
|
|
6
|
+
|
|
7
|
+
export interface TsgLambdaProp {
|
|
8
|
+
|
|
9
|
+
name: string;
|
|
10
|
+
codePath: string;
|
|
11
|
+
handler: string;
|
|
12
|
+
duration?: Duration;
|
|
13
|
+
environment?: { [name: string]: string };
|
|
14
|
+
runtime?: Runtime;
|
|
15
|
+
memory?: number;
|
|
16
|
+
apiGateway?: TsgLambdaRoutable;
|
|
17
|
+
managedPolicies?: string[];
|
|
18
|
+
logDuration?: LogDuration;
|
|
19
|
+
|
|
20
20
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { IUserPool } from "aws-cdk-lib/aws-cognito";
|
|
2
|
-
import { IRole } from "aws-cdk-lib/aws-iam";
|
|
3
|
-
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
4
|
-
import { Construct } from "constructs";
|
|
5
|
-
import { MicroserviceProps } from "../../interfaces/MicroserviceProps";
|
|
6
|
-
import { TsgCognitoConfig } from "./TsgCognitoConfig";
|
|
7
|
-
import { AppConfig } from "../AppConfig";
|
|
8
|
-
|
|
9
|
-
export interface TsgLambdaProps {
|
|
10
|
-
|
|
11
|
-
scope: Construct;
|
|
12
|
-
appConfig: AppConfig;
|
|
13
|
-
role?: IRole;
|
|
14
|
-
poolArn?: IUserPool;
|
|
15
|
-
layers?: LayerVersion[];
|
|
16
|
-
tsgCognito?: TsgCognitoConfig;
|
|
17
|
-
|
|
1
|
+
import { IUserPool } from "aws-cdk-lib/aws-cognito";
|
|
2
|
+
import { IRole } from "aws-cdk-lib/aws-iam";
|
|
3
|
+
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
import { Construct } from "constructs";
|
|
5
|
+
import { MicroserviceProps } from "../../interfaces/MicroserviceProps";
|
|
6
|
+
import { TsgCognitoConfig } from "./TsgCognitoConfig";
|
|
7
|
+
import { AppConfig } from "../AppConfig";
|
|
8
|
+
|
|
9
|
+
export interface TsgLambdaProps {
|
|
10
|
+
|
|
11
|
+
scope: Construct;
|
|
12
|
+
appConfig: AppConfig;
|
|
13
|
+
role?: IRole;
|
|
14
|
+
poolArn?: IUserPool;
|
|
15
|
+
layers?: LayerVersion[];
|
|
16
|
+
tsgCognito?: TsgCognitoConfig;
|
|
17
|
+
|
|
18
18
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export interface TsgLambdaRoutable {
|
|
2
|
-
route: string;
|
|
3
|
-
secure?: boolean;
|
|
4
|
-
method?: "get" | "post" | "delete" | "put" | "patch";
|
|
5
|
-
version?: number;
|
|
6
|
-
useRouteOverride?: boolean;
|
|
7
|
-
requireApiKey?: boolean;
|
|
8
|
-
queryStrings?: string[];
|
|
1
|
+
export interface TsgLambdaRoutable {
|
|
2
|
+
route: string;
|
|
3
|
+
secure?: boolean;
|
|
4
|
+
method?: "get" | "post" | "delete" | "put" | "patch";
|
|
5
|
+
version?: number;
|
|
6
|
+
useRouteOverride?: boolean;
|
|
7
|
+
requireApiKey?: boolean;
|
|
8
|
+
queryStrings?: string[];
|
|
9
9
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from "./TsgAuthorizerProp";
|
|
2
|
-
export * from "./TsgAuthorizerType";
|
|
3
|
-
export * from "./TsgCognitoConfig";
|
|
4
|
-
export * from "./TsgDynamoDbProp";
|
|
5
|
-
export * from "./TsgDynamoProp";
|
|
6
|
-
export * from "./TsgDynamoTableRef";
|
|
7
|
-
export * from "./TsgLambdaMap";
|
|
8
|
-
export * from "./TsgLambdaName";
|
|
9
|
-
export * from "./TsgLambdaNode";
|
|
10
|
-
export * from "./TsgLambdaProp";
|
|
11
|
-
|
|
1
|
+
export * from "./TsgAuthorizerProp";
|
|
2
|
+
export * from "./TsgAuthorizerType";
|
|
3
|
+
export * from "./TsgCognitoConfig";
|
|
4
|
+
export * from "./TsgDynamoDbProp";
|
|
5
|
+
export * from "./TsgDynamoProp";
|
|
6
|
+
export * from "./TsgDynamoTableRef";
|
|
7
|
+
export * from "./TsgLambdaMap";
|
|
8
|
+
export * from "./TsgLambdaName";
|
|
9
|
+
export * from "./TsgLambdaNode";
|
|
10
|
+
export * from "./TsgLambdaProp";
|
|
11
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const SERVICE_PRINCIPAL = {
|
|
2
|
-
"EVENTS" : 'events.amazonaws.com'
|
|
1
|
+
export const SERVICE_PRINCIPAL = {
|
|
2
|
+
"EVENTS" : 'events.amazonaws.com'
|
|
3
3
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { LambdaProps } from "../interfaces/lambda";
|
|
3
|
-
import { createBasicLambda } from "../resources/lambda/create-basic-lambda-helper
|
|
4
|
-
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
|
-
|
|
6
|
-
export class BasicLambda extends Construct {
|
|
7
|
-
public readonly lambdaFunction: NodejsFunction;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
scope: Construct,
|
|
11
|
-
id: string,
|
|
12
|
-
props: LambdaProps,
|
|
13
|
-
private env: string
|
|
14
|
-
) {
|
|
15
|
-
super(scope, id);
|
|
16
|
-
|
|
17
|
-
this.lambdaFunction = createBasicLambda(scope, props);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { LambdaProps } from "../interfaces/lambda";
|
|
3
|
+
import { createBasicLambda } from "../resources/lambda/create-basic-lambda-helper";
|
|
4
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
|
+
|
|
6
|
+
export class BasicLambda extends Construct {
|
|
7
|
+
public readonly lambdaFunction: NodejsFunction;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
scope: Construct,
|
|
11
|
+
id: string,
|
|
12
|
+
props: LambdaProps,
|
|
13
|
+
private env: string,
|
|
14
|
+
) {
|
|
15
|
+
super(scope, id);
|
|
16
|
+
|
|
17
|
+
this.lambdaFunction = createBasicLambda(scope, props);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { CreateDynamoSingleTableDesign } from "../resources/dynamodb/CreateDynamoSingleTableDesign";
|
|
3
|
-
|
|
4
|
-
export class DynamoDbSingleTable extends Construct {
|
|
5
|
-
constructor(scope: Construct, id: string, tableName: string) {
|
|
6
|
-
super(scope, id);
|
|
7
|
-
new CreateDynamoSingleTableDesign(this, id, tableName);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { CreateDynamoSingleTableDesign } from "../resources/dynamodb/CreateDynamoSingleTableDesign";
|
|
3
|
+
|
|
4
|
+
export class DynamoDbSingleTable extends Construct {
|
|
5
|
+
constructor(scope: Construct, id: string, tableName: string) {
|
|
6
|
+
super(scope, id);
|
|
7
|
+
new CreateDynamoSingleTableDesign(this, id, tableName);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
import { Table } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
import { MicroserviceProps } from "../interfaces/MicroserviceProps";
|
|
4
|
-
import { CreateDynamoDb } from "../resources/dynamodb/CreateDynamo";
|
|
5
|
-
import { Api } from "../resources/gateway/createApi";
|
|
6
|
-
import { getSecretManager } from "../resources/securityManager";
|
|
7
|
-
import { createCommonLayer } from "../resources/helpers/createCommonLayer";
|
|
8
|
-
import { AppConfig } from "../config/AppConfig";
|
|
9
|
-
import { Tags } from "aws-cdk-lib";
|
|
10
|
-
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
11
|
-
import { CreateApiAndAttachLambdas } from "../resources/gateway/CreateApiAndAttachLambdas";
|
|
12
|
-
import { createSeedDatabaseCustomResource } from "../resources/customResource/createSeedDatabaseCustomResource";
|
|
13
|
-
import { IRestApi } from "aws-cdk-lib/aws-apigateway";
|
|
14
|
-
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
|
15
|
-
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
16
|
-
|
|
17
|
-
export class MicroService extends Construct {
|
|
18
|
-
|
|
19
|
-
protected readonly requireDynamoTables: boolean;
|
|
20
|
-
protected requireSeedDatabase: boolean = false;
|
|
21
|
-
protected readonly hasLambdaLayers: boolean = false;
|
|
22
|
-
protected appConfig: AppConfig;
|
|
23
|
-
private readonly api: IRestApi;
|
|
24
|
-
private readonly dynamoTables: Table[] | undefined;
|
|
25
|
-
private readonly lambdaLayers: LayerVersion[] | undefined;
|
|
26
|
-
private readonly secretManager: ISecret | null = null;
|
|
27
|
-
private readonly lambdas: NodejsFunction[] = [];
|
|
28
|
-
private lambdaRecords: Record<string, NodejsFunction> = {};
|
|
29
|
-
|
|
30
|
-
public get Tables() {
|
|
31
|
-
return this.dynamoTables;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public get SecretManager() {
|
|
35
|
-
return this.secretManager;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public get LambdaLayers() {
|
|
39
|
-
return this.lambdaLayers;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public get Lambdas() {
|
|
43
|
-
return this.lambdas;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public get LambdaRecords() {
|
|
47
|
-
return this.lambdaRecords;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public get RestApi() {
|
|
51
|
-
return this.api;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
constructor(scope: Construct, id: string, props: MicroserviceProps,
|
|
55
|
-
private env: string) {
|
|
56
|
-
super(scope, id);
|
|
57
|
-
|
|
58
|
-
this.appConfig = new AppConfig(props);
|
|
59
|
-
|
|
60
|
-
this.requireDynamoTables = (props.RESOURCES.DYNAMO?.TABLES &&
|
|
61
|
-
props.RESOURCES.DYNAMO.TABLES.length > 0) ? true : false;
|
|
62
|
-
|
|
63
|
-
this.requireSeedDatabase = (props.RESOURCES.DYNAMO?.USE_SEED_DATABASE &&
|
|
64
|
-
props.RESOURCES.DYNAMO.SEED_LAMBDA) ? true : false;
|
|
65
|
-
|
|
66
|
-
this.hasLambdaLayers = (props.RESOURCES.LAMBDA_LAYERS &&
|
|
67
|
-
props.RESOURCES.LAMBDA_LAYERS.length > 0) ? true : false;
|
|
68
|
-
|
|
69
|
-
const results = this.onInit(scope);
|
|
70
|
-
|
|
71
|
-
this.api = results.restApi!;
|
|
72
|
-
this.dynamoTables = results.dynamoTables!;
|
|
73
|
-
this.lambdaLayers = results.lambdaLayers!;
|
|
74
|
-
this.secretManager = results.secretManager!;
|
|
75
|
-
|
|
76
|
-
this.lambdas = results.lambdas!;
|
|
77
|
-
|
|
78
|
-
this.createTag(scope)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
private onInit(scope: Construct) {
|
|
82
|
-
|
|
83
|
-
let secretManager: ISecret | null = null;
|
|
84
|
-
let tables: Table[] | undefined = undefined;
|
|
85
|
-
let commonLayers: LayerVersion[] | undefined = undefined;
|
|
86
|
-
|
|
87
|
-
if (process.env.SECRET_MANAGER_ARN) {
|
|
88
|
-
// throw new Error(`You must provide the ARN for the your Configuration Secret
|
|
89
|
-
// Manager`);
|
|
90
|
-
secretManager = getSecretManager(scope, this.appConfig, process.env.SECRET_MANAGER_ARN);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (this.hasLambdaLayers) {
|
|
94
|
-
commonLayers = createCommonLayer(scope, this.appConfig);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const gateway = new Api(scope, this.appConfig, this.env).APIs;
|
|
98
|
-
|
|
99
|
-
const layers = commonLayers;
|
|
100
|
-
|
|
101
|
-
// Creates DynamoDb Tables if required
|
|
102
|
-
if (this.requireDynamoTables) {
|
|
103
|
-
const dynamo = new CreateDynamoDb(scope, this.appConfig);
|
|
104
|
-
|
|
105
|
-
tables = dynamo.CreatedTables;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (this.requireSeedDatabase) {
|
|
109
|
-
createSeedDatabaseCustomResource(scope, this.appConfig, tables![0], layers);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// CREATE API GATEWAY AND LAMBDA HERE
|
|
113
|
-
const apiGateway = new CreateApiAndAttachLambdas(scope, this.appConfig, gateway[0], layers, tables);
|
|
114
|
-
|
|
115
|
-
this.lambdaRecords = apiGateway.LambdaRecords;
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
restApi: (gateway?.length > 0) ? gateway[0] : null,
|
|
119
|
-
lambdaLayers: layers || null,
|
|
120
|
-
dynamoTables: tables || null,
|
|
121
|
-
secretManager: secretManager,
|
|
122
|
-
lambdas: apiGateway.Lambdas,
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
protected createTag(scope: Construct) {
|
|
129
|
-
Tags.of(scope).add('App', this.appConfig.AppName);
|
|
130
|
-
Tags.of(scope).add('ResoucePrefix', this.appConfig.AppPrefix);
|
|
131
|
-
}
|
|
1
|
+
import { Table } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { MicroserviceProps } from "../interfaces/MicroserviceProps";
|
|
4
|
+
import { CreateDynamoDb } from "../resources/dynamodb/CreateDynamo";
|
|
5
|
+
import { Api } from "../resources/gateway/createApi";
|
|
6
|
+
import { getSecretManager } from "../resources/securityManager";
|
|
7
|
+
import { createCommonLayer } from "../resources/helpers/createCommonLayer";
|
|
8
|
+
import { AppConfig } from "../config/AppConfig";
|
|
9
|
+
import { Tags } from "aws-cdk-lib";
|
|
10
|
+
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
11
|
+
import { CreateApiAndAttachLambdas } from "../resources/gateway/CreateApiAndAttachLambdas";
|
|
12
|
+
import { createSeedDatabaseCustomResource } from "../resources/customResource/createSeedDatabaseCustomResource";
|
|
13
|
+
import { IRestApi } from "aws-cdk-lib/aws-apigateway";
|
|
14
|
+
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
|
15
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
16
|
+
|
|
17
|
+
export class MicroService extends Construct {
|
|
18
|
+
|
|
19
|
+
protected readonly requireDynamoTables: boolean;
|
|
20
|
+
protected requireSeedDatabase: boolean = false;
|
|
21
|
+
protected readonly hasLambdaLayers: boolean = false;
|
|
22
|
+
protected appConfig: AppConfig;
|
|
23
|
+
private readonly api: IRestApi;
|
|
24
|
+
private readonly dynamoTables: Table[] | undefined;
|
|
25
|
+
private readonly lambdaLayers: LayerVersion[] | undefined;
|
|
26
|
+
private readonly secretManager: ISecret | null = null;
|
|
27
|
+
private readonly lambdas: NodejsFunction[] = [];
|
|
28
|
+
private lambdaRecords: Record<string, NodejsFunction> = {};
|
|
29
|
+
|
|
30
|
+
public get Tables() {
|
|
31
|
+
return this.dynamoTables;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public get SecretManager() {
|
|
35
|
+
return this.secretManager;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public get LambdaLayers() {
|
|
39
|
+
return this.lambdaLayers;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public get Lambdas() {
|
|
43
|
+
return this.lambdas;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get LambdaRecords() {
|
|
47
|
+
return this.lambdaRecords;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get RestApi() {
|
|
51
|
+
return this.api;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
constructor(scope: Construct, id: string, props: MicroserviceProps,
|
|
55
|
+
private env: string) {
|
|
56
|
+
super(scope, id);
|
|
57
|
+
|
|
58
|
+
this.appConfig = new AppConfig(props);
|
|
59
|
+
|
|
60
|
+
this.requireDynamoTables = (props.RESOURCES.DYNAMO?.TABLES &&
|
|
61
|
+
props.RESOURCES.DYNAMO.TABLES.length > 0) ? true : false;
|
|
62
|
+
|
|
63
|
+
this.requireSeedDatabase = (props.RESOURCES.DYNAMO?.USE_SEED_DATABASE &&
|
|
64
|
+
props.RESOURCES.DYNAMO.SEED_LAMBDA) ? true : false;
|
|
65
|
+
|
|
66
|
+
this.hasLambdaLayers = (props.RESOURCES.LAMBDA_LAYERS &&
|
|
67
|
+
props.RESOURCES.LAMBDA_LAYERS.length > 0) ? true : false;
|
|
68
|
+
|
|
69
|
+
const results = this.onInit(scope);
|
|
70
|
+
|
|
71
|
+
this.api = results.restApi!;
|
|
72
|
+
this.dynamoTables = results.dynamoTables!;
|
|
73
|
+
this.lambdaLayers = results.lambdaLayers!;
|
|
74
|
+
this.secretManager = results.secretManager!;
|
|
75
|
+
|
|
76
|
+
this.lambdas = results.lambdas!;
|
|
77
|
+
|
|
78
|
+
this.createTag(scope)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private onInit(scope: Construct) {
|
|
82
|
+
|
|
83
|
+
let secretManager: ISecret | null = null;
|
|
84
|
+
let tables: Table[] | undefined = undefined;
|
|
85
|
+
let commonLayers: LayerVersion[] | undefined = undefined;
|
|
86
|
+
|
|
87
|
+
if (process.env.SECRET_MANAGER_ARN) {
|
|
88
|
+
// throw new Error(`You must provide the ARN for the your Configuration Secret
|
|
89
|
+
// Manager`);
|
|
90
|
+
secretManager = getSecretManager(scope, this.appConfig, process.env.SECRET_MANAGER_ARN);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.hasLambdaLayers) {
|
|
94
|
+
commonLayers = createCommonLayer(scope, this.appConfig);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const gateway = new Api(scope, this.appConfig, this.env).APIs;
|
|
98
|
+
|
|
99
|
+
const layers = commonLayers;
|
|
100
|
+
|
|
101
|
+
// Creates DynamoDb Tables if required
|
|
102
|
+
if (this.requireDynamoTables) {
|
|
103
|
+
const dynamo = new CreateDynamoDb(scope, this.appConfig);
|
|
104
|
+
|
|
105
|
+
tables = dynamo.CreatedTables;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this.requireSeedDatabase) {
|
|
109
|
+
createSeedDatabaseCustomResource(scope, this.appConfig, tables![0], layers);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// CREATE API GATEWAY AND LAMBDA HERE
|
|
113
|
+
const apiGateway = new CreateApiAndAttachLambdas(scope, this.appConfig, gateway[0], layers, tables);
|
|
114
|
+
|
|
115
|
+
this.lambdaRecords = apiGateway.LambdaRecords;
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
restApi: (gateway?.length > 0) ? gateway[0] : null,
|
|
119
|
+
lambdaLayers: layers || null,
|
|
120
|
+
dynamoTables: tables || null,
|
|
121
|
+
secretManager: secretManager,
|
|
122
|
+
lambdas: apiGateway.Lambdas,
|
|
123
|
+
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected createTag(scope: Construct) {
|
|
129
|
+
Tags.of(scope).add('App', this.appConfig.AppName);
|
|
130
|
+
Tags.of(scope).add('ResoucePrefix', this.appConfig.AppPrefix);
|
|
131
|
+
}
|
|
132
132
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { IQueue } from "aws-cdk-lib/aws-sqs";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
import { createSQSResource } from "../resources/sqs/create-sqs-resource";
|
|
4
|
-
|
|
5
|
-
export class BasicQueue extends Construct {
|
|
6
|
-
|
|
7
|
-
public readonly queue: IQueue;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
scope: Construct,
|
|
11
|
-
id: string,
|
|
12
|
-
props: { queueName: string },
|
|
13
|
-
private env: string
|
|
14
|
-
) {
|
|
15
|
-
super(scope, id);
|
|
16
|
-
|
|
17
|
-
this.queue = createSQSResource(scope, props.queueName);
|
|
18
|
-
}
|
|
1
|
+
import { IQueue } from "aws-cdk-lib/aws-sqs";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { createSQSResource } from "../resources/sqs/create-sqs-resource";
|
|
4
|
+
|
|
5
|
+
export class BasicQueue extends Construct {
|
|
6
|
+
|
|
7
|
+
public readonly queue: IQueue;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
scope: Construct,
|
|
11
|
+
id: string,
|
|
12
|
+
props: { queueName: string },
|
|
13
|
+
private env: string
|
|
14
|
+
) {
|
|
15
|
+
super(scope, id);
|
|
16
|
+
|
|
17
|
+
this.queue = createSQSResource(scope, props.queueName);
|
|
18
|
+
}
|
|
19
19
|
}
|
package/src/constructs/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { MicroService } from "./MicroService";
|
|
2
|
-
export { TsgAuthorizerType } from "../config/types/TsgAuthorizerType";
|
|
3
|
-
export { DynamoDbSingleTable } from "./DynamoDbSingleTable";
|
|
4
|
-
export { TimerJob } from "./timer-job";
|
|
5
|
-
export { BasicLambda } from "./BasicLambda";
|
|
6
|
-
export * from "./basic-queue";
|
|
1
|
+
export { MicroService } from "./MicroService";
|
|
2
|
+
export { TsgAuthorizerType } from "../config/types/TsgAuthorizerType";
|
|
3
|
+
export { DynamoDbSingleTable } from "./DynamoDbSingleTable";
|
|
4
|
+
export { TimerJob } from "./timer-job";
|
|
5
|
+
export { BasicLambda } from "./BasicLambda";
|
|
6
|
+
export * from "./basic-queue";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { TimerJobProps } from "../interfaces/timer-job";
|
|
3
|
-
import { createBasicLambdaTimerJob } from "../resources/lambda/create-basic-lambda
|
|
4
|
-
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
|
-
|
|
6
|
-
export class TimerJob extends Construct {
|
|
7
|
-
public readonly lambdaFunction: NodejsFunction;
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
scope: Construct,
|
|
11
|
-
id: string,
|
|
12
|
-
props: TimerJobProps,
|
|
13
|
-
private env: string
|
|
14
|
-
) {
|
|
15
|
-
super(scope, id);
|
|
16
|
-
|
|
17
|
-
this.lambdaFunction = createBasicLambdaTimerJob(scope, props);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { TimerJobProps } from "../interfaces/timer-job";
|
|
3
|
+
import { createBasicLambdaTimerJob } from "../resources/lambda/create-basic-lambda";
|
|
4
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
|
+
|
|
6
|
+
export class TimerJob extends Construct {
|
|
7
|
+
public readonly lambdaFunction: NodejsFunction;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
scope: Construct,
|
|
11
|
+
id: string,
|
|
12
|
+
props: TimerJobProps,
|
|
13
|
+
private env: string,
|
|
14
|
+
) {
|
|
15
|
+
super(scope, id);
|
|
16
|
+
|
|
17
|
+
this.lambdaFunction = createBasicLambdaTimerJob(scope, props);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/helpers/logger.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { debug } from "console";
|
|
2
|
-
|
|
3
|
-
export class Logger {
|
|
4
|
-
|
|
5
|
-
constructor(private debug: boolean = false) { }
|
|
6
|
-
|
|
7
|
-
public log(message: string) {
|
|
8
|
-
|
|
9
|
-
if (this.debug) {
|
|
10
|
-
console.log(message);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { debug } from "console";
|
|
2
|
+
|
|
3
|
+
export class Logger {
|
|
4
|
+
|
|
5
|
+
constructor(private debug: boolean = false) { }
|
|
6
|
+
|
|
7
|
+
public log(message: string) {
|
|
8
|
+
|
|
9
|
+
if (this.debug) {
|
|
10
|
+
console.log(message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
}
|