How to add terraform version constraint via cdktf?

I’m just getting started in cdktf but have been using terraform from the beginning. I’m mainly using Python, but I think this question applies to any “flavor”.

How do I define a terraform version constraint via cdktf, the way I would in straight terraform HCL using

terraform {
  required_version = ">= 1.4.2"
}

Hi @jantman :wave:

There is currently no high-level CDKTF functionality to achieve that, but you can use an override on your stack, something like:

stack.add_override("terraform.required_version", ">= 1.4.2")

Out of curiosity: Why do you want to set the Terraform version?

– Ansgar

Sometimes, the stack needs to be in an older version to compatible with other resources… one case would be, we migrate existing HCL to terraform 1.3, but we can migrate to 1.3 all in one night, it takes weeks to get it done, then this case, we need to have migrated stack have 1.3, other remain 1.2