-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from mbc-net/feat/infra-diagram
[CLI]: Generate infrastructure diagram from CDK
- Loading branch information
Showing
4 changed files
with
46 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
outdir: 'graph', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,42 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register' | ||
import * as cdk from 'aws-cdk-lib' | ||
// import { InfraStack } from '../libs/infra-stack' | ||
|
||
// import * as dotenv from 'dotenv' | ||
// import { Env } from '../config/type' | ||
// import { getConfig } from '../config' | ||
import { PipelineStack } from '../libs/pipeline-stack' | ||
import 'source-map-support/register' | ||
import { Env, PIPELINE_NAME } from '../config' | ||
// dotenv.config() | ||
|
||
const app = new cdk.App() | ||
|
||
// const env: Env = app.node.tryGetContext('env') || 'dev' | ||
// console.log('stack environment:', env) | ||
// const config = getConfig(env) | ||
|
||
const cdkEnv: cdk.Environment = { | ||
account: '', | ||
region: '', | ||
} | ||
|
||
// new InfraStack(app, 'InfraStack', { | ||
// config, | ||
// /* If you don't specify 'env', this stack will be environment-agnostic. | ||
// * Account/Region-dependent features and context lookups will not work, | ||
// * but a single synthesized template can be deployed anywhere. */ | ||
// /* Uncomment the next line to specialize this stack for the AWS Account | ||
// * and Region that are implied by the current CLI configuration. */ | ||
// // env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION }, | ||
// /* Uncomment the next line if you know exactly what Account and Region you | ||
// * want to deploy the stack to. */ | ||
// env: cdkEnv, | ||
// /* For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html */ | ||
// }) | ||
|
||
const envs: Env[] = ['dev'] | ||
|
||
for (const env of envs) { | ||
new PipelineStack(app, env + '-' + PIPELINE_NAME + '-pipeline-stack', { | ||
env: cdkEnv, | ||
envName: env, | ||
import { PipelineStack } from '../libs/pipeline-stack' | ||
import { CdkGraph, FilterPreset } from '@aws/pdk/cdk-graph' | ||
import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram' | ||
;(async () => { | ||
const app = new cdk.App() | ||
|
||
const cdkEnv: cdk.Environment = { | ||
account: '', | ||
region: '', | ||
} | ||
|
||
const envs: Env[] = ['dev'] | ||
|
||
for (const env of envs) { | ||
new PipelineStack(app, env + '-' + PIPELINE_NAME + '-pipeline-stack', { | ||
env: cdkEnv, | ||
envName: env, | ||
}) | ||
} | ||
|
||
const graph = new CdkGraph(app, { | ||
plugins: [ | ||
new CdkGraphDiagramPlugin({ | ||
diagrams: [ | ||
{ | ||
name: 'diagram', | ||
title: 'Infrastructure diagram', | ||
theme: 'light', | ||
}, | ||
], | ||
}), | ||
], | ||
}) | ||
} | ||
|
||
app.synth() | ||
app.synth() | ||
|
||
await graph.report() | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
*.js | ||
!jest.config.js | ||
!.cdkgraphrc.js | ||
*.d.ts | ||
node_modules | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out | ||
cdk.out | ||
|
||
# | ||
graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters