The initial version of Terrastack was built over the course of a few days in March 2020. It was built around the same concepts as the AWS CDK and shared a similar vision: Leveraging imperative programming languages such as Typescript, Python, Java and C# to build out infrastructure with the Terraform engine.
Liquid error: internal
While my intention with the prototype was to raise awareness and get support for further development, I didn’t anticipate pushing at an open door.
Fast forward four months, the successor of Terrastack - the Terraform CDK - got launched as a joint effort by Hashicorp, the AWS CDK team and me :) It turned out that Hashicorp and the AWS CDK team started to work together on the exact same idea long before I published Terrastack. They reached out to me and I’m still very grateful for the opportunity to join the ongoing project as an independent contributor.
Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
CDK for Terraform
This experimental repository contains software which is still being developed and in the alpha testing stage. It is not ready for production use.
CDK (Cloud Development Kit) for Terraform allows developers to use familiar programming languages to define cloud infrastructure and provision it through HashiCorp Terraform.
CDK for Terraform apps are written in one of the supported programming languages and can leverage the entire ecosystem of Terraform modules and providers. The application synthesizes Terraform configuration in JSON. Terraform or the CDK for Terraform can then be used to deploy the application.
The CDK for Terraform project includes two packages:
- cdktf-cli - A CLI that allows users to run commands to initialize, import, and synthesize CDK for Terraform applications.
- cdktf - A library for defining Terraform resources using programming constructs.
The project currently supports TypeScript, Python, Java, and C#.
Choose a language:
The community preview of the Terraform CDK is considered an alpha version. There are lots of rough edges which we’ll iron out over the next few months. Nevertheless, the sentiment of the feedback has been quite positive so far. There are more than 600 stars on Github, a bunch of contributions to the Github repository and roughly 1500 downloads via NPM within one week after the launch. That’s fantastic and makes me excited about the future of the Terraform CDK.
Here’s a little real world example, which I migrated from Terrastack to Terraform CDK.
Terraform CDK SSL Proxy for cdkweekly.com
This little workaround was initially built on top of Terrastack and got migrated to its successor Terraform CDK. It's the first real world example for the Terraform CDK and is running in production for a while now.
npm install cdktf get
That's where one of the Terraform CDK examples is stemming from.
- Redirect naked domain -> www (probably including SSL via Cloudfront distribution)
- Inject Google Analytics or something similar
- Migrate state to Terraform Cloud
I’m currently working on yet another example, which will be a bit more elaborate and demonstrate a more complex use case.
When you’re interested to learn more about the Terraform CDK, here are some resources to get you started:
If you have feedback or feature requests, the Github repository is a good starting point. We try to follow up on newly created issues quickly. I’d love to hear from you.
ps: The actual first version of Terrastack dates back to the end of 2018 and was sort of Terragrunt on steroids powered by Typescript. I had lots of fun building that prototype back then together with Andreas Litt.
pps: If you're interested to keep up with what's happening in the CDK ecosystem, you should consider signing up to cdkweekly