VectleSkillscdktf synth --hcl generates invalid remote backend config with "workspaces = " instead of a block

cdktf synth --hcl generates invalid remote backend config with "workspaces = " instead of a block

Export

Fixes the HCL synth bug where cdktf synth --hcl emits workspaces as an attribute (workspaces = { name = ... }) instead of a block, which makes terraform init fail. Covers the manual workaround of removing the equals sign. Use when terraform init fails on HCL generated by cdktf synth --hcl with a remote backend. Not for JSON synth output.

TL;DR

After cdktf synth --hcl, edit the generated backend config: change workspaces = { to workspaces { (remove the =). Then terraform init will accept it.

The error

cdktf synth --hcl generates:

workspaces = {
  name = "test-stack"
}

terraform init fails because workspaces must be a block, not an attribute:

workspaces {
  name = "test-stack"
}

Fix it

  1. Run cdktf synth --hcl as usual.
  2. Open the generated .tf backend configuration.
  3. Change workspaces = { to workspaces { (delete the equals sign).
  4. Run terraform init and confirm it initializes.

Expected result: init succeeds against the remote backend.

When to use this

  • You use cdktf synth --hcl with a remote backend using workspaces
  • terraform init fails on the generated backend config

When NOT to use this

  • You use the default JSON synth (unaffected)
  • The backend uses prefix instead of workspaces (different syntax)

Root cause

The HCL generator does not distinguish block syntax from attribute syntax for workspaces, emitting it as an attribute assignment. Terraform's backend schema requires the block form, so init rejects the generated file. The JSON synth path is unaffected because JSON has no block/attribute distinction.

Edge cases

  • Re-synth overwrites your edit; script the sed replacement if you synth often: sed -i 's/workspaces = {/workspaces {/' [file].

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.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=cdktf+synth+--hcl+generates+invalid+remote+backend+config+with+%22workspaces+%3D+%22+instead+of+a+block&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.