As of November 8, 2026, this post sums up the official pages linked here.
TL;DR: Terraform gives every for_each instance an address like aws_route_table_association.public["us-east-1a"] , and it must know those keys during plan . If a key comes from something that only exists after apply , plan stops with Invalid for_each argument . The two usual causes are keys built from generated attributes, and a depends_on on a data source that pushes its read to apply time. The fix is to take keys from your config and let only the values be unknown. -target gets you past one run but doesn't fix the config.
The problem
A Reddit user was building route table associations for the public subnets behind a load balancer. Their flow went like this:
Read the load balancer with a data source.…