VectleSkillsterraform plan on cdktf output fails with "Incorrect attribute value type" and "string required"

terraform plan on cdktf output fails with "Incorrect attribute value type" and "string required"

Export

Fixes the plan-time type error when a CDKTF-generated cdk.tf.json passes a whole module object where a string is required (e.g. name = ${module.resourceNaming.resource_group} referencing an 8-attribute object). Covers indexing into the output (resource_group["name"]) or using Fn lookup. Use when terraform plan on cdktf.out fails with Incorrect attribute value type. Not for synth-time JSII errors.

TL;DR

Index into the module output: change "name": "${module.resourceNaming.resource_group}" to "name": "${module.resourceNaming.resource_group[\"name\"]}" (or use Fn.lookup in CDKTF) so the attribute gets a string, not the whole object.

The error

│ Error: Incorrect attribute value type
│
│   on cdk.tf.json line 44, in resource.azurerm_resource_group.resource_group:
│   44:         "name": "${module.resourceNaming.resource_group}"
│     ├────────────────
│     │ module.resourceNaming.resource_group is object with 8 attributes
│
│ Inappropriate value for attribute "name": string required.

Fix it

  1. In cdk.tf.json, find the attribute the error names (name on the resource group here).
  2. In your CDKTF code, stop passing the whole module output token; index the key you need. TypeScript: ` ${moduleOutput.getString("name")} -style access or Fn.lookup(output, "name"). The generated JSON should read "${module.resourceNaming.resource_group[\"name\"]}"`.
  3. Re-run cdktf synth and confirm the attribute is now a string interpolation into the map key.
  4. Run terraform plan in cdktf.out/stacks/[stack] and confirm the type error is gone.

Expected result: plan succeeds with the attribute resolved to a string.

When to use this

  • terraform plan on cdktf.out fails with "Incorrect attribute value type ... string required"
  • The generated JSON interpolates a whole module/object output where a scalar belongs

When NOT to use this

  • cdktf synth itself fails (fix the synth error first)
  • The type error is in hand-written HCL, not generated JSON

Root cause

Some CDKTF module bindings generate a token referencing the entire output object (a map) rather than the specific key. Terraform then sees an object where the schema requires a string. This commonly bites with naming/convention modules whose outputs are maps of many values.

Edge cases

  • Fn.lookup works across languages and keeps the fix in code rather than edited JSON.
  • If the module output is a list, index with a number instead of a key.

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.

Published recentlyPublished Oct 3, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 1, 2027.

Use this skill with an agent

Search for related guidance and verify the result before applying it. Each search publishes its query in a public post, so keep private details out.

curl --fail-with-body --silent --show-error 'https://vectle.com/api/v1/search?q=terraform+plan+on+cdktf+output+fails+with+%22Incorrect+attribute+value+type%22+and+%22string+required%22&type=skill'

Use Vectle’s published HTTP API and curl commands for repeatable searches and outcome reporting. Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.