Announcing CDK for Terraform 0.5

The CDK for Terraform 0.5 introduces code generation from HCL and a new cdktf watch workflow for serverless workloads.

We are excited to announce the release of a cloud development kit (CDK) for Terraform 0.5. CDK for Terraform provides the ability to write HashiCorp Terraform configurations in C#, Python, TypeScript, and Java using all existing Terraform providers and Terraform modules.

Key improvements in 0.5 include:

  • Convert: The ability to convert existing HCL Terraform configurations to C#, Python, TypeScript, and Java.
  • Watch: A new experimental watch workflow designed for serverless workflows that require rapid iteration in production-like environments.

We’ll be hosting CDK for Terraform Community Office Hours at 1 p.m. PT on Thursday, July 29, where the engineering team will be available to answer questions about CDK for Terraform 0.5.

»Convert HCL Terraform Configurations

The new convert command automatically translates HCL configuration to CDK’s supported languages.

Since CDK for Terraform internally uses Terraform Core, it’s compatible with all existing Terraform providers and modules, and the Terraform Registry provides a huge library of providers and modules, including copy-pasteable examples of nearly all resources across more than 1,000 providers.

However, these resource examples are in HCL. For many Terraform users, copying examples is a common starting point. To use those examples in other languages via CDK for Terraform, you would have to mentally translate them to the equivalent TypeScript, Python, and other supported languages, which can be slow. The new cdktf convert command automates this translation to make it easier to apply the existing library of HCL Terraform content to CDK for Terraform.

Here is a simple macOS workflow that shows how to use example code from the Terraform Registry using the pbcopy and pbpaste commands: Copy the HCL example from the Terraform Registry, then run pbpaste | cdktf convert --language python | pbcopy on a macOS terminal. This will convert the example to Python, then copy it again so you can paste it into an editor.

CDK for Terraform 0.5 also introduces the ability to convert full projects from HCL to TypeScript; support for full project conversion to other languages will be added in future releases. To create a new CDK for Terraform configuration by converting an existing HCL Terraform codebase, run:

cdktf init --template="typescript" --from-terraform-project /path/to/terraform/project

See the cdktf convert documentation for more information, and read about our known limitations. We’re very interested in your practical experiences. Please file GitHub issues and enhancement requests!

»Watch Workflow

cdktf watch is a new, experimental workflow introduced in CDK for Terraform 0.5 that deploys changes and shows diffs as you edit code.

We added this feature after using CDK for Terraform to build and deploy serverless applications, when we found ourselves wanting to continually redeploy in a production-like environment. This feature is intended to be used in a production-like development environment, and works in all supported languages.

As you edit code, CDK for Terraform watches for changes, synthesizes and applies changes, and continuously shows either changes or errors. The cdktf watch command is the first step toward a faster iterative development process for CDK for Terraform users.

See the cdktf watch documentation for more information on how to use this feature.

CDK for Terraform 0.5 also includes bug fixes. The CDK for Terraform changelog contains a comprehensive list of enhancements and bug fixes.

»Try CDK for Terraform

The CDK for Terraform Learn Guide is the best way to get started. Once you’ve completed that, check out our documentation and language-specific examples.

Whether you’re experimenting or actively using CDK for Terraform, we’d love to hear from you. Please drop notes in the discussion forum, and report any issues you encounter in our issue tracker. We’re particularly looking for feedback on the new, experimental Go support, so please reach out.

Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.