cdktf provider add fails on CDKTF versions newer than 0.20.1
Covers the regression where cdktf provider add fails on versions after 0.20.1 while 0.20.1 works, with the workaround of pinning the CLI to 0.20.1 for provider generation. Use when provider add fails right after upgrading cdktf past 0.20.1. Not for pre-built provider lookup misses.
TL;DR
Pin the CDKTF CLI to 0.20.1 to generate providers: npm install -g cdktf-cli@0.20.1, run cdktf provider add, then upgrade the CLI back. The regression is version-specific.
The error
cdktf provider add fails on CDKTF versions newer than 0.20.1. On 0.20.1 it works:
[INFO] Adding local provider registry.terraform.io/grafana/grafana...
Generated typescript constructs in the output directory: src/genOn newer versions it fails right after the "Adding local provider" line.
Fix it
- Downgrade the CLI:
npm install -g cdktf-cli@0.20.1. - Run
cdktf provider add "[provider]"and confirm bindings generate. - Upgrade the CLI back to your version for synth/deploy; the generated bindings remain valid.
- Alternatively, install a pre-built provider package (
npm install @cdktf/provider-[name]) if one exists for your version.
Expected result: bindings generate under the configured output directory.
When to use this
cdktf provider addworked on 0.20.1 and fails after upgrading the CLI- The failure happens during local provider generation, not pre-built lookup
When NOT to use this
- The error is "Pre-built provider information not found" (different cause)
- You are on 0.20.1 already (something else is wrong)
Root cause
A regression in the provider code-generation path after 0.20.1 breaks local schema harvesting for some providers. The generated output itself is version-independent, so bindings produced by 0.20.1 work fine with newer CLI versions for synth and deploy.
Edge cases
- Keep the 0.20.1 CLI around (e.g. via npx) if you regenerate providers often.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.