The Cloud Development Kit for Terraform (CDKTF) enables you to write Infrastructure as Code (IaC) using HashiCorp Terraform without the need to learn HCL (HashiCorp Configuration Language). This opens up Terraform infrastructure development to the use of existing toolchains for other programming languages developers are already familiar with, like Python, C#, Java, Go and Typescript.

The CDKTF allows for DevOps Engineers and SRE (Site Reliability Engineers), as well as Developers, to build the infrastructure deployment and management code for projects using the same programming languages those teams are already using and familiar with. This could help lower the barrier to getting starting using HashiCorp Terraform in the organization and leverage existing development skillsets.

Diagram: CDKTF in the HashiCorp Terraform ecosystem
Diagram: CDKTF in the HashiCorp Terraform ecosystem

The CDK for Terraform works by enabling infrastructure manage code to be written in a programming language other than HCL, then that code is used to either provision the infrastructure using the cdktf CLI or to synthesize the infrastructure code as JSON that can be used with Terraform directly.

The high level flow to using the CDK for Terraform is as follows:

  1. Write an application using either a built-in or custom template to scaffold using your chosen programming language: Python, C#, Java, Go or Typescript
  2. Using your chosen language, write code that defines the infrastructure to deploy and manage. CDKTF will extract the schema from Terraform providers and modules to generate the necessary classes for your application code.
  3. The cdktf CLI can be used to deploy/provision the infrastructure defined in the code, or it can synthesize your code into JSON configuration that can be used directly with Terraform instead.

The CDK for Terraform provides a few benefits that offer an alternative to HCL (HashiCorp Configuration Language). The following are some of the considerations when deciding to use CDK for Terraform:

  • If the team / organization has a strong preference or need to use a particular programming language to define the necessary infrastructure.
  • If abstractions are needed to help maintain the complexity of infrastructure by creating reusable infrastructure patterns composed of multiple and convenient code methods.
  • You may need to perform your own troubleshooting of your infrastructure code, so if you are comfortable with this without requiring commercial support.

If you want to get started with CDK for Terraform, the following resources will be helpful:

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect