Cloud Development Kit for Terraform 0.9 (CDKTF) enables cross-stack references and improves generated resources for providers and modules.
We are excited to announce the release of Cloud Development Kit for Terraform (CDKTF) 0.9. With CDK for Terraform, you can write Terraform configurations in your choice of C#, Python, TypeScript, or Java (with experimental support for Go), and still benefit from the full ecosystem of Terraform providers and modules.
Key improvements in CDK for Terraform 0.9 include:
CDKTF applications can contain multiple stacks that each represent a collection of infrastructure components, allowing you to separate state management for multiple environments. For example, you may want a separate configuration for development, testing, and production environments. With CDKTF 0.9, you can now use cross-stack references to reference a resource in a different stack from the one where it was created.
Previously, this could only be achieved manually using outputs and the remote-state data source. Easily referencing resources across stacks makes development quicker and reduces the risk of inconsistencies across environments.
In the example below, the AWS region that was defined in a different stack (where you defined VPC resources), is exposed and made available to be used by the current stack (where you are defining resources for your Docker backend).
CDKTF generates the required code bindings for the providers and modules that you define in cdktf.json. This allows you to define resources for that provider in your application. We discovered that the generated resources didn’t always work nicely in every supported programming language. The 0.9 release introduces two improvements to make the generated resources for providers and modules easier to work with.
Our community noticed that providers and modules that use sets were sometimes failing to generate code bindings, or that the sets were treated as arrays, making the returned resources difficult to access. This release provides helper methods for accessing individual items or all items as a list.
Note: This is an intermediate step until JSII has support for sets, which will allow us to model them properly in all target languages.
Previously, when you needed the outputs of your CDK application, you had to run Terraform output by hand; now the CDK has its own version of the ‘output’ command. To integrate better into your tooling, we added the –output-file
flag for the deploy and output commands. The file that is written is structured like your CDKTF application, so it's predictable to work with.
The CDK for Terraform CHANGELOG contains a comprehensive list of additional enhancements and bug fixes. Please note that CDKTF 0.9 contains breaking changes that may require code updates. Please see the CHANGELOG and 0.9 Upgrade Guide for details.
If you’re new to the project, the tutorials for CDK for Terraform on HashiCorp Learn are the best way to get started, or dive deeper into our documentation beginning with this overview of CDKTF.
Whether you’re experimenting or actively using CDK for Terraform, we’d love to hear from you. Please file any bugs you encounter, let us know about your feature requests, and share other questions, thoughts, and experiences in the CDK for Terraform discussion forum.
Improve the developer experience writing Terraform code with the help of generative AI powered by Amazon CodeWhisperer.
HashiCorp’s Terraform provider for AWS now enables users to manage their S3 Express buckets.
A new view in the HashiCorp Terraform extension for Visual Studio Code shows your Terraform Cloud workspaces and runs, reducing context-switching.