cdktf synth fails: "Found resources without a matching provider. Please make sure to add the following providers to
Diagnoses and fixes the CDKTF synth-time validation error where resources in a stack have no matching provider construct. Covers adding the missing provider (e.g. AwsProvider) to the stack, cdktf get regeneration, and language-specific examples for TypeScript, Python, and Go. Use when cdktf synth panics with a provider validation error. Not for terraform core provider errors or missing TerraformVariable values.
TL;DR
Add the missing provider construct to your stack before calling synth. If the error names aws, add new AwsProvider(stack, "aws", { region: "us-east-1" }) (TypeScript) or the equivalent in your language, then re-run cdktf synth.
The error
panic: "Validation failed with the following errors:
[cdktf-go-sample] Found resources without a matching provider. Please make sure to add the following providers to your stack: aws"
...
cdktf encountered an error while synthesizing
Synth command: go run main.go
Error: non-zero exit code 1Fix it
- Read the provider name at the end of the error (
awsin this example). - Open your stack file (
main.ts,main.py, ormain.go) and add the provider construct at the top of the stack constructor:
- TypeScript:
new AwsProvider(this, "aws", { region: "us-east-1" }); - Python:
AwsProvider(self, "aws", region="us-east-1") - Go:
aws.NewAwsProvider(stack, jsii.String("aws"), &aws.AwsProviderConfig{Region: jsii.String("us-east-1")})
- If the provider package is not installed, add it first:
npm install @cdktf/provider-aws(TS),pipenv install cdktf-cdktf-provider-aws(Python), orgo getthe generated bindings (Go). - Re-run
cdktf getif the bindings were generated before the provider was added. - Re-run
cdktf synthand confirm it completes without the panic.
Expected result: synth finishes and cdktf.out/stacks/[stack]/cdk.tf.json is generated.
When to use this
cdktf synthpanics with "Found resources without a matching provider"- You added a resource construct but never instantiated its provider
When NOT to use this
- The error is about a missing Terraform variable, not a provider (see the missing-variable skill)
- The provider exists but
terraform initfails to download it (that is a registry/network issue)
Root cause
CDKTF validates at synth time that every resource in a stack has a provider construct of the matching type registered in that stack. Unlike Terraform, which can infer providers from resource type prefixes, CDKTF requires the explicit provider object. The validation runs inside the jsii runtime before any Terraform JSON is emitted, so the failure surfaces as a Go panic (or the language equivalent) rather than a Terraform error.
Edge cases
- Multiple stacks: the provider must be added to each stack that uses its resources, not just one.
- Aliased providers: if resources use a provider alias, instantiate the provider with that alias.
cdktf getregenerates bindings into.genorimports; a stale generation can hide a provider you already added, so re-runcdktf getafter changing providers.
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.