Variable interpolation across groups

I am working on a setup in which there are backend nodes running a legacy app that generates a UDP video stream. To overcome firewall issues I need to run an additional gateway component on a frontend server that assists in forwarding the stream to a client.

Below is a minimal example of what I am trying to do. I would like nomad to allocate dynamic ports on the server, and then somehow let the backend node know the IP and port of the gateway. I am not sure I can use Consul Connect because I need low-latency UDP, the backends run on Windows with no Docker support (installing Envoy is not so easy) and encryption is already built into the protocol.

Here is a minimal example - how would you recommend setting --udp-out-endpoint with the gateway IP and port?

job "session" {
  type="batch"
  
  parameterized {
    meta_required = ["SESSION_PARAM"]
  }
  
  group "backend" {
    
    # ... constraint to run on certain (Windows) nodes
    
    task "source" {
      driver = "raw_exec"
      
      config {
        command = "C:/path/to/legacy/app"
        args = [
          "--session", "${NOMAD_META_SESSION_PARAM}",
          # change this to gateway IP and backend-facing port
          "--udp-out-endpoint", "127.0.0.1:5600"
        ]
      }
    }

  }
  
  group "gateway" {
    
    # ... constraint to run on certain nodes
    
    task "gateway" {
      driver = "exec" # will probably change to docker
      
      config {
        image = "/path/to/app"
        args = [
          "--from", ":${NOMAD_PORT_backend}",
          "--to", ":${NOMAD_PORT_frontend}"
        ]
      }
      
      resources {
        network {
          # backend-facing port
          port "backend" {
          }
          # frontend-facing port
          port "frontend" {
          }
        }
      }
    }
    
  }

}