Terraform Says for_each Keys Can't Be Known Until Apply. Here's What It Actually Wants
DEV Community
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.
0 comments
No comments yet.