Using environment variable in outgoing connections

Hello,

I’m trying to use some environment variables to configure my enmasse file for outgoing connections.

image

  - cache_expiry: 0
    connection: outgoing
    data_format: json
    has_rbac: false
    host: $MY_SERVICE_ADDRESS
    http_accept: ""
    is_active: true
    is_internal: false
    name: MY_SERVICE
    ping_method: HEAD
    pool_size: 20
    sec_def: zato-no-security
    sec_tls_ca_cert_id:
    serialization_type: string
    timeout: 10
    transport: plain_http
    url_params_pri: qs-over-path
    url_path: /

I have created an env.ini file in /opt/hot-deploy/enmasse/

[env]
MY_SERVICE_ADDRESS=http://ip_address

I have also configure my docker-compose like this:

environment:
      Zato_SSH_Password: ${ZATO_SSH_PASSWORD}
      Zato_Dashboard_Password: ${ZATO_WEB_ADMIN_PASSWORD}
      Zato_IDE_Password: ${ZATO_IDE_PUBLISHER_PASSWORD}
      Zato_Host_Database_Port: 5432
      Zato_ODB_Hostname: db
      Zato_ODB_Password: ${DB_PASSWORD}
      MY_SERVICE_ADDRESS: ${MY_SERVICE_ADDRESS}

And I’m using a .env with docker-compose like this:

MY_SERVICE_ADDRESS=http://ip_address

When I ping the connection I get the following error:

esb_1      | 2022-06-24 09:51:59,744 - INFO - 3161:Dummy-92 - zato.server.connection.http_soap.outgoing:0 - Pinging:`{'id': 86, 'is_active': True, 'method': '', 'data_format': 'json', 'name': 'MY_SERVICE', 'transport': 'plain_http', 'address_host': 'ENV_KEY_MISSING_MY_SERVICE_ADDRESS', 'address_url_path': '/', 'soap_action': '', 'soap_version': '', 'ping_method': 'HEAD', 'pool_size': 20, 'serialization_type': 'string', 'timeout': 10.0, 'content_type': '', 'security_name': None, 'sec_type': None, 'username': None, 'password': '***', 'password_type': None, 'orig_username': None, 'tls_verify': True}`

Docker image: ghcr.io/zatosource/zato-3.2-quickstart:latest

Zato version: Zato 3.2+rev.65d16e4b-py3.8.10-ubuntu.20.04-focal

How can I proceed to use such variables ?

Hello @lwitz,

the enmasse syntax for that is a bit different.

In your enmasse file, instead of this …

host: $MY_SERVICE_ADDRESS

… please use this:

host: ZatoEnmasseEnv.MY_SERVICE_ADDRESS

The “ZatoEnmasseEnv.” prefix is a special indicator that makes enmasse look up a given key in environment variables. The first kind of syntax will not work in this case.

By the way, it is planned to make soon the “env.ini” file look like just the one in Docker to make it possible to use a single file for both enmasse and Docker.

Regards.

Hello @dsuch,

Thank you for your clarifications.
It works as expected.

Okay good to know for the simplification of env files.

Regards,