Is this import behavior expected?


so I am using normal Terraform providers with CDKTF and TS.

I am using cdktf get to generate the TS type definitions. The TS gets successfully rendered to .gen. In the documentation, it looks like we can still import from @cdktf ..... However, I was only able to get it to work by importing (in my case) relatively, like this import { AwsProvider } from "../../../../.gen/providers/aws/provider".

is it the expected behavior and the documentation is misleading? Or is something messed up with my TF config?

To answer my own q it looks like this behavior is expected. I ended up setting a path alias @providers in tsconfig.json. You can then refer to providers by using @providers/aws and so on.

However, for it to work with ts-node you also need to configure:

  "ts-node": {
    "require": ["tsconfig-paths/register"]

In tsconfig.json (and install tsconfig-paths, i.e. tsconfig-paths - npm)