Skip to content

Instantly share code, notes, and snippets.

@so0k
Created July 28, 2026 12:03
Show Gist options
  • Select an option

  • Save so0k/95ab03a2ab854b5163fd6d703f3573ab to your computer and use it in GitHub Desktop.

Select an option

Save so0k/95ab03a2ab854b5163fd6d703f3573ab to your computer and use it in GitHub Desktop.

CDK Workshop - Notes

# mkdir test; cd test <<< Can't run cdktn init a non-empty directorynpx cdktn-cli@next init --template=typescript --local
Note: By supplying '--local' option you have chosen local storage mode for storing the state of your stack.
This means that your Terraform state file will be stored locally on disk in a file 'terraform.<STACK NAME>.tfstate' in the root of your project.
✔ Project Name cdk-workshop
✔ Project Description TerraConstructs AWS Workshop
✔ Do you want to start from an existing Terraform project? No
✔ Do you want to send crash reports to the CDKTN team? Refer to https://cdktn.io/docs/create-and-deploy/configuration-file#enable-crash-reporting-for-the-cli for more information Yes
Note: You can always add providers using 'cdktn provider add' later on
✔ What providers do you want to use?

I did not add any providers, I set project name to "cdk-workshop" on the prompt! I confirm only "constructs" and "cdktn@next" are added as dependencies (no providers added or generated) I expected package name to be "cdk-workshop" (but it is "test") I expected main.ts -> new MyStack(app, "cdk-workshop") (but it is "test")

added 2 packages, and audited 6 packages in 757ms

found 0 vulnerabilities
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@7.2.3: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
npm warn deprecated glob@10.5.0: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me

added 321 packages, and audited 327 packages in 13s

46 packages are looking for funding
  run `npm fund` for details

20 high severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
npm warn allow-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn allow-scripts   unrs-resolver@1.12.2 (postinstall: node postinstall.js)
npm warn allow-scripts
npm warn allow-scripts Run `npm approve-scripts --allow-scripts-pending` to review, or `npm approve-scripts <pkg>` to allow.

I expected no high severity vulnerabilities I don't understand why approve-scripts is needed I expected no warnings about deprecated packages "inflight" and "glob".

Running cdktn deploy

Tried CTRL+C during synth - error (synth interrupted) no stack trace Tried CTRL+C during plan - stacktrace

cdk-workshop on  main [!] via  v24.18.0 via 💠 default on ☁️  tcons-vincent (us-east-1) took 4s 
❯ npx cdktn-cli@next deploy

cdk-workshop  Initializing the backend...
cdk-workshop  
cdk-workshop  Initializing provider plugins...
cdk-workshop  - Reusing previous version of hashicorp/aws from the dependency lock file
cdk-workshop  - Using previously-installed hashicorp/aws v6.56.0
cdk-workshop  ╷
│ Error: Provider installation was canceled by an interrupt signal.
│ 
│ 
╵
terraform init failed with exit code 1
Error: terraform init failed with exit code 1
    at /Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:332:9816
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async FX.init (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:332:9873)
    at async YX.initalizeTerraform (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:336:211)
    at async aJ.initializeStacksToRunInSerial (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:39723)
    at async aJ.execute (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:35724)
    at async aJ.deploy (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:37051)
    at async /Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:430:297
    at async $a (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:416:6483)
    at async jVe (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:430:139)
Collecting Debug Information...
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: terraform init failed with exit code 1
    at /Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:332:9816
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async FX.init (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:332:9873)
    at async YX.initalizeTerraform (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:336:211)
    at async aJ.initializeStacksToRunInSerial (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:39723)
    at async aJ.execute (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:35724)
    at async aJ.deploy (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:371:37051)
    at async /Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:430:297
    at async $a (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:416:6483)
    at async jVe (/Users/vincentsmet/tcons/cdk-workshop/node_modules/cdktn-cli/bundle/bin/cmds/handlers.js:430:139)
(node:96177) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 11)
(Use `node --trace-warnings ...` to show where the warning was created)
Debug Information:
language: typescript
cdktn-cli: 0.24.0-pre.91
node: v24.18.0
cdktn: 0.24.0-pre.91
cdktf: null
constructs: 10.7.1
jsii: null
terraform: 1.15.8
arch: arm64
os: darwin 25.5.0

Running cdktn diff

After removing the resources but not their imports

npx cdktn-cli@next diff         

⠏ Synthesizing
[2026-07-28T17:55:12.977] [ERROR] default - /Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^

[2026-07-28T17:55:12.978] [ERROR] default - TSError: ⨯ Unable to compile TypeScript:
main.ts(3,1): error TS6133: 'Duration' is declared but its value is never read.
main.ts(5,1): error TS6192: All imports in import declaration are unused.

    at createTSError (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1617:30)
    at node:internal/modules/cjs/loader:2002:10
    at Object.require.extensions.<computed> [as .ts] (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1594:32)
    at Module._load (node:internal/modules/cjs/loader:1396:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:255:19) {
  diagnosticCodes: [ 6133, 6192 ]
}
⠋ Synthesizing
ERROR: cdktn encountered an error while synthesizing

Synth command: npx ts-node main.ts
Error:         npx ts-node main.ts  exited with code 1

Command output on stderr:

    /Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:859
        return new TSError(diagnosticText, diagnosticCodes, diagnostics);
               ^
    TSError: ⨯ Unable to compile TypeScript:
    main.ts(3,1): error TS6133: 'Duration' is declared but its value is never read.
    main.ts(5,1): error TS6192: All imports in import declaration are unused.

        at createTSError (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:859:12)
        at reportTSError (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:863:19)
        at getOutput (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1077:36)
        at Object.compile (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1433:41)
        at Module.m._compile (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1617:30)
        at node:internal/modules/cjs/loader:2002:10
        at Object.require.extensions.<computed> [as .ts] (/Users/vincentsmet/tcons/cdk-workshop/node_modules/ts-node/src/index.ts:1621:12)
        at Module.load (node:internal/modules/cjs/loader:1594:32)
        at Module._load (node:internal/modules/cjs/loader:1396:12)
        at wrapModuleLoad (node:internal/modules/cjs/loader:255:19) {
      diagnosticCodes: [ 6133, 6192 ]
    }

Expected: less stack traces?

Running cdktn watch

Correctly warns to use --auto-approve Correctly re-deploys when files are changed on disk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment