Skip to content

Commit

Permalink
infra diagram from cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Quan Nguyen Ba committed Nov 14, 2024
1 parent 9dc8eb5 commit 0c8a868
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 43 deletions.
3 changes: 3 additions & 0 deletions packages/cli/templates/infra/.cdkgraphrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
outdir: 'graph',
}
79 changes: 37 additions & 42 deletions packages/cli/templates/infra/bin/infra.ts
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()
})()
6 changes: 5 additions & 1 deletion packages/cli/templates/infra/gitignore
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
1 change: 1 addition & 0 deletions packages/cli/templates/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@aws-cdk/aws-apigatewayv2-alpha": "^2.114.1-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "^2.114.1-alpha.0",
"@aws-cdk/aws-apigatewayv2-integrations-alpha": "^2.114.1-alpha.0",
"@aws/pdk": "^0.25.7",
"aws-cdk-lib": "^2.147.0",
"cdk-ecr-deployment": "^3.0.71",
"constructs": "^10.3.0",
Expand Down

0 comments on commit 0c8a868

Please sign in to comment.