Environment Variables

Contact your Skuid representative to access this feature.

Note

Environment variables are only available for use on SQL data sources.

Environment variables are values stored as labeled references in a particular Skuid environment. These key-value pairs are often used to store protected information unique to an environment, like data source credentials. All variables are stored in a centralized location within Skuid settings.

Why use environment variables?

It’s common practice to develop in one environment, like a sandbox, and then deploy to another, like a production environment. When deploying to the next environment, some values are intentionally not sent because they are secret (like passwords) and others may need to be different (like database URLs). And even for values that are not protected, their settings would be overwritten during each deployment. In these examples, it would be better to have unique values for consistent placeholder references.

Enter environment variables. By defining the necessary variables in each environment, you’ll only need to enter them once—changing them only if their values change. By setting some fields to reference variables instead of hardcoded values, you won’t have to re-enter those field values each time you deploy to another environment. If the variable names match across environments, then their unique values are injected based on the environment’s configuration.

Example use case

A common workflow within Skuid could look like this:

  1. Within a sandbox environment, create environment variables for the username and password for a sandbox database, but whose variable name matches the production variables exactly.
  2. Within the sandbox environment, create a data source that—instead of hardcoded values—uses the previously created environment variables for its username and password credential fields.
  3. Within a production environment, create environment variables for the username and password for a production database.

Development would take place in the sandbox environment. When deployed to the production Skuid environment, the data source would function as expected, but pointed to the production database, because the environment names matched. Without using this variable-based workflow, credentials would need to be hardcoded and updated at the data source level in both environments.

Environment variable management

Variables are managed on the Environment Variables screen, accessible by navigating to Settings > Environment Variables. All existing variables are represented in a table.

Note

This screen only represents the variables for the current environment. It is not possible to set variables for other environments.

  • To create new variables, click Create. Enter the name and value of the variable, and then click Save.

    • If you wish to create more than one variable, click the Save another checkbox to immediately create another variable after saving.
    • Since variables can contain protected information, the value field is masked. To display the value, uncheck Hide value.
    • You cannot see an environment variable’s value once it is saved. This is intended to protect secret values, like passwords. Be sure you have values set correctly before saving.
  • To update existing variables, click dots-vertical More Options > Edit. Make any changes, and then click Save.

    Note

    • Because variables can contain sensitive information, existing values are masked. You cannot unmask variable values when editing them. click the name or value field on the variable’s row.
  • To delete one or more variables, click dots-vertical More Options > Delete.

Adding new variables from the data source screen

It’s also possible to create environment variables from data source screens. While not intended to be the primary method of managing variables, this workflow can serve as a useful shortcut when initially setting up data sources.

To save hardcoded values as new variables:

  1. Ensure the Save values as environment variables checkbox is enabled.

    Note

    This checkbox is enabled by default when creating new data sources, but must be manually enabled when editing existing data sources. The checkbox will disable if all fields use variables, as there will be no hardcoded values to save.

  2. Update the rest of your field values as needed.

  3. Click Save to save any changes. Doing so will display the Select your variables modal.

  4. Check the Save column checkbox for each field value you wish to save as variable.

    • If needed, update each variable’s Variable Name. Ensure variable names match across environments.
  5. Click Save.

Any fields whose values were saved as variables are updated to reference that newly created variable.

Note

The only way to update values for existing environment variables is the Environment Variables screen.

Using environment variables

On data sources

To use variables for data source fields:

  1. Create a new data source or navigate to the existing data source’s detail screen.
  2. Enable the Use variable toggle beside the data source field you wish to set as a variable. The field’s input box turns into a combobox.
  3. Select the variable you wish the field to reference.
  4. Click Save.

Note

If the Use variable toggle is disabled, the environment may not have any variables created. Verify there are variables available.