What are "known after apply" and unknown values, and why do they limit what you can do?
AdvancedConceptWorkflow and CLI
Answer
Unknown values are attributes the provider cannot compute until the resource exists, such as an instance ID. Terraform tracks them through the plan, but cannot use them where it must know the value to build the graph, such as count or for_each keys, or resource addresses. That is why for_each = toset(aws_instance.x[*].id) fails and you key by static values instead.
More on Workflow and CLI
What does `terraform init` do?BeginnerWhat does `terraform plan` do?BeginnerWhat does `terraform apply` do and what is `-auto-approve`?BeginnerWhat does `terraform destroy` do?BeginnerWhat do `terraform fmt` and `terraform validate` check?BeginnerWhy save a plan with `-out` and apply that file?Intermediate