The YAML format does not include support for variables.
It is difficult to recommend a specific path forward - given the relatively low complexity of the test input data, moving it directly into your .tf file is the best way to go, but I imagine your real data might be more complex.
This is not something which can simply be upgraded. YAML is a standard format defined independently of Terraform.
In order for members of this forum to provide useful advice, I think you’ll have to describe, in more general terms, what you are trying to do - as the specific solution you’re currently aiming for is impossible, so it is necessary to step back and consider the available options without a preconceived solution.