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.
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:
- Write an application using either a built-in or custom template to scaffold using your chosen programming language: Python, C#, Java, Go or Typescript
- 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.
cdktfCLI 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: