Book Image

Spring Boot Cookbook

By : Alex Antonov
Book Image

Spring Boot Cookbook

By: Alex Antonov

Overview of this book

Table of Contents (15 chapters)
Spring Boot Cookbook
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
Index

Externalizing 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 can manipulate the data in it. Next step would be to integrate Consul with our application and make the data extraction process seamless and non-invasive from the application's stand point.

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 and open-sourced by Hashicorp, called envconsul to 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 that was created in the previous recipes, we need to install the envconsul utility.

Let's download the binary for your respective...