Dynamic env vars in yaml file

trying to build connection between apps ( totaling one full application ).
Wanting to get a variable from another but with protocol… or trailing slug

- key: MAIN_TEST_HOST_PORT
  fromService:
    type: web
    name: Test 1 - Main API
    property: hostport
- key: MAIN_TEST_PUBLIC_URL
  value: 'http://' + MAIN_TEST_HOST_PORT

or

- key: MAIN_TEST_HOST_PORT
  fromService:
    type: web
    name: Test 1 - Main API 
    property: hostport
- key: MAIN_TEST_PUBLIC_URL
  value: 'http://' + MAIN_TEST_HOST_PORT + '/slughere'

but not able to get the concat to work at all… any help here would be greatly appreciated!

Hi there.

Unfortunately our blueprints do not support variable interpolation. One workaround you could try is to do this as part of the startCommand, for example:

startCommand: MAIN_TEST_PUBLIC_URL="http://$MAIN_TEST_HOST_PORT/slughere" node server.js

It might be cleaner to write a Bash script for this, and call it in startCommand.

Thank you for your response Hieu:
so, startCommand fires before buildCommand then, correct?
( I ask because there is a difference in the UI - build is first in order on the screen )

buildCommand is run first in order to build your service. If you need the interpolation to happen at build time, you can put the snippet MAIN_TEST_PUBLIC_URL="http://$MAIN_TEST_HOST_PORT/slughere" in your buildCommand instead.

1 Like