Help us understand the problem. What is going on with this article?

AWS CDK CLIをデバッグする

GitHubからCloneしたAWS CDK CLIをローカルでデバッグする手順をまとめました。
もっと効率いい方法があったら教えて下さい!

Overview

  1. tsc, tslint をインストール
  2. pkglint, cdk-build-tools, awslint, cdkをビルド
  3. jsファイルにdebuggerを仕込む
  4. ビルドしたCDK CLIで任意のCDKアプリケーションを実行

toolsとCDK CLI本体の依存関係はこんな感じです。

image.png

1. tsc, tslint をインストール

npm install -g tsc
npm install -g tslint

2. pkglint, cdk-build-tools, awslint, cdkをビルド

※パスは適宜読み替えてください。

cd aws-cdk/tools/pkglint
npm run build
cd aws-cdk/tools/cdk-build-tools
PATH=$PATH:~/.ghq/github.com/aws/aws-cdk/tools/pkglint/bin
npm run build
cd ~/.ghq/github.com/aws/aws-cdk/tools/awslint
npm run build
cd aws-cdk/packages/aws-cdk
PATH=$PATH:~/.ghq/github.com/aws/aws-cdk/tools/cdk-build-tools/bin
PATH=$PATH:~/.ghq/github.com/aws/aws-cdk/tools/awslint/bin
npm run build

3. jsファイルにdebuggerを仕込む

nodeアプリケーションのデバッグ方法は以下を参照してください。
https://nodejs.org/api/debugger.html

vi aws-cdk/packages/aws-cdk/bin/cdk.js

結果として、こんな感じになります。

cdk.js
    async function cliSynthesize(stackNames, exclusively) {
        // 省略......
        debugger; // debuggerを仕込む。
        appStacks.processMetadata(stacks);

4. ビルドしたCDK CLIで任意のCDKアプリケーションを実行

cd ${APPLICATION_DIR}/cdk
node inspect ~/.ghq/github.com/aws/aws-cdk/packages/aws-cdk/bin/cdk synth -v

以上です。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした