hashicorp/terraform · error

no schema found for %s (in provider %s)

Error message

no schema found for %s (in provider %s)

What it means

Returned by jsonconfig.marshalResources when schemas.ResourceTypeConfig(provider, mode, type).Body is nil — meaning no schema exists for the given resource type within its provider (config.go:501-507). The %s placeholders are the resource address and the provider address. Without a schema Terraform cannot marshal the resource's expressions, so it aborts.

Source

Thrown at internal/command/jsonconfig/config.go:507

		}

		cExp := marshalExpression(v.Count)
		if !cExp.Empty() {
			r.CountExpression = &cExp
		} else {
			fExp := marshalExpression(v.ForEach)
			if !fExp.Empty() {
				r.ForEachExpression = &fExp
			}
		}

		schema := schemas.ResourceTypeConfig(
			v.Provider,
			v.Mode,
			v.Type,
		)
		if schema.Body == nil {
			return nil, fmt.Errorf("no schema found for %s (in provider %s)", v.Addr().String(), v.Provider)
		}
		r.SchemaVersion = uint64(schema.Version)

		r.Expressions = marshalExpressions(v.Config, schema.Body)

		// Managed is populated only for Mode = addrs.ManagedResourceMode
		if v.Managed != nil && len(v.Managed.Provisioners) > 0 {
			var provisioners []provisioner
			for _, p := range v.Managed.Provisioners {
				schema := schemas.ProvisionerConfig(p.Type)
				prov := provisioner{
					Type:        p.Type,
					Expressions: marshalExpressions(p.Config, schema),
				}
				provisioners = append(provisioners, prov)
			}
			r.Provisioners = provisioners
		}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Run `terraform init` to install the required providers and populate the schema cache before show -json.
  2. Update the provider to a version that includes the resource type (or pin required_providers to a version that has it).
  3. Remove or import the orphaned resource from state if the resource type was legitimately removed.
  4. Verify the resource type name spelling and the provider source address in required_providers.

Example fix

# before
$ terraform show -json   # provider not installed
# after
$ terraform init
$ terraform show -json
Defensive patterns

Strategy: validation

Validate before calling

// Verify the provider schema exposes every resource type before Marshal.
for addr, res := range module.ManagedResources {
    if schemas.ResourceTypeConfig(res.Provider, res.Mode, res.Type).Body == nil {
        return fmt.Errorf("no schema for %s; run terraform init", addr)
    }
}

Prevention

When it happens

Trigger: Running `terraform show -json` / jsonconfig.Marshal when the loaded schema set has no entry for a resource type referenced by the config/state. This happens when the provider that defines the resource is not installed, a different/older provider version is in the schema cache, or the resource type was renamed/removed upstream.

Common situations: Forgetting `terraform init` so providers (and thus schemas) aren't loaded before `terraform show -json`; a state file referencing a resource type no longer present in the installed provider version; provider swapped for a fork that dropped the resource; lock file pins an old provider lacking the resource.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/532dad3eb31787e7. Report an issue: GitHub.