CDKTF Commands through node script

I see that I could use the CLI to call cdftf plan and cdktf get. Is there a way I could import the methods behind these commands to a node script to invoke in that context? Ideally, the method would return enough data about the plan to then invoke the apply right after.

Thanks for any help in advance!

Hey there,

We currently don’t support this, though it’s something on our radar:

If you need something in the mean time you could use terraform-cdk/index.ts at main · hashicorp/terraform-cdk · GitHub with const cdktf = require("cdktf-cli/lib");, but please be aware that the API there is subject to change.

1 Like

This sounds great, thank you! Are these issues open for outside contribution or are they considered too large and are reserved for development from the team?

In the meantime, I’m comfortable importing from the cdk directly, even if the API is subject to change

I think the immediate next step there is to publish the lib packages as an experimental API package. When we feel the API is stable and add JSII support so that other languages can use that api we can make it official. I think the first step is doable as an outside contribution, but the second one will be more time consuming.