We have been using CDK on AWS and it is really nice because you can do complex things through Typescript.
I have not used terraform that much, but they did launch a CDK for terraform that does a similar thing https://www.terraform.io/cdktf. Basically you write in code and at compile time it converts it to the terraform templates.