diff --git a/packages/cli/templates/infra/.cdkgraphrc.js b/packages/cli/templates/infra/.cdkgraphrc.js new file mode 100644 index 0000000..b3dc24f --- /dev/null +++ b/packages/cli/templates/infra/.cdkgraphrc.js @@ -0,0 +1,3 @@ +module.exports = { + outdir: 'graph', +} diff --git a/packages/cli/templates/infra/bin/infra.ts b/packages/cli/templates/infra/bin/infra.ts index 8f7e582..e6f7d60 100644 --- a/packages/cli/templates/infra/bin/infra.ts +++ b/packages/cli/templates/infra/bin/infra.ts @@ -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() +})() diff --git a/packages/cli/templates/infra/gitignore b/packages/cli/templates/infra/gitignore index 4bdca62..2d321b6 100644 --- a/packages/cli/templates/infra/gitignore +++ b/packages/cli/templates/infra/gitignore @@ -1,8 +1,12 @@ *.js !jest.config.js +!.cdkgraphrc.js *.d.ts node_modules # CDK asset staging directory .cdk.staging -cdk.out \ No newline at end of file +cdk.out + +# +graph \ No newline at end of file diff --git a/packages/cli/templates/infra/package.json b/packages/cli/templates/infra/package.json index 3c89457..d046376 100644 --- a/packages/cli/templates/infra/package.json +++ b/packages/cli/templates/infra/package.json @@ -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",