Skip to content
CDKTN init

CDKTN init

Create project directory

Create an empty directory on your system:

mkdir cdk-workshop && cd cdk-workshop

CDKTN init

We will use cdktn init to create a new TypeScript CDKTN project:

cdktn init --template=typescript-pnpm --local

This workshop uses the pnpm project template. npm remains the default for cdktn init; selecting typescript-pnpm makes the generated project use pnpm and creates its pnpm workspace configuration.

Output should look like this (you can safely ignore warnings about initialization of a git repository, this probably means you don't have git installed, which is fine for this workshop):

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)

Confirm the prompts:

  • Project Name ↩

  • Project Description ↩

  • Do you want to start from an existing Terraform project? ↩

  • Do you want to send crash reports to the CDKTN team? ↩

    Refer to crash reporting for more information

  • Help us prioritize features and bolster regression tests: send anonymous usage telemetry? Yes

    It covers which commands you run, your language, tooling versions and platform; never your code, paths or resource names. See telemetry.

  • What providers do you want to use? ↩ (none)

========================================================================================================

  Your CDKTN TypeScript project is ready!

  cat help                Print this message

  Compile:
    pnpm run get           Import/update Terraform providers and modules (you should check-in this directory)
    pnpm run compile       Compile typescript code to javascript (or "pnpm run watch")
    pnpm run watch         Watch for changes and compile typescript in the background
    pnpm run build         Compile typescript

  Synthesize:
    cdktn synth [stack]   Synthesize Terraform resources from stacks to cdktf.out/ (ready for 'terraform apply')

  Diff:
    cdktn diff [stack]    Perform a diff (terraform plan) for the given stack

  Deploy:
    cdktn deploy [stack]  Deploy the given stack

  Destroy:
    cdktn destroy [stack] Destroy the stack

  Test:
    pnpm run test        Runs unit tests (edit __tests__/main-test.ts to add your own tests)
    pnpm run test:watch  Watches the tests and reruns them on change

  Upgrades:
    pnpm run upgrade        Upgrade cdktn modules to latest version
    pnpm run upgrade:next   Upgrade cdktn modules to latest "@next" version (last commit)

 Use Providers:

  You can add prebuilt providers (if available) or locally generated ones using the add command:

  cdktn provider add "aws@~>3.0" null kreuzwerker/docker

  You can find all prebuilt providers on npm: https://www.npmjs.com/search?q=keywords:cdktn
  You can also install these providers directly through pnpm:

  pnpm add @cdktn/provider-aws
  pnpm add @cdktn/provider-google
  pnpm add @cdktn/provider-azurerm
  pnpm add @cdktn/provider-docker
  pnpm add @cdktn/provider-github
  pnpm add @cdktn/provider-null

  You can also build any module or provider locally. Learn more https://cdktn.io/docs/concepts/providers

========================================================================================================

As you can see, it shows us a bunch of useful commands to get us started.

See Also

Edit this page