cdktf deploy fails with "Failed to instantiate provider" and "unknown provider registry.terraform.io/-/docker"
Fixes the cdktf deploy/destroy failure where Terraform reports an unknown provider at a registry.terraform.io/-/ address because the generated config has no provider source. Covers regenerating bindings, fixing the provider source, and cleaning stale .gen output. Use when deploy or destroy fails with the unknown-provider error. Not for credential or network failures.
TL;DR
Your generated config points Terraform at a nonsense provider address (registry.terraform.io/-/docker) because the provider source is missing. Re-run cdktf get, fix the provider source to the real namespace, remove stale .gen/cdktf.out, and re-synth.
The error
Failed to instantiate provider "registry.terraform.io/-/docker" to obtain
schema: unknown provider "registry.terraform.io/-/docker"
non-zero exit code 1Fix it
- Re-run
cdktf getto regenerate provider bindings with current sources. - Check
cdk.tf.jsonrequired_providers: the docker entry must have a realsource(e.g.kreuzwerker/docker), never-. - Remove stale generated output:
rm -rf .gen cdktf.out(and any compiledmain.js/main.d.ts). - Re-run
cdktf synth, verify the provider address is correct in the JSON, thencdktf deploy.
Expected result: deploy plans and applies instead of failing on provider instantiation.
When to use this
cdktf deployorcdktf destroyfails withunknown provider "registry.terraform.io/-/[name]"- You switched provider namespaces or upgraded cdktf recently
When NOT to use this
- The provider address is correct but the download fails (registry/network issue)
- Synth itself fails (fix the synth error first)
Root cause
The - in the address is Terraform's placeholder for "no namespace given". It appears when the generated required_providers lacks a source, common after namespace moves (the docker provider moved from terraform-providers to kreuzwerker) combined with stale generated bindings that predate the move.
Edge cases
cdktf destroyhits the same bug on old stacks; clean and re-synth before destroying.- If you hand-edit
cdk.tf.json, your edits are overwritten on the next synth; fix the source in code or config instead.
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.