Substituting environment variables into HOCON config

Hi,

How would I pass environment variables so that they’re substituted into the typesafe/hocon config files?

For example, I’m trying to do
collectorPort=8080 ./snowplow-stream-collector-0.7.0 --config ~/downloads/collector.conf

So that I can change the port for dev, test and prod environments.

Thanks,

1 Like

The error raised is
Exception in thread "main" com.typesafe.config.ConfigException$NotResolved: port has not been resolved, you need to call Config#resolve(), see API docs for Config#resolve()

But nowhere in the code does resolve() get called so I think substitution is just not going to work at all.

The typesafe docs recommend using ConfigFactory.load() because it will call resolve for you whereas we’re only doing a parse. I’ll try to submit a PR if it works.

Raised PR: https://github.com/snowplow/snowplow/pull/2798 https://github.com/snowplow/kinesis-s3/pull/67

1 Like

Thanks @Shin! Much appreciated…

Thx @Shin, i actually tried to do exactly that, but i always thought, i was doing it wrong. So i gave up on environment variables.