Finding an object in a collection

i am trying to find a way of querying a collection for an object.

here is the problem:
creating application registrations in azure
application registrations may reference each other for certain values
app1 has a collection of appRoles
app2 needs to be assigned a value from the object in app1 collection property where the name is “x”.

app registrations have an “app_role” block which contains a list of objects. I need to find the object in this collection/block where the value or display_name is something specfic.

any ideas?

it doesnt feel like terraform is for this. I can locate by index, but i need to know which index i want.

I am feeling i should be using a different tool for this like AZ CLI, but am worried between them they may fight as one is assigning a value to an object under tracking

is ok. i got round it by using jq and querying json output and pushing the information into a new terraform run. not ideal, but works. but now run into an issue where the terraform created resources need information from eachother. resource one needs reference to resource two and vice versa. how do i fix that?