Cdktf init creates copies of local modules folder outside project

Hello all,
I’m experimenting with Terraform CDK with an existing project that contains a terraform stack in HCL.

My project structure is similar to this:

/<projectRoot>/terraform/env/development/main.tf <-- References ../modules/web_service
/<projectRoot>/terraform/env/modules/web_service 
/<projectRoot>/cdk <-- New folder for CDK

I ran cdktf init and with the prompts setup typescript, local state, and pointed to an existing directory (/<projectRoot>/terraform/env/development, which I assume is the same as using the --from-terraform-project CLI flag).

When all was said and done, I was running cdktf plan on my new CDK project, and kept getting provider version errors due to some mismatches with version constraints in the web_service module. I corrected it, but running cdktf get didn’t seem to pick up the changes in the web_service module. After poking around, I found that cdktf init seemed to create a copy of /<projectRoot>/terraform/env/modules/web_service outside of the project root at <projectRoot>/../modules/web_service, and that cdktf get is using that. I also see references to this path in <projectRoot>/cdk/cdktf.json.

I’m curious as to why this copy is created. I’m also curious if it’s common place for folks to manually adjust the settings in cdktf.json in scenarios like this?

Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.