Setting the Consul Connection Parameters

You set the values for app properties that you want to override by creating a Key/Value pair for each property in Consul. You can create a standalone property or a hierarchy that groups multiple related properties.

Prerequisites

This document assumes that you have access to Consul and are familiar with its use.
To create a standalone property (without hierarchy), you simply enter the property name as the name of the Key when creating the Key in Consul. To create a property within a hierarchy enter the hierarchy in the following format in the Create Key field in Consul: <key_prefix>/<key_name> where <key_prefix> is a meaningful string or hierarchy that serves as a path to the key in Consul and <key_name> is the name of the app property whose value you want to override. For example, in dev/Timer/Message and test/Timer/Message, dev/Timer and test/Timer are the <key_prefix> which could stand for the dev and test environments and Message is the key name. During runtime, you provide the <key_prefix> value which tells your app the location in Consul from where to access the property values.
Important: The Key name in Consule must be identical to its counterpart in the Application Properties dialog in TIBCO Cloud Integration - Flogo (PAYG). If the key name does not match exactly, you will receive a warning message and the app will use the default value that you configured for the property in TIBCO Cloud Integration - Flogo (PAYG).
Important: A single app property, for example Message, will be looked up by your app as either Message or <key_prefix>/Message in Consul. An app property within a hierarchy such as x.y.z will be looked up as x/y/z or <key_prefix>/x/y/z in Consul. Note that the dot in the hierarchy is represented by a forward slash (/) in Consul.

After you have configured the app properties in Consul, you need to set the environment variable, FLOGO_APP_PROPS_CONSUL with the Consul connection parameters in order for your app to connect to the Consul. When you set the environment variable, it triggers the app to run, which connects to the Consul using the Consul connection parameters you provided and pulls the app property values from the key_prefix location you set by matching the app property name with the key_name. Hence, it is mandatory for the Key names to be identical to the app property names defined in the Application Properties dialog in TIBCO Cloud Integration - Flogo (PAYG).

You can set the FLOGO_APP_PROPS_CONSUL environment variable either by directly entering the values as a JSON string on the command line or placing the properties in a file and using the file as input to the FLOGO_APP_PROPS_CONSUL environment variable.

Entering the Consul Parameter Values as a JSON String

To enter the Consul parameters as a JSON string, enter the parameters as key/value pairs using the comma delimiter. The following examples illustrate how to set the values as JSON strings. You would run the following from the location where your app resides:

An example when not using security without tokens enabled:
FLOGO_APP_PROPS_CONSUL="{\"server_address\":\"http:\/\/127.0.0.1:8500\"}" ./Timer-darwin-amd64
where Timer-darwin-amd64 is the name of the app binary.
An example when tokens are enabled and app properties are within a hierarchy:
FLOGO_APP_PROPS_CONSUL="{"server_address":"http://127.0.0.1:8500","key_prefix":"/dev/Timer","acl_token":"SECRET:b0UaK3bTyD9wN+ZJkmlKRmojhAv+"}"
where /dev/Timer is the path and SECRET is the encrypted value of the token obtained from the Consul.

This command directs your app to connect to the Consul at the server_address and pull the values for the properties from the Consul and run your app with those values.

Refer to Consul Connection Parameters section for a description of the parameters. Refer to Encrypting Password Values for details on how to encrypt a value.

Setting the Consul Parameter Values Using a File

To set the parameter values in a file, create a .json file, for example, consul_config.json containing the parameter values in key/value pairs. Here's an example:
{
    "server_address": "http://127.0.0.1:32819",
    "key_prefix": "/dev/<APPNAME>/",
    "acl_token": "SECRET:b0UaK3bTyD9wN+ZJkmlKRmojhAv+"
}

You would place the consul_config.json file in the same directory which contains your app binary.

You would then run the following from the location where your app binary resides to set the FLOGO_APP_PROPS_CONSUL environment variable. For example, to use the consul_config.json file from the example above, you would run:
FLOGO_APP_PROPS_CONSUL=consul_config.json ./<app_binary_name>

The command extracts the Consul server connection parameters from the file and connects to the Consul to pull the app properties values from the Consul and run your app with those values.

Consul properties can also be run using docker by passing the same arguments for the docker image of a binary app.

Related reference