Page 1 of 1

how to externalize a db connection with environmental variables?

Posted: Wed Sep 05, 2018 2:11 am
by ramiro

We've been using externalized connections for db access, and we were able to apply params in there via config files, so we don't have to hardcode the actual db connection values.

We want to go a step further, and take those params from env variables, instead of from the XML config files, our connection file looks like this:

Code: Select all

#Tue Sep 04 10:45:38 PDT 2018

when we run graphs with it, we get the following error:

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Unknown host: ${RDS_DB_HOST}

according to your documentation, environmental variables can be read the same way other config parameters are: ... ables.html

and yet, it looks like the connection is failing to translate "${RDS_DB_HOST}" to the actual host we confirmed existed in the env variable...

why would this work for configs coming from the XML param files, but not from env variables?

if dynamic params in the config file won't work, is there a better way to establish the connection off env variables?

Re: how to externalize a db connection with environmental variables?

Posted: Fri Sep 07, 2018 1:28 pm
by cholastal
Hi Ramiro,

It is possible to use environment variables even in externalized connections. However, under certain circumstances, these variables may not be visible to CloverETL, mainly on Linux where these variables may exist in isolated shells. So, the most reliable way to tell whether the CloverETL can see them is to navigate into the CloverETL Server web console -> Configuration -> System Info -> Environment Variables. It you can see your variable here, you can use it within the software. Here you can find how to reliable define a global environment variable for Linux. If you are on a different OS, please let me know which one it is, whether you can see them in the web console and how did you define the variables. If you do not have a CloverETL Server or if it is located in a different environment, please let me know about it as well.

Best regards,

Re: how to externalize a db connection with environmental variables?

Posted: Fri Sep 07, 2018 10:45 pm
by ramiro
Thanks Lukas,

It is possible indeed! We have the connection working now.

The problem was that we were caching the docker image that run cloverETL.

We run everything in containers, and I was using the old cached version (without the new env variables set) by mistake.

All good, not a cloverETL issue, but thanks for the response!