I have a plan with some resources generated from the same count meta-argument:
As seen above, for the first index  the policy_arn is constant, however for the other indices 1 and 2 the policy_arn is referenced.
The references for the policy_arn attribute are:
How terraform knows which value is relevant for each index? What is supposed to be the policy_arn for index 1 and 2 if there are several values?
Terraform knows because it looks at the configuration in your
The JSON formatted plan is only a summary of the full saved plan bundle, and does not contain that data.
It looks like your first screenshots are of the “plan” part of
terraform show -json planfile, but your last screenshot is of the “config” section.
The “config” section describes the static configuration prior to any evaluation, so the references it shows in there are the ones Terraform would use to construct the dependency graph and populate the expression scope for evaluation.
The “plan” section describes the results of evaluating those expressions during the plan phase. Not all information is ready yet during the plan phase, so you will see some information show as “unknown”, which is the same as
(known after apply) in the UI.
If you apply this plan then Terraform will reevaluate all of the expressions again using the results from applying the upstream changes – that is, the changes to the objects described as “references” in the config section – so that re-evaluation should produce the final values for those arguments. You can’t see those final values in the plan because they aren’t known yet, but after apply you can inspect the state to see the final values of everything after changes are complete.