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 --local

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)
Workshops ran on shared AWS Accounts must use unique Project Name for each attendee to avoid name conflicts.

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

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

added 2 packages, and audited 102 packages in 3s
...
========================================================================================================

  Your CDKTN TypeScript project is ready!

  cat help                Print this message

  Compile:
    npm run get           Import/update Terraform providers and modules (you should check-in this directory)
    npm run compile       Compile typescript code to javascript (or "npm run watch")
    npm run watch         Watch for changes and compile typescript in the background
    npm 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:
    npm run test        Runs unit tests (edit __tests__/main-test.ts to add your own tests)
    npm run test:watch  Watches the tests and reruns them on change

  Upgrades:
    npm run upgrade        Upgrade cdktn modules to latest version
    npm 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 npm:

  npm install @cdktn/provider-aws
  npm install @cdktn/provider-google
  npm install @cdktn/provider-azurerm
  npm install @cdktn/provider-docker
  npm install @cdktn/provider-github
  npm install @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 #




We use analytics to make this content better, but only with your permission.

More information