_images/login_button.png _images/signup_button.png



Shell Variables

Reading time: 4 minutes

In addition to Terraform input variables there are a few use cases for declaring shell variables in the run time environment. Shell variables can be declared in Scalr and are exported into the Terraform runtime environment using with export var=value.

Scalr uses this technique to automatically publish provider credentials to workspaces for the major cloud platforms. See Cloud Credentials for more details.

Some other use cases for shell variables are as follows.

  • Provide credentials to providers that are not supported by Scalr Cloud Credentials (see individual provider docs).

  • Pass in non-credentials configuration values to providers, such as location for AWS (see individual provider docs).

  • Set values for Terraform input variables with TF_VAR_{variable_name}={value}.

  • Pass in data to be used in scripts executed by provisioners or data "external" {}.

  • Set Terraform debug/behavioral variables NEWWIN.

Setting Shell Variables

Scalr provides multi-scope shell variables that can be set at any scope and inherited at lower scopes. Variables set at higher scopes can, depending on the configuration of the variable, have their value overridden at lower scopes. The hierarchy is as follows.

  • Account

  • Environment -> Inherits from Account

  • Workspace -> Inherits from Account and Environment

Shell variables marked as “final” at any scope cannot be overridden by lower scopes. They can also be marked as “sensitive” to ensure the value is masked out in the Scalr UI, API and Provider results and Terraform plan and state output.

Shell variables are set in the “Variables” section at each scope and are color coded to show the scope(s) they have been set at.

Example: Account scope

_images/ms_var_1.png

Use the slider icon to access the variable configuration detail. Make sure to “Save” after any changes to variables.

Example: Environment scope

_images/ms_var_2.png

Note that some provider credential variables are show. These have been inherited from cloud credentials set at account scope, hence the green icon.

Variable VAR_THREE has been overridden at environment scope as shown by the green and blue icons. Variables are overridden by creating a new variable of the same name. An overridden variable is shown as a group with the lowest scope, and therefore applicable value visible. The variable can be ungrouped using the button on the right so that variable can be edited or deleted.

_images/ms_var_3.png

Example: Workspace scope

_images/ms_var_4.png