How to use an "each.value" when referencing another resource

Hi - Welcome to the forum - please reformat your message

Terraform does not have support for dynamically referencing arbitrary other resource blocks. All references to blocks have to be explicitly written into the configuration file.

There are two common workarounds.

Option 1: Restructure the group of resource blocks that you want to reference, to one resource block with a for_each. Whilst you can’t dynamically reference a different resource block, you can dynamically specific which element of a for_each you want to refer to.

Option 2: Write out a local variable consisting of an object/map that map strings to various other resource blocks. Do your lookup through your separately curated lookup variable.