Skip to main content

CDK for Terraform 0.10 Adds Multi-Stack Deployments and More

Cloud Development Kit for Terraform 0.10 (CDKTF) enables multi-stack deployments and improves the CLI experience.

We are excited to announce the release of Cloud Development Kit for Terraform (CDKTF) 0.10. 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.10 include:

  • Multi-stack deployments: CLI workflow to support an automated multi-stack deployment process that resolves dependencies between stacks and executes accordingly.
  • CLI refactor and improved output: Full Terraform output is streamed to the CLI for diff, deploy, and destroy commands, improving the debugging and reviewing process.
  • Improved types for computed lists: Output of generated provider code bindings now allows referencing lists of computed attributes as a whole list, instead of just individual items of that list.

»Multi-Stack Deployments

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.

The 0.9 release enabled cross-stack references, with a dependency tree created in the cdktf.out/manifest.json file to make it clear which stacks depend on resources defined in other stacks. With CDKTF 0.10, we implemented a new CLI workflow to support automated multi-stack deployment, which relies on those dependency trees to ensure that the stacks in your application are deployed in the correct order.

Multi-stack deployments

You can now start a process from the CLI to deploy all stacks in your application in the correct order, with either an auto-approve option or a manual approval process that allows you to review the diff for each stack before continuing to the next.

The watch command has also been updated to support multi-stack workflows and you can now make it explicit which files you want to watch.

»CLI Refactor and Improved Output

0.10 improves the CLI output for diff, deploy, and destroy commands to provide a complete view of how resources will be impacted by a configuration change. We now ensure that the full Terraform output is streamed to the CLI, making sure that no valuable information is swallowed or lost. The logs are now formatted to show an attribute level diff, ensuring you understand the impact of your changes. In addition to making sure the full stream of logs is presented, we also implemented several improvements to fix scrollback issues and ensure that the logs are readable on smaller screen sizes.

Detailed diff

»Improved Types for Computed Lists

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. Previously, CDKTF had a limited way of working with lists that were returned in the generated code bindings for providers. To improve the ease of working with lists in your chosen programming language, we made a change to the type of list attributes. This improvement to the generated provider code bindings now allows referencing lists of computed attributes as a whole list, instead of just individual items of that list.

Note: This change will require changes to existing application code when upgrading to 0.10. Please see the 0.10 Upgrade Guide for more information.

»Other Improvements

The CDK for Terraform CHANGELOG contains a comprehensive list of additional enhancements and bug fixes. Please note that CDKTF 0.10 contains breaking changes that may require code updates. Please see the CHANGELOG and 0.10 Upgrade Guide for details.

»Try CDK for Terraform

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.

Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.