diff --git a/website/docs/cdktf/concepts/hcl-interoperability.mdx b/website/docs/cdktf/concepts/hcl-interoperability.mdx index 8baa6a8e0b..34b53dba64 100644 --- a/website/docs/cdktf/concepts/hcl-interoperability.mdx +++ b/website/docs/cdktf/concepts/hcl-interoperability.mdx @@ -8,6 +8,7 @@ description: >- # HCL Interoperability Terraform requires infrastructure configuration files written in either [HashiCorp Configuration Language (HCL)](/terraform/language/syntax/configuration) or JSON syntax. CDK for Terraform (CDKTF) works by translating configurations defined in an imperative programming language to JSON configuration files for Terraform. +Starting from version 0.20, CDKTF can also generate Terraform HCL as output by setting the `--hcl` flag when running `cdktf synth`. CDKTF may not be the right choice for every team and project within your organization. For example, some teams may already be very familiar with Terraform and have created HCL modules, providers, etc. To provide flexibility, CDKTF applications are interoperable with Terraform projects written in HCL. Specifically: @@ -200,9 +201,10 @@ func NewHclInteropStack(scope constructs.Construct, name string) cdktf.Terraform -To use this as a Terraform module, run `cdktf synth` and copy the resulting `cdktf.out/stacks/random-pet-module/cdktf.json` file out to the module directory in your HCL project. +To use this as a Terraform module, run `cdktf synth` and copy the resulting `cdktf.out/stacks/random-pet-module/cdk.tf.json` file out to the module directory in your HCL project. +By default, `cdktf synth` generates Terraform JSON, but starting from version 0.20, CDKTF can also generate Terraform HCL output by passing the `--hcl` flag to `cdktf synth`. -After you transfer the `cdktf.json` file, you can reference the pet name module as you would any other HCL Terraform module. +After you transfer the `cdk.tf.json` (or `cdk.tf`) file, you can reference the pet name module as you would any other HCL Terraform module. ```terraform terraform { @@ -226,4 +228,8 @@ output "name" { ## HCL to CDKTF -Use the [`cdktf convert`](/terraform/cdktf/cli-reference/commands#convert) command to automatically translate existing HCL into a preferred CDKTF language. The [modules documentation](/terraform/cdktf/concepts/modules) shows how to use existing Terraform modules in CDK for Terraform projects. +HCL can be used with Terraform CDK in two ways. Converting HCL code directly to a CDKTF language, and using Terraform modules directly within CDKTF projects. + +- In order to convert HCL to a CDKTF language, the [`cdktf convert`](/terraform/cdktf/cli-reference/commands#convert) command can be used. It automatically translates HCL into a preferred CDKTF language. This is useful when working with an existing codebase that needs to be converted to CDKTF. + +- While CDKTF has the ability to import HCL modules through `cdktf get` when referenced within the `cdktf.json` file, Terraform modules can also be referenced without generating language specific bindings. The [modules documentation](/terraform/cdktf/concepts/modules) shows how to use existing Terraform modules in CDK for Terraform projects.