Environment Variables
    • Dark
      Light

    Environment Variables

    • Dark
      Light

    Article summary

    This page shows us how to configure environment variables and use them in the FTX configuration.

    How to configure

    We are able to setup environment variables for the device in Balena and Azure Iot Edge.

    Balena

    There are two ways of configuring environment variables in balena.

    Fleet Level

    A fleet can have multiple devices so if you configure environment variables here, they apply to all devices in that fleet.

    To configure, go to the fleet page and search for “Variables” on the sidebar.

    Device Level

    A device with environment variables will override fleet environment variables that share the same name.

    To configure, go to the device page and search for “Device Variables” on the sidebar.

    Azure Iot Edge

    To configure environment variables, follow these steps:

    1. Find the iot hub resource in azure
    2. Click on “Devices” on the sidebar and select the relevant device.
    3. Click on “Set Modules”
    4. Click on the module named “factorytx”
    5. You should now be able to configure “Environment Variables” on this page.

    How to use environment variables in the config

    The configuration supports bash-like environment variables for string values.

    • Values such as ${PASSWORD} or ${PREFIX}-name are allowed.
    • If you want to prevent the environment variables from showing up or being stored in the logs, prefix the name with ${FTX_CREDS}. For example, something configured with ${FTX_CREDS_PASSWORD} will be hidden from the logs.

    For example, your config can look like this:

    {
      "data_receiver": [
        {
          "data_receiver_name": "${FACTORY} sql receiver",
          "protocol": "sql",
          "poll_interval": 10,
          "connections": [
            {
              "host": "${SQL_FACTORY_HOSTNAME}",
              "port": ${SQL_FACTORY_PORT},
              "username": "${SQL_FACTORY_USERNAME}",
              "password": "${SQL_FACTORY_PASSWORD}",
              "database_type": "postgresql",
              "database_name": "p1",
              "ssl": false
            }
          ...
        ]
    }