Announcing CDK for Terraform 0.7
Cloud Development Kit for Terraform 0.7 introduces a tech preview for compatibility with AWS CDK constructs, a simplified provider API, and improved documentation.
We are excited to announce the release of Cloud Development Kit for Terraform (CDKTF) 0.7. 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.7 include:
- AWS CDK compatibility: A new experimental adapter lets you use resources from the AWS Cloud Development Kit construct library in your CDKTF application.
- Simplified provider API: The interface with the provider API has been updated to make the returned resources easier to access and work with.
- Improved documentation: Product documentation has been updated and moved from GitHub to Terraform.io.
» AWS CDK Construct Compatibility (Tech Preview)
You can now leverage resources from both the Terraform and AWS CDK ecosystems in your CDK for Terraform applications. The new experimental AwsTerraformAdapter
allows you to deploy AWS CDK (v2) constructs in your CDKTF application to provision resources using Terraform. Constructs are the building blocks of CDK applications; by adding in compatibility with the AWS CDK construct ecosystem, engineers deploying resources on AWS should enjoy a faster and more efficient development process.
Check out the three-minute video below for a demo of how to use the new AWS Terraform adapter in a CDKTF TypeScript application.
The AwsTerraformAdapter
is in technical preview and is not ready for production usage. Please share your experiences trying out this new feature by posting to the CDK for Terraform Discuss forum. For more information, please refer to the documentation.
» Improvements to the Provider API
When you run cdktf get
, the provider API downloads the providers and modules that were defined in your application and generates CDK constructs for them. In 0.7, the interface with this API has been updated to make the constructs that are returned easier to access and work with. Previously, the API translated any block to an array of a certain type, both in configuration and as properties on the resource/data source instances. For blocks that appear only once, this made the API harder to use, and resulted in a lot of extra nesting.
Starting with 0.7, these blocks will return just the type, instead of an array of a certain type. This change makes the returned resources easier to work with. For example, in the TypeScript code snippet below, the object properties that are returned from the new API can be accessed directly, rather than within an array:
// Before
const development = new Namespace(this, "development", {
metadata: [
{
name: "development",
},
],
});
const deploy = new Deployment(this, "nginx", {
metadata: [
{
namespace: "setViaOverride",
name: "nginx",
},
],
// ...
});
deploy.addOverride(
"metadata.0.namespace",
`\${${development.fqn}.metadata.0.name}`
);
// After
const development = new Namespace(this, "development", {
metadata: {
name: "development",
},
});
new Deployment(this, "nginx", {
metadata: {
namespace: development.metadata.namespace,
name: "nginx",
},
// ...
});
For information on how to migrate to the new version of this API, please see the upgrade guide.
» Other Improvements
Product documentation for CDK for Terraform has been updated and moved from the GitHub repo to Terraform.io. On the new docs site, you can filter for specific reference topics and read more about the architecture and conceptual framework of CDKTF. You can start reading the CDKTF documentation on the introductory What is CDK for Terraform? page.
The CDK for Terraform changelog contains a comprehensive list of additional enhancements and bug fixes. Please note that CDK for Terraform 0.7 contains breaking changes that will require code updates for namespacing AWS provider resources, as well as the provider API updates described above. Please see the CHANGELOG and 0.7 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 you can dive deeper into our documentation.
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
More blog posts like this one
New Terraform integrations with Crowdstrike, Datadog, JFrog, Red Hat, and more
12 new Terraform integrations from 9 partners provide more options to automate and secure cloud infrastructure management.
Terraform delivers launch-day support for Amazon S3 Tables, EKS Hybrid Nodes, and more at re:Invent
The Terraform provider for AWS now enables users to manage a variety of new services just announced at re:Invent.
HashiCorp at re:Invent 2024: Infrastructure Lifecycle Management with AWS
A recap of HashiCorp infrastructure news and developments on AWS from the past year, from a new provider launch to simplifying infrastructure provisioning and more.