Is there a way to evaluate an expression and get the result?

I have multiple nodes scattered around different regions. My application is deployed region wise, i.e. the application present in region A will only talk to resources in region A.

However, in order to provide high availability if resources in region A are not available for some reason, the request should go to region B.
I'm trying to see if I can evaluate the health of a node in a particular region and then the return the resource Id that the application will have to use.

Is there any way to evaluate an expression and the return a static value?
For ex-
resource: region A? resource A : resource B