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.
But it can't! It's quite misleading that it can be a used as a terraform module. Cdktf generated code contains provider and backend configuration, so it cannot be reused.
References
No response
Help Wanted
[ ] I'm interested in contributing a fix myself
Community Note
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
I think https://github.com/cdktf/cdktf-tf-module-stack should be a native option for cdktf projects. Package is fairly small, but functionality is the most important.
Documentation at https://developer.hashicorp.com/terraform/cdktf/concepts/hcl-interoperability#cdktf-to-hcl claims cdktf synth generated output can be used as a terraform module.
But it can't! It's quite misleading that it can be a used as a terraform module. Cdktf generated code contains provider and backend configuration, so it cannot be reused.
References
No response
Help Wanted
Community Note