Cloud Development Kit for Terraform (CDKTF) 0.14 makes it easier to add and upgrade Terraform providers.
We are excited to announce the release of Cloud Development Kit for Terraform (CDKTF) 0.14. With CDK for Terraform, you can write Terraform configurations in your choice of C#, Python, TypeScript, Java, or Go, and still benefit from the full ecosystem of Terraform providers and modules.
Auto-generating the code bindings for a large Terraform provider can take several minutes, so CDKTF offers pre-built provider packages that you can import directly into your application. Version 0.14 introduces several improvements that make pre-built providers easier to use, including:
provider upgradecommand: Now you can upgrade installed provider bindings while respecting dependencies such as the CDKTF version.
cdktf initcommand now lists all available pre-built providers when initializing a new project and allows you to directly install them when setting up a new CDKTF project.
getCommand: Subsequent runs of
getare faster now because existing bindings are not regenerated.
Back in October, we announced significant performance improvements with CDKTF version 0.13. These improvements required breaking changes for which we provided backward-compatible provider bindings in version 0.13. As announced, the 0.12 (non-namespaced) provider bindings will no longer work starting with CDKTF 0.14. Refer to the upgrade guide for 0.13 to learn how to update your imports for these changes.
With the new
provider upgrade command, you can update your providers regardless of whether they are installed via pre-built provider packages or are available as locally generated providers. The command will update either the installed package or the version constraint for the locally generated providers, depending on how they are currently configured. While doing so, it will make sure that updated pre-built provider packages are compatible with the currently used CDKTF version:
$ cdktf provider upgrade random Upgrading random... Adding package @cdktf/provider-random @ 3.0.11 Installing package @cdktf/provider-random @ 3.0.11 using npm. Package installed. $ cdktf provider upgrade random Upgrading random... The latest version of @cdktf/provider-random is already installed: 3.0.11
Similar to the
provider add command, you can also supply a version constraint to
$ cdktf provider add "aws@~>3.0" Checking whether pre-built provider exists for the following constraints: provider: aws version : ~>3.0 language: typescript cdktf : 0.13.3 Pre-built provider does not exist for the given constraints. Adding local provider registry.terraform.io/hashicorp/aws with version constraint ~>3.0 to cdktf.json Local providers have been updated. Running cdktf get to update... Generated typescript constructs in the output directory: .gen $ cdktf provider upgrade "aws@~>4.0" Upgrading aws... Local providers have been updated. Running cdktf get to update... Generated typescript constructs in the output directory: .gen
After creating a new CDK for Terraform project using the
cdktf init command, you can select from a list of all available pre-built provider packages and directly add them to your new project:
Note: You can always add providers using 'cdktf provider add' later on ? What providers do you want to use? (Press <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed) ◯ vault ◯ vsphere ◯ acme ❯◯ ad ◉ archive ◉ aws ◯ azuread (Move up and down to reveal more choices)
$ cdktf provider add nomad Checking whether pre-built provider exists for the following constraints: provider: nomad version : latest language: typescript cdktf : 0.13.3 Found pre-built provider. Adding package @cdktf/provider-nomad @ 1.0.3 Installing package @cdktf/provider-nomad @ 1.0.3 using npm. Package installed.
As of 0.14 the
get command, which is used to generate local bindings for Terraform providers, won’t re-generate everything all the time. Instead, it will only generate bindings for providers that have been added or changed since the last time
get was run. This drastically lowers the time spent generating provider bindings locally, for example, when new ones are added using the
provider add command.
The upcoming CDKTF 0.15 release will focus primarily on quality-of-life improvements that make it easier to use Terraform Cloud and Terraform Enterprise with CDK for Terraform, such as creating workspaces when adding more stacks to projects.
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.
AWS re:Invent 2022 is here. We highlighted what’s new with Terraform and AWS — like Launch Day support for new AWS services in the Terraform AWS Provider.
The HashiCorp Terraform AWS provider has surpassed one billion downloads — here’s how we got there, and what to look for next.
Run tasks can now be accessed from the HashiCorp Terraform Registry, helping developers discover run tasks they can integrate with their existing Terraform workflow.