-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
57 lines (47 loc) · 1.42 KB
/
main.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
import 'dotenv/config';
import { CdkGraph, FilterPreset } from '@aws/pdk/cdk-graph';
import {
CdkGraphDiagramPlugin,
DiagramFormat
} from '@aws/pdk/cdk-graph-plugin-diagram';
import { App } from 'aws-cdk-lib';
import { AppServiceStack, EcrStack, NetworkStack } from './stacks';
import { config } from './utils';
// Wrap cdk app with async IIFE function to enable async cdk-graph report
// eslint-disable-next-line no-void, func-names
void (async function () {
const app = new App();
const env = {
region: config.aws.region,
account: config.aws.accountId
};
const networkStack = new NetworkStack(app, 'NetworkStack', { env });
const ecrStack = new EcrStack(app, 'EcrStack', { env });
new AppServiceStack(app, 'AppServiceStack', {
env,
vpc: networkStack.vpc,
appSecurityGroup: networkStack.appSecurityGroup,
appRepository: ecrStack.appRepository,
targetGroupArn: networkStack.targetGroup.targetGroupArn
});
// Generate a diagram for the whole architecture
const group = new CdkGraph(app, {
plugins: [
new CdkGraphDiagramPlugin({
diagrams: [
{
name: 'nextjs-cdk-example-diagram',
title: 'NextJS CDK Diagram',
format: DiagramFormat.PNG,
theme: 'light',
filterPlan: {
preset: FilterPreset.COMPACT
}
}
]
})
]
});
app.synth();
await group.report();
})();