
Why choose CDKTF?
CDKTF brings the full Terraform provider and module ecosystem together with the expressiveness of familiar programming languages. This combination provides:- Familiar syntax and constructs (loops, conditionals, functions, classes) for defining infrastructure.
- Better logic reusability through language-level abstractions and helper functions.
- Type safety and IDE auto-completion for safer, faster development and refactoring.
- Direct compatibility with Terraform modules and engines (including OpenTofu), enabling gradual adoption.
Key benefits at a glance
Using language features and types reduces the learning curve and helps catch issues earlier — type mismatches and invalid patterns are often discovered during development instead of at apply time.
Type safety example
Below is a simplified TypeScript CDKTF stack demonstrating typed properties. Note howobjectLockEnabled is typed as a boolean. This example configures the AWS and random providers, creates a random ID, and provisions an S3 bucket using the generated value.
Synth & deploy output
When you synthesize and deploy a CDKTF stack (for example, usingcdktf deploy), the output shows Terraform-style logs for resource lifecycle operations. Example:
Compatibility and migration
CDKTF is designed to fit into existing Terraform workflows and to simplify adoption:- Use existing Terraform modules directly from CDKTF — reuse proven infrastructure code without rewriting.
- CDKTF synthesizes Terraform configuration (JSON) that remains compatible with Terraform engines and OpenTofu.
- Migration tools and community guides are available to help convert HCL/Terraform projects into CDKTF constructs when needed.
- CDK for Terraform (CDKTF): https://developer.hashicorp.com/terraform/cdktf
- Terraform Documentation: https://www.terraform.io/docs
- OpenTofu: https://opentofu.org
- Terraform Provider Registry: https://registry.terraform.io
