> ## Documentation Index
> Fetch the complete documentation index at: https://cdktn.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Configuration - CDK Terrain

> Install and configure the CDKTN Command Line Interface.

The CDK Terrain (CDKTN) CLI allows you to initialize a new CDKTN project, adjust project settings, synthesize your infrastructure into Terraform configuration files, deploy your CDKTN application, and more. You can also use some Terraform CLI commands like `terraform apply` and `terraform destroy` directly, but we recommend using the available [`cdktn cli` commands](/cli-reference/commands) where possible.

<Tip>CDKTN works with both Terraform and OpenTofu. To use OpenTofu, set the `TERRAFORM_BINARY_NAME=tofu` environment variable. Refer to [Environment Variables](/create-and-deploy/environment-variables) for details.</Tip>

## Install

```bash theme={null}
$ npm install -g cdktn-cli
```

## Use

```bash theme={null}
$ cdktn --help
```

Help output:

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

Options:
  --version                   Show version number                                                                                                                                                                  [boolean]
  --disable-plugin-cache-env  Don't 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](/create-and-deploy/configuration-file) for more detail on how you can supply custom configuration settings for your application. You can also declare the Terraform and OpenTofu versions your project targets and optionally have `diff`, `deploy`, and `destroy` verify the installed binary against them; see [Declare Target Runtimes](/create-and-deploy/configuration-file#declare-target-runtimes).

## Telemetry

The CDKTN CLI ([cdktn-cli](https://github.com/open-constructs/cdk-terrain/tree/main/packages/cdktn-cli) interacts with a HashiCorp service called [Checkpoint](https://checkpoint.hashicorp.com)
to report project metrics such as cdktn 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](https://github.com/open-constructs/cdk-terrain/blob/main/packages/%40cdktf/commons/src/checkpoint.ts) is part of the CDK Terrain CLI.

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