Externalizing an environmental config using Consul and envconsul
In the previous recipe, we had our Consul service installed and experimented with its key/value capabilities to learn how we could manipulate the data in it in order to integrate Consul with our application and make the data extraction process seamless and non-invasive from an application standpoint.
As we don't want our application to know anything about Consul and have to explicitly connect to it, even though such a possibility exists, we will employ another utility, also created as open source by Hashicorp, called envconsul. It will connect to the Consul service for us, extract the specified configuration key/value tree, and expose it as the environment variables to be used while also launching our application. Pretty cool, right?
Getting ready
Before we get started with launching our application, which was created in the previous recipes, we need to install the envconsul utility.
Download the binary for your respective operating...