forked from aws-samples/aws-cdk-cicd-boot-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppStage.ts
77 lines (65 loc) · 2.68 KB
/
AppStage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
import * as cdk from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';
import { Construct } from 'constructs';
import { SecurityControls } from '../../../bin/aspects';
import { LambdaStack } from '../../stacks/app/LambdaStack';
import { MonitoringStack } from '../../stacks/app/MonitoringStack';
import { S3BucketStack } from '../../stacks/app/S3BucketStack';
import { ComplianceLogBucketStack } from '../../stacks/core/ComplianceLogBucketStack';
import { EncryptionStack } from '../../stacks/core/EncryptionStack';
import { LogRetentionRoleStack } from '../../stacks/core/LogRetentionRoleStack';
interface Props extends cdk.StageProps {
applicationName: string;
applicationQualifier: string;
logRetentionInDays: string;
resAccount: string;
stage: string;
complianceLogBucketName: string;
}
export class AppStage extends cdk.Stage {
constructor(scope: Construct, id: string, props: Props) {
super(scope, id, props);
const encryptionStack = new EncryptionStack(this, `${props.applicationName}EncryptionStack`, {
applicationName: props.applicationName,
stageName: props.stage,
});
new ComplianceLogBucketStack(this, `${props.applicationName}ComplianceLogBucketStack`, {
complianceLogBucketName: props.complianceLogBucketName,
});
new LogRetentionRoleStack(this, `${props.applicationName}LogRetentionRoleStack`, {
resAccount: props.resAccount,
stageName: props.stage,
applicationName: props.applicationName,
encryptionKey: encryptionStack.kmsKey,
});
new LambdaStack(this, `${props.applicationName}LambdaStack`, {
stageName: props.stage,
applicationName: props.applicationName,
});
new S3BucketStack(this, `${props.applicationName}S3Stack`, {
bucketName: 'test-bucket',
stageName: props.stage,
applicationQualifier: props.applicationQualifier,
encryptionKey: encryptionStack.kmsKey,
});
new MonitoringStack(this, `${props.applicationName}MonitoringStack`, {
applicationName: props.applicationName,
applicationQualifier: props.applicationQualifier,
stageName: props.stage,
});
cdk.Aspects.of(this).add(
new SecurityControls(
encryptionStack.kmsKey,
props.stage,
props.logRetentionInDays,
props.complianceLogBucketName,
),
);
cdk.Aspects.of(this).add(new AwsSolutionsChecks({ verbose: false }));
}
static getLogRetentionRoleArn(account: string, region: string, stageName: string, applicationName: string) {
return LogRetentionRoleStack.getRoleArn(account, region, stageName, applicationName);
}
}