Linux command
cdktf 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Initialize a new CDKTF project
cdktf init --template=[typescript] --local
Generate provider bindings
cdktf get
Synthesize Terraform configuration
cdktf synth
Plan infrastructure changes
cdktf diff
Apply infrastructure changes
cdktf deploy
Destroy infrastructure
cdktf destroy
Convert HCL to CDKTF
cdktf convert < [main.tf]
List stacks
cdktf list
说明
CDK for Terraform (CDKTF) enables defining infrastructure using familiar programming languages instead of HCL. It generates Terraform JSON configuration, leveraging the full Terraform ecosystem while writing infrastructure code in TypeScript, Python, Java, C#, or Go. CDKTF projects define constructs that represent infrastructure resources. The synth command compiles code to Terraform JSON in cdktf.out/, which can be inspected or applied manually. The deploy command handles synthesis and application in one step. Provider bindings are generated from Terraform providers, providing type safety and IDE autocompletion. Complex logic, loops, and conditionals use native language features rather than HCL limitations.
参数
- init
- Initialize a new CDKTF project.
- get
- Generate provider bindings from cdktf.json.
- synth
- Synthesize Terraform JSON configuration.
- diff
- Show planned changes (terraform plan).
- deploy _stacks_
- Deploy infrastructure (terraform apply).
- destroy _stacks_
- Destroy infrastructure.
- convert
- Convert HCL Terraform code to CDKTF.
- list
- List all stacks in the application.
- output _stacks_
- Show outputs from deployed stacks.
- watch _stacks_
- Watch for file changes and automatically trigger a deploy.
- debug
- Get debug information about the current project and environment.
- provider _subcommand_
- Manage providers (add, upgrade, list).
- --template _name_
- Project template: typescript, python, java, csharp, go.
- --local
- Use local Terraform state.
- --auto-approve
- Skip interactive approval.
- -o, --output _directory_
- Output directory for synthesized files.
- --log-level _level_
- Set log level (debug, info, warn, error).
- --version
- Show version number.
FAQ
What is the cdktf command used for?
CDK for Terraform (CDKTF) enables defining infrastructure using familiar programming languages instead of HCL. It generates Terraform JSON configuration, leveraging the full Terraform ecosystem while writing infrastructure code in TypeScript, Python, Java, C#, or Go. CDKTF projects define constructs that represent infrastructure resources. The synth command compiles code to Terraform JSON in cdktf.out/, which can be inspected or applied manually. The deploy command handles synthesis and application in one step. Provider bindings are generated from Terraform providers, providing type safety and IDE autocompletion. Complex logic, loops, and conditionals use native language features rather than HCL limitations.
How do I run a basic cdktf example?
Run `cdktf init --template=[typescript] --local` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does init do in cdktf?
Initialize a new CDKTF project.