• Overview
    • Enforce Policy as Code
    • Infrastructure as Code
    • Inject Secrets into Terraform
    • Integrate with Existing Workflows
    • Manage Kubernetes
    • Manage Virtual Machine Images
    • Multi-Cloud Deployment
    • Network Infrastructure Automation
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
  • Registry
  • Tutorials
    • About the Docs
    • Intro to Terraform
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
    • Terraform Tools
    • CDK for Terraform
    • Glossary
  • Community
GitHubTerraform Cloud
Download

    CDK for Terraform

  • Overview
  • Get Started
    • Architecture
    • HCL Interoperability
    • Constructs
    • Providers and Resources
    • Modules
    • Data Sources
    • Variables and Outputs
    • Functions
    • Remote Backends
    • Aspects
    • Assets
    • Tokens
    • Stacks
  • Examples and Guides
    • Project Setup
    • Configuration File
    • Best Practices
    • Environment Variables
    • Remote Templates
    • AWS Adapter [preview]
    • Unit Tests
    • Debugging
    • CLI Configuration
    • Commands
    • Overview
    • Upgrading to Version 0.6
    • Upgrading to Version 0.7
    • Upgrading to Version 0.9
    • Upgrading to Version 0.10
    • Upgrading to Version 0.11
  • Community
  • Telemetry
  • Other Docs

  • Intro to Terraform
  • Configuration Language
  • Terraform CLI
  • Terraform Cloud
  • Terraform Enterprise
  • Provider Use
  • Plugin Development
  • Registry Publishing
  • Integration Program
  • Terraform Tools
  • CDK for Terraform
  • Glossary
Type '/' to Search

»CLI Configuration

The CDK for Terraform (CDKTF) CLI allows you to initialize a new CDKTF project, adjust project settings, synthesize your infrastructure into Terraform configuration files, deploy your CDKTF application, and more. You can also use some Terraform CLI commands like terraform apply and terraform destroy directly, but we recommend using the available cdktf cli commands where possible.

»Install

$ npm install -g cdktf-cli
$ npm install -g cdktf-cli

»Use

$ cdktf --help
$ cdktf --help

Help output:

Commands:
  cdktf init [OPTIONS]                Create a new cdktf project from a template.
  cdktf get [OPTIONS]                 Generate CDK Constructs for Terraform providers and modules.
  cdktf convert [OPTIONS]             Converts a single file of HCL configuration to CDK for Terraform. Takes the file to be converted on stdin.
  cdktf deploy [OPTIONS] <stacks..>   Deploy the given stacks                                                                                                                                    [aliases: apply]
  cdktf destroy [OPTIONS] <stacks..>  Destroy the given stacks
  cdktf diff [stack] [OPTIONS]        Perform a diff (terraform plan) for the given stack                                                                                                         [aliases: plan]
  cdktf list [OPTIONS]                List stacks in app.
  cdktf login                         Retrieves an API token to connect to Terraform Cloud.
  cdktf synth [stack] [OPTIONS]       Synthesizes Terraform code for the given app in a directory.                                                                                          [aliases: synthesize]
  cdktf watch [stack] [OPTIONS]       [experimental] Watch for file changes and automatically trigger a deploy
  cdktf output [stack] [OPTIONS]      Prints the output of a stack
  cdktf debug                         Get debug information about the current project and environment
  cdktf provider                      A set of subcommands that facilitates provider management                                                                                                                             [aliases: outputs]
  cdktf completion                    generate completion script

Options:
  --version                   Show version number                                                                                                                                                                  [boolean]
  --disable-plugin-cache-env  Dont set TF_PLUGIN_CACHE_DIR automatically. This is useful when the plugin cache is configured differently. Supported using the env CDKTF_DISABLE_PLUGIN_CACHE_ENV. [boolean] [default: false]
  --log-level                 Which log level should be written. Only supported via setting the env CDKTF_LOG_LEVEL                                                                                                 [string]
  -h, --help                  Show help                                                                                                                                                                            [boolean]

Options can be specified via environment variables with the "CDKTF_" prefix (e.g. "CDKTF_OUTPUT")
Commands:
  cdktf init [OPTIONS]                Create a new cdktf project from a template.
  cdktf get [OPTIONS]                 Generate CDK Constructs for Terraform providers and modules.
  cdktf convert [OPTIONS]             Converts a single file of HCL configuration to CDK for Terraform. Takes the file to be converted on stdin.
  cdktf deploy [OPTIONS] <stacks..>   Deploy the given stacks                                                                                                                                    [aliases: apply]
  cdktf destroy [OPTIONS] <stacks..>  Destroy the given stacks
  cdktf diff [stack] [OPTIONS]        Perform a diff (terraform plan) for the given stack                                                                                                         [aliases: plan]
  cdktf list [OPTIONS]                List stacks in app.
  cdktf login                         Retrieves an API token to connect to Terraform Cloud.
  cdktf synth [stack] [OPTIONS]       Synthesizes Terraform code for the given app in a directory.                                                                                          [aliases: synthesize]
  cdktf watch [stack] [OPTIONS]       [experimental] Watch for file changes and automatically trigger a deploy
  cdktf output [stack] [OPTIONS]      Prints the output of a stack
  cdktf debug                         Get debug information about the current project and environment
  cdktf provider                      A set of subcommands that facilitates provider management                                                                                                                             [aliases: outputs]
  cdktf completion                    generate completion script

Options:
  --version                   Show version number                                                                                                                                                                  [boolean]
  --disable-plugin-cache-env  Dont set TF_PLUGIN_CACHE_DIR automatically. This is useful when the plugin cache is configured differently. Supported using the env CDKTF_DISABLE_PLUGIN_CACHE_ENV. [boolean] [default: false]
  --log-level                 Which log level should be written. Only supported via setting the env CDKTF_LOG_LEVEL                                                                                                 [string]
  -h, --help                  Show help                                                                                                                                                                            [boolean]

Options can be specified via environment variables with the "CDKTF_" prefix (e.g. "CDKTF_OUTPUT")

»CI Environment

If you are running the CLI in an automated environment, you can force the dynamic CLI output rendering to be static by setting the CI environment variable to true.

»Configuration File

You can configure the behavior of the Terraform CDK CLI by modifying the cdktf.json file in your project root directory. Refer to the cdktf.json documentation for more detail on how you can supply custom configuration settings for your application.

»Telemetry

The CDKTF CLI (cdktf-cli interacts with a HashiCorp service called Checkpoint to report project metrics such as cdktf version, project language, provider name, platform name, and other details that help guide the project maintainers with feature and roadmap decisions. The code that interacts with Checkpoint is part of the CDK for Terraform CLI.

The use of Checkpoint is completely optional. Refer to the telemetry documentation for more information about Checkpoint and you can disable it if desired.

github logoEdit this page
  • Overview
  • Docs
  • Extend
  • Privacy
  • Security
  • Press Kit
  • Consent Manager