As more and more focus shifts to the cloud, and more importantly the scale of these efforts increase, it becomes increasingly complex to manage and deploy these infrastructures. Terraform has always been a great tool to manage these configurations and remain as cloud-agnostic as possible. One issue with terraform however has been how to architect the code and manage the infrastructure config as things get more complex. Tools like Terragrunt have been able to step in and fill some gaps, but still leave a bit to be desired.
We collaborated with AWS and their Cloud Development Kit (CDK) team to support this new project leveraging two key components of the AWS CDK: a set of language native frameworks for defining infrastructure and adaptors to an underlying provisioning tool. Using these libraries, the AWS CDK generates CloudFormation configuration. Similarly, the CDK for Terraform generates Terraform configuration to enable provisioning with Terraform. The adaptor works with any existing provider and modules hosted in the Terraform Registry. The core Terraform workflow remains the same, with the ability to plan changes before applying.CDK for Terraform: Enabling Python & TypeScript Support (hashicorp.com)
With the introduction of CDK for Terraform, this entire process has become increasingly more manageable. CDK for Terraform essentially allows us to use more familiar languages (Typescript, Java, and Python) to create our infrastructure as code. This is a huge win for a couple of reasons: First, it allows us to leverage all of the natural control flows that are available in these languages as well as their large ecosystems of libraries for more complex use cases. Additionally, this opens up the world of testing to easily be integrated in our infrastructure code utilizing existing tools. We likely don’t want to test our specific configuration implementations, but being able to test more complex workflows will allow us to be more confident that we’re writing stable configurations.
Infrastructure as code is a great way to allow software engineers a coherent process in managing their infrastructure, and CDK for Terraform is just another step in making that all the more natural of a process.