@sylvesterllc/aws-constructs 1.1.11 → 1.1.13
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 +58 -38
- 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.d.ts +3 -0
- package/dist/constants/aws-service-principal-constants.js +7 -0
- package/dist/constructs/DynamoDbSingleTable.js +1 -1
- package/dist/constructs/MicroService.js +1 -1
- package/dist/constructs/index.d.ts +1 -0
- package/dist/constructs/index.js +4 -2
- package/dist/constructs/timer-job.d.ts +6 -0
- package/dist/constructs/timer-job.js +15 -0
- package/dist/helpers/logger.js +1 -1
- package/dist/helpers/util-helper.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +18 -4
- 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/timer-job/index.d.ts +1 -0
- package/dist/interfaces/timer-job/index.js +18 -0
- package/dist/interfaces/timer-job/timer-job-props.d.ts +14 -0
- package/dist/interfaces/timer-job/timer-job-props.js +3 -0
- 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.d.ts +3 -0
- package/dist/resources/lambda/create-basic-lambda.js +77 -0
- 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/jest.config.js +8 -8
- package/jest.config.ts.old +20 -20
- package/package.json +55 -56
- 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 +3 -0
- package/src/constructs/DynamoDbSingleTable.ts +12 -12
- package/src/constructs/MicroService.ts +131 -132
- package/src/constructs/index.ts +4 -3
- package/src/constructs/timer-job.ts +17 -0
- package/src/helpers/logger.ts +12 -12
- package/src/helpers/util-helper.ts +19 -19
- package/src/index.ts +6 -5
- 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/timer-job/index.ts +1 -0
- package/src/interfaces/timer-job/timer-job-props.ts +17 -0
- 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 +111 -111
- 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.ts +104 -0
- package/src/resources/lambda/createLambda.ts +203 -200
- 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/tsconfig.json +44 -42
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ApiAppConfig } from "../config/customConfigs/ApiAppConfig";
|
|
2
|
-
import { GlobalAppConfig } from "../config/customConfigs/GlobalAppConfig";
|
|
3
|
-
import { ResourceAppConfig } from "../config/customConfigs/ResourceAppConfig";
|
|
4
|
-
import { TsgDnsAppConfig } from "../config/types/TsgDnsConfig";
|
|
5
|
-
|
|
6
|
-
export interface MicroserviceProps {
|
|
7
|
-
API: ApiAppConfig;
|
|
8
|
-
GLOBALS: GlobalAppConfig;
|
|
9
|
-
RESOURCES: ResourceAppConfig;
|
|
10
|
-
DNS?: TsgDnsAppConfig;
|
|
1
|
+
import { ApiAppConfig } from "../config/customConfigs/ApiAppConfig";
|
|
2
|
+
import { GlobalAppConfig } from "../config/customConfigs/GlobalAppConfig";
|
|
3
|
+
import { ResourceAppConfig } from "../config/customConfigs/ResourceAppConfig";
|
|
4
|
+
import { TsgDnsAppConfig } from "../config/types/TsgDnsConfig";
|
|
5
|
+
|
|
6
|
+
export interface MicroserviceProps {
|
|
7
|
+
API: ApiAppConfig;
|
|
8
|
+
GLOBALS: GlobalAppConfig;
|
|
9
|
+
RESOURCES: ResourceAppConfig;
|
|
10
|
+
DNS?: TsgDnsAppConfig;
|
|
11
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./timer-job-props";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CronOptions } from "aws-cdk-lib/aws-events/lib/schedule";
|
|
2
|
+
import { IRole } from "aws-cdk-lib/aws-iam/lib";
|
|
3
|
+
import { LayerVersion } from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
|
|
5
|
+
export interface TimerJobProps {
|
|
6
|
+
|
|
7
|
+
functionName: string;
|
|
8
|
+
appPrefix: string;
|
|
9
|
+
codePath: string;
|
|
10
|
+
timeoutInMinutes: number;
|
|
11
|
+
memory: number;
|
|
12
|
+
envs: Record<string, string>;
|
|
13
|
+
role?: IRole;
|
|
14
|
+
cronOptions: CronOptions;
|
|
15
|
+
dynamoTableNames?: string[];
|
|
16
|
+
lambdaLayerArn?: string[];
|
|
17
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Tags } from "aws-cdk-lib";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
import { AppConfig } from "../../config/AppConfig";
|
|
4
|
-
|
|
5
|
-
export abstract class BaseResource<T> {
|
|
6
|
-
|
|
7
|
-
protected createdResources: T[];
|
|
8
|
-
|
|
9
|
-
constructor(protected scope: Construct, protected config: AppConfig) { }
|
|
10
|
-
|
|
11
|
-
protected abstract createResource(scope: Construct): T[] | null;
|
|
12
|
-
|
|
13
|
-
protected abstract createOutput<T>(scope: Construct, createdAssets: T[]): void;
|
|
14
|
-
|
|
1
|
+
import { Tags } from "aws-cdk-lib";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { AppConfig } from "../../config/AppConfig";
|
|
4
|
+
|
|
5
|
+
export abstract class BaseResource<T> {
|
|
6
|
+
|
|
7
|
+
protected createdResources: T[];
|
|
8
|
+
|
|
9
|
+
constructor(protected scope: Construct, protected config: AppConfig) { }
|
|
10
|
+
|
|
11
|
+
protected abstract createResource(scope: Construct): T[] | null;
|
|
12
|
+
|
|
13
|
+
protected abstract createOutput<T>(scope: Construct, createdAssets: T[]): void;
|
|
14
|
+
|
|
15
15
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { CfnOutput } from "aws-cdk-lib";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
|
|
4
|
-
export abstract class TsgBaseResource<T, R> {
|
|
5
|
-
|
|
6
|
-
protected createdResource: T | null;
|
|
7
|
-
|
|
8
|
-
constructor(protected scope: Construct, protected config: R) {
|
|
9
|
-
|
|
10
|
-
this.createdResource = this.createResource(scope);
|
|
11
|
-
|
|
12
|
-
if (this.createdResource) {
|
|
13
|
-
this.createOutput(scope);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
protected abstract createResource(scope: Construct): T | null;
|
|
19
|
-
|
|
20
|
-
protected abstract createOutput<T>(scope: Construct): void;
|
|
21
|
-
|
|
1
|
+
import { CfnOutput } from "aws-cdk-lib";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
|
|
4
|
+
export abstract class TsgBaseResource<T, R> {
|
|
5
|
+
|
|
6
|
+
protected createdResource: T | null;
|
|
7
|
+
|
|
8
|
+
constructor(protected scope: Construct, protected config: R) {
|
|
9
|
+
|
|
10
|
+
this.createdResource = this.createResource(scope);
|
|
11
|
+
|
|
12
|
+
if (this.createdResource) {
|
|
13
|
+
this.createOutput(scope);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
protected abstract createResource(scope: Construct): T | null;
|
|
19
|
+
|
|
20
|
+
protected abstract createOutput<T>(scope: Construct): void;
|
|
21
|
+
|
|
22
22
|
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { RemovalPolicy } from "aws-cdk-lib";
|
|
2
|
-
import { Certificate, CertificateValidation, DnsValidatedCertificate, ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
3
|
-
import { HostedZone, IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
4
|
-
import { Construct } from "constructs";
|
|
5
|
-
import { MicroserviceProps } from "../../interfaces/MicroserviceProps";
|
|
6
|
-
import { environmentSuffixForDomain } from "../../helpers/util-helper";
|
|
7
|
-
import { Environment } from "../../config/Environments";
|
|
8
|
-
import { env } from "process";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export class CreateCertificate {
|
|
12
|
-
|
|
13
|
-
public certificate: ICertificate;
|
|
14
|
-
|
|
15
|
-
constructor(scope: Construct, props: MicroserviceProps, hostedZone: IHostedZone, env: string) {
|
|
16
|
-
|
|
17
|
-
// this.certificate = this.generateCertificate(scope, props, hostedZone);
|
|
18
|
-
|
|
19
|
-
this.certificate = this.generateApiCertificate(scope, props, env);
|
|
20
|
-
|
|
21
|
-
this.certificate.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
generateCertificate(scope: Construct, props: MicroserviceProps, hostedZone: IHostedZone, env: string) {
|
|
26
|
-
|
|
27
|
-
const devHostedZone = HostedZone.fromHostedZoneId(scope, `api.c1.dev.convergeone.io-hosted-zone`,
|
|
28
|
-
'Z0508834Q8E4TWFVG990');
|
|
29
|
-
|
|
30
|
-
const cert = new Certificate(scope, `api-c1-dev-api-certificate`, {
|
|
31
|
-
domainName: `c1.api.dev.convergeone.io`,
|
|
32
|
-
validation: CertificateValidation.fromDnsMultiZone({
|
|
33
|
-
[`dev.convergeone.io`]: devHostedZone
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
return cert;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
generateApiCertificate(scope: Construct, props: MicroserviceProps, env: string) {
|
|
40
|
-
|
|
41
|
-
const hostedZone = HostedZone.fromHostedZoneId(scope, `${props.API.DomainPrefix}-${env}-${props.DNS?.ZoneName}-hosted-zone`,
|
|
42
|
-
props.DNS?.ZoneId!);
|
|
43
|
-
|
|
44
|
-
const domainName = `${props.API.DomainPrefix}.${env}.${props.DNS?.ZoneName}`;
|
|
45
|
-
|
|
46
|
-
const cert = new Certificate(scope, `${props.API.DomainPrefix}-${env}-${props.DNS?.ZoneName}-certificate`, {
|
|
47
|
-
certificateName: `${domainName}-certificate`,
|
|
48
|
-
domainName: domainName,
|
|
49
|
-
// validation: CertificateValidation.fromDnsMultiZone({
|
|
50
|
-
// [`${props.API.DomainPrefix}.${env}.${props.DNS?.ZoneName}`]: hostedZone
|
|
51
|
-
|
|
52
|
-
// })
|
|
53
|
-
validation: CertificateValidation.fromDns(hostedZone)
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return cert;
|
|
57
|
-
}
|
|
1
|
+
import { RemovalPolicy } from "aws-cdk-lib";
|
|
2
|
+
import { Certificate, CertificateValidation, DnsValidatedCertificate, ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
3
|
+
import { HostedZone, IHostedZone } from "aws-cdk-lib/aws-route53";
|
|
4
|
+
import { Construct } from "constructs";
|
|
5
|
+
import { MicroserviceProps } from "../../interfaces/MicroserviceProps";
|
|
6
|
+
import { environmentSuffixForDomain } from "../../helpers/util-helper";
|
|
7
|
+
import { Environment } from "../../config/Environments";
|
|
8
|
+
import { env } from "process";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export class CreateCertificate {
|
|
12
|
+
|
|
13
|
+
public certificate: ICertificate;
|
|
14
|
+
|
|
15
|
+
constructor(scope: Construct, props: MicroserviceProps, hostedZone: IHostedZone, env: string) {
|
|
16
|
+
|
|
17
|
+
// this.certificate = this.generateCertificate(scope, props, hostedZone);
|
|
18
|
+
|
|
19
|
+
this.certificate = this.generateApiCertificate(scope, props, env);
|
|
20
|
+
|
|
21
|
+
this.certificate.applyRemovalPolicy(RemovalPolicy.DESTROY);
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
generateCertificate(scope: Construct, props: MicroserviceProps, hostedZone: IHostedZone, env: string) {
|
|
26
|
+
|
|
27
|
+
const devHostedZone = HostedZone.fromHostedZoneId(scope, `api.c1.dev.convergeone.io-hosted-zone`,
|
|
28
|
+
'Z0508834Q8E4TWFVG990');
|
|
29
|
+
|
|
30
|
+
const cert = new Certificate(scope, `api-c1-dev-api-certificate`, {
|
|
31
|
+
domainName: `c1.api.dev.convergeone.io`,
|
|
32
|
+
validation: CertificateValidation.fromDnsMultiZone({
|
|
33
|
+
[`dev.convergeone.io`]: devHostedZone
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
return cert;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
generateApiCertificate(scope: Construct, props: MicroserviceProps, env: string) {
|
|
40
|
+
|
|
41
|
+
const hostedZone = HostedZone.fromHostedZoneId(scope, `${props.API.DomainPrefix}-${env}-${props.DNS?.ZoneName}-hosted-zone`,
|
|
42
|
+
props.DNS?.ZoneId!);
|
|
43
|
+
|
|
44
|
+
const domainName = `${props.API.DomainPrefix}.${env}.${props.DNS?.ZoneName}`;
|
|
45
|
+
|
|
46
|
+
const cert = new Certificate(scope, `${props.API.DomainPrefix}-${env}-${props.DNS?.ZoneName}-certificate`, {
|
|
47
|
+
certificateName: `${domainName}-certificate`,
|
|
48
|
+
domainName: domainName,
|
|
49
|
+
// validation: CertificateValidation.fromDnsMultiZone({
|
|
50
|
+
// [`${props.API.DomainPrefix}.${env}.${props.DNS?.ZoneName}`]: hostedZone
|
|
51
|
+
|
|
52
|
+
// })
|
|
53
|
+
validation: CertificateValidation.fromDns(hostedZone)
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return cert;
|
|
57
|
+
}
|
|
58
58
|
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { IUserPool, UserPool, UserPoolClient, UserPoolClientProps, UserPoolIdentityProviderAmazon, UserPoolIdentityProviderAmazonProps, UserPoolIdentityProviderSaml, UserPoolIdentityProviderSamlMetadataType } from "aws-cdk-lib/aws-cognito";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
import { AppConfig } from "../../config/AppConfig";
|
|
4
|
-
import { createUserPoolProps } from "./createCognitoProps";
|
|
5
|
-
import { Duration } from "aws-cdk-lib";
|
|
6
|
-
import { ClientAppType } from "../../config/Environments";
|
|
7
|
-
|
|
8
|
-
export const createCognito = (scope: Construct, appConfig: AppConfig) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const userPool = createUserPool(scope, appConfig);
|
|
12
|
-
const clientPool = createUserPoolClient(scope, userPool, "mobile", appConfig);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
userPool,
|
|
16
|
-
clientPool
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const createUserPool = (scope: Construct, appConfig: AppConfig, userPoolName?: string) => {
|
|
21
|
-
|
|
22
|
-
return new UserPool(scope, `${appConfig.AppName}-user-pool`,
|
|
23
|
-
createUserPoolProps(`${appConfig.AppName}-user-pool`));
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const createUserPoolClient = (scope: Construct, userPool: IUserPool, appType: ClientAppType,
|
|
28
|
-
appConfig: AppConfig) => {
|
|
29
|
-
|
|
30
|
-
const client = new UserPoolClient(scope, `${appConfig.AppName}-user-pool-client`,
|
|
31
|
-
createUserPoolClientProps(userPool, appConfig, appType));
|
|
32
|
-
|
|
33
|
-
return client;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const createUserPoolClientProps = (userpool: IUserPool, config: AppConfig, appType: ClientAppType): UserPoolClientProps => {
|
|
37
|
-
const props: UserPoolClientProps = {
|
|
38
|
-
userPool: userpool,
|
|
39
|
-
accessTokenValidity: Duration.hours(3),
|
|
40
|
-
refreshTokenValidity: Duration.days(3),
|
|
41
|
-
userPoolClientName: `${config.AppName}-${appType}`,
|
|
42
|
-
authFlows: {
|
|
43
|
-
userPassword: true,
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return props;
|
|
47
|
-
};
|
|
1
|
+
import { IUserPool, UserPool, UserPoolClient, UserPoolClientProps, UserPoolIdentityProviderAmazon, UserPoolIdentityProviderAmazonProps, UserPoolIdentityProviderSaml, UserPoolIdentityProviderSamlMetadataType } from "aws-cdk-lib/aws-cognito";
|
|
2
|
+
import { Construct } from "constructs";
|
|
3
|
+
import { AppConfig } from "../../config/AppConfig";
|
|
4
|
+
import { createUserPoolProps } from "./createCognitoProps";
|
|
5
|
+
import { Duration } from "aws-cdk-lib";
|
|
6
|
+
import { ClientAppType } from "../../config/Environments";
|
|
7
|
+
|
|
8
|
+
export const createCognito = (scope: Construct, appConfig: AppConfig) => {
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const userPool = createUserPool(scope, appConfig);
|
|
12
|
+
const clientPool = createUserPoolClient(scope, userPool, "mobile", appConfig);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
userPool,
|
|
16
|
+
clientPool
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const createUserPool = (scope: Construct, appConfig: AppConfig, userPoolName?: string) => {
|
|
21
|
+
|
|
22
|
+
return new UserPool(scope, `${appConfig.AppName}-user-pool`,
|
|
23
|
+
createUserPoolProps(`${appConfig.AppName}-user-pool`));
|
|
24
|
+
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const createUserPoolClient = (scope: Construct, userPool: IUserPool, appType: ClientAppType,
|
|
28
|
+
appConfig: AppConfig) => {
|
|
29
|
+
|
|
30
|
+
const client = new UserPoolClient(scope, `${appConfig.AppName}-user-pool-client`,
|
|
31
|
+
createUserPoolClientProps(userPool, appConfig, appType));
|
|
32
|
+
|
|
33
|
+
return client;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const createUserPoolClientProps = (userpool: IUserPool, config: AppConfig, appType: ClientAppType): UserPoolClientProps => {
|
|
37
|
+
const props: UserPoolClientProps = {
|
|
38
|
+
userPool: userpool,
|
|
39
|
+
accessTokenValidity: Duration.hours(3),
|
|
40
|
+
refreshTokenValidity: Duration.days(3),
|
|
41
|
+
userPoolClientName: `${config.AppName}-${appType}`,
|
|
42
|
+
authFlows: {
|
|
43
|
+
userPassword: true,
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return props;
|
|
47
|
+
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Duration, RemovalPolicy } from "aws-cdk-lib";
|
|
2
|
-
import { AccountRecovery, DateTimeAttribute, NumberAttribute, StringAttribute, UserPoolProps,
|
|
3
|
-
VerificationEmailStyle } from "aws-cdk-lib/aws-cognito";
|
|
4
|
-
|
|
5
|
-
export const createUserPoolProps = (securityUserPool: string) => {
|
|
6
|
-
|
|
7
|
-
const cognitoProps: UserPoolProps = {
|
|
8
|
-
userPoolName: securityUserPool.toLowerCase(),
|
|
9
|
-
selfSignUpEnabled: true,
|
|
10
|
-
userVerification: {
|
|
11
|
-
emailSubject: 'Verify your email for Bishop CDK Constructs!',
|
|
12
|
-
emailBody: 'Thanks for creating an account with Bishop CDK Constructs! Your verification code is {####}',
|
|
13
|
-
emailStyle: VerificationEmailStyle.CODE,
|
|
14
|
-
smsMessage: 'Thanks for signing up {username} with Bishop CDK Constructs! Your verification code is {####}',
|
|
15
|
-
},
|
|
16
|
-
userInvitation: {
|
|
17
|
-
emailSubject: 'Invite to join Bishop CDK Constructs!',
|
|
18
|
-
emailBody: 'Hello {username}, you have been invited to join Bishop CDK Constructs! Your temporary password is {####}',
|
|
19
|
-
smsMessage: 'Your temporary password for {username} with Bishop CDK Constructs is {####}'
|
|
20
|
-
},
|
|
21
|
-
signInAliases: {
|
|
22
|
-
username: true,
|
|
23
|
-
email: true,
|
|
24
|
-
phone: true
|
|
25
|
-
},
|
|
26
|
-
customAttributes: {
|
|
27
|
-
'firstName': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
28
|
-
'lastName': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
29
|
-
'phoneNumber': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
30
|
-
'acccountType': new NumberAttribute({ mutable: true }),
|
|
31
|
-
'joinedOn': new DateTimeAttribute(),
|
|
32
|
-
},
|
|
33
|
-
passwordPolicy: {
|
|
34
|
-
minLength: 8,
|
|
35
|
-
requireLowercase: true,
|
|
36
|
-
requireUppercase: true,
|
|
37
|
-
requireDigits: true,
|
|
38
|
-
requireSymbols: true,
|
|
39
|
-
tempPasswordValidity: Duration.days(1),
|
|
40
|
-
},
|
|
41
|
-
accountRecovery: AccountRecovery.PHONE_AND_EMAIL,
|
|
42
|
-
removalPolicy: RemovalPolicy.DESTROY,
|
|
43
|
-
}
|
|
44
|
-
return cognitoProps;
|
|
45
|
-
};
|
|
46
|
-
|
|
1
|
+
import { Duration, RemovalPolicy } from "aws-cdk-lib";
|
|
2
|
+
import { AccountRecovery, DateTimeAttribute, NumberAttribute, StringAttribute, UserPoolProps,
|
|
3
|
+
VerificationEmailStyle } from "aws-cdk-lib/aws-cognito";
|
|
4
|
+
|
|
5
|
+
export const createUserPoolProps = (securityUserPool: string) => {
|
|
6
|
+
|
|
7
|
+
const cognitoProps: UserPoolProps = {
|
|
8
|
+
userPoolName: securityUserPool.toLowerCase(),
|
|
9
|
+
selfSignUpEnabled: true,
|
|
10
|
+
userVerification: {
|
|
11
|
+
emailSubject: 'Verify your email for Bishop CDK Constructs!',
|
|
12
|
+
emailBody: 'Thanks for creating an account with Bishop CDK Constructs! Your verification code is {####}',
|
|
13
|
+
emailStyle: VerificationEmailStyle.CODE,
|
|
14
|
+
smsMessage: 'Thanks for signing up {username} with Bishop CDK Constructs! Your verification code is {####}',
|
|
15
|
+
},
|
|
16
|
+
userInvitation: {
|
|
17
|
+
emailSubject: 'Invite to join Bishop CDK Constructs!',
|
|
18
|
+
emailBody: 'Hello {username}, you have been invited to join Bishop CDK Constructs! Your temporary password is {####}',
|
|
19
|
+
smsMessage: 'Your temporary password for {username} with Bishop CDK Constructs is {####}'
|
|
20
|
+
},
|
|
21
|
+
signInAliases: {
|
|
22
|
+
username: true,
|
|
23
|
+
email: true,
|
|
24
|
+
phone: true
|
|
25
|
+
},
|
|
26
|
+
customAttributes: {
|
|
27
|
+
'firstName': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
28
|
+
'lastName': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
29
|
+
'phoneNumber': new StringAttribute({ minLen: 3, maxLen: 30, mutable: true }),
|
|
30
|
+
'acccountType': new NumberAttribute({ mutable: true }),
|
|
31
|
+
'joinedOn': new DateTimeAttribute(),
|
|
32
|
+
},
|
|
33
|
+
passwordPolicy: {
|
|
34
|
+
minLength: 8,
|
|
35
|
+
requireLowercase: true,
|
|
36
|
+
requireUppercase: true,
|
|
37
|
+
requireDigits: true,
|
|
38
|
+
requireSymbols: true,
|
|
39
|
+
tempPasswordValidity: Duration.days(1),
|
|
40
|
+
},
|
|
41
|
+
accountRecovery: AccountRecovery.PHONE_AND_EMAIL,
|
|
42
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
43
|
+
}
|
|
44
|
+
return cognitoProps;
|
|
45
|
+
};
|
|
46
|
+
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { ITableV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
-
import { LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
3
|
-
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
4
|
-
import { Construct } from "constructs";
|
|
5
|
-
import { AppConfig } from "../../config/AppConfig";
|
|
6
|
-
import { LambdaHelper } from "../lambda/lambdaHelper";
|
|
7
|
-
import { Provider, ProviderProps } from "aws-cdk-lib/custom-resources";
|
|
8
|
-
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
9
|
-
import { CustomResource, CustomResourceProps } from "aws-cdk-lib";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export const createSeedDatabaseCustomResource = (scope: Construct, config: AppConfig,
|
|
13
|
-
database: ITableV2, layers?: LayerVersion[]) => {
|
|
14
|
-
|
|
15
|
-
const seedLambda = config.RESOURCES.DYNAMO?.SEED_LAMBDA;
|
|
16
|
-
|
|
17
|
-
const databaseSeedLambda = LambdaHelper.createLambdaFunctions(scope,
|
|
18
|
-
config,
|
|
19
|
-
seedLambda!,
|
|
20
|
-
undefined,
|
|
21
|
-
layers!) as NodejsFunction;
|
|
22
|
-
|
|
23
|
-
database.grantReadWriteData(databaseSeedLambda);
|
|
24
|
-
|
|
25
|
-
const providerProps: ProviderProps = {
|
|
26
|
-
onEventHandler: databaseSeedLambda,
|
|
27
|
-
logRetention: RetentionDays.ONE_WEEK,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const provider = new Provider(scope, `${config.AppPrefix}-database-seed-provider`, providerProps);
|
|
31
|
-
|
|
32
|
-
const crProps: CustomResourceProps = {
|
|
33
|
-
serviceToken: provider.serviceToken,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
new CustomResource(scope, `${config.AppPrefix}-database-seed`, crProps);
|
|
1
|
+
import { ITableV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { LayerVersion, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
|
|
4
|
+
import { Construct } from "constructs";
|
|
5
|
+
import { AppConfig } from "../../config/AppConfig";
|
|
6
|
+
import { LambdaHelper } from "../lambda/lambdaHelper";
|
|
7
|
+
import { Provider, ProviderProps } from "aws-cdk-lib/custom-resources";
|
|
8
|
+
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
9
|
+
import { CustomResource, CustomResourceProps } from "aws-cdk-lib";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const createSeedDatabaseCustomResource = (scope: Construct, config: AppConfig,
|
|
13
|
+
database: ITableV2, layers?: LayerVersion[]) => {
|
|
14
|
+
|
|
15
|
+
const seedLambda = config.RESOURCES.DYNAMO?.SEED_LAMBDA;
|
|
16
|
+
|
|
17
|
+
const databaseSeedLambda = LambdaHelper.createLambdaFunctions(scope,
|
|
18
|
+
config,
|
|
19
|
+
seedLambda!,
|
|
20
|
+
undefined,
|
|
21
|
+
layers!) as NodejsFunction;
|
|
22
|
+
|
|
23
|
+
database.grantReadWriteData(databaseSeedLambda);
|
|
24
|
+
|
|
25
|
+
const providerProps: ProviderProps = {
|
|
26
|
+
onEventHandler: databaseSeedLambda,
|
|
27
|
+
logRetention: RetentionDays.ONE_WEEK,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const provider = new Provider(scope, `${config.AppPrefix}-database-seed-provider`, providerProps);
|
|
31
|
+
|
|
32
|
+
const crProps: CustomResourceProps = {
|
|
33
|
+
serviceToken: provider.serviceToken,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
new CustomResource(scope, `${config.AppPrefix}-database-seed`, crProps);
|
|
37
37
|
};
|