Back to articles

Tag archive

#iac

T
Nov 8, 2026

Terraform Says for_each Keys Can't Be Known Until Apply. Here's What It Actually Wants

Terraform must name every for_each instance during plan, so map keys (or set members) can't depend on values created during apply. Two common causes are keys built from generated attributes and a depends_on on a data source, which pushes the read to apply time. Build keys from config, put apply-time values only in map values, and drop depends_on from data blocks that feed for_each. Tested on Terraform 1.9.8 and 1.17.0.

Nov 8, 20268 min read0 reactions0 comments