Env variables in the API Definition

Hello!

I’m doing my first steps with Tyk and stuck with a simple task.

I use docker-compose for development to run 2 services: Tyk API Gateway and Test service.
Request to http://localhost:8080/test should be proxied to Test service host, defined in docker-compose config (http://test-service:3000).

Simple:

{
  "name": "Test",
  "use_keyless": true,
  "version_data": {
    "not_versioned": true,
    "versions": {
      "Default": {
        "name": "Default",
        "expires": ""
      }
    }
  },
  "proxy": {
    "preserve_host_header": false,
    "listen_path": "/test",
    "target_url": "http://test-service:3000",
    "strip_listen_path": true
  },
  "active": true,
} 

But host and port for target_url are hardcoded in thia case. If I need to change it for some reason - I need to make changes in Tyk API definition file. If I want to deploy my code to the cloud - I need to worry about the same service host.

I read about the service_discovery option. But anyway I need to path query_endpoint for it which depends on the environment.

I found a similar question without an answer: Use environment variable for jwt_source in API def JSON

So, what is a workaround?

Maybe there is something like $tyk_context or $tyk_meta for API definition and I just cannot find it?
Or another approach…
I thought about storing definitions as templates and process them on start with ENV variables. Using sed, for example. But it looks not elegantly.

Found issue about this problem https://github.com/TykTechnologies/tyk/issues/2476