Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Variables

Variables

In Terraform, a variable is a way to store and reuse values throughout your Terraform code, and it is defined using the variable block.

Brainboard allows you to create a variable manually, or you can also import it from an existing file. File types allowed are: tfvars , tf.

Action items on the Variables window

Shared below is the screenshot of the Variables window, numbered with action items/features available on this screen, followed by their brief description.

By default, the variables list is displayed when you click on the variables icon in the right panel.

#
Feature
Purpose / Description

1

Add Variable (+)

To create a new variable. (Explained in detail below).

2

Search option

To search for a specific variable on the Variables window. Keyword search is supported.

3

Filter

Using this option, you can filter the list of variables by scope or by the user who updated the variable. So, you have the following three options: - All (no filter). - Scope: architecture, environment, project, organization. - Updated by: select the user name whose updated variables you want to view.

4

Sorting variables list

You can sort the list of variables according to ascending or descending order of their names, as well as in ascending/descending order of the date when they were last updated.

5

Filter

The scope selector allows you to view variables that are defined in every scope or display all variables of all scopes.

6

Expand all / Collapse all

Clicking this will exapnd the variables section for you to view details of each variable in the list. Clicking it again will collapse the expanded view.

Creating a new variable

To create a new variable, expand the right panel, and follow these steps:

  1. Click the Variable icon available in the right panel.

  2. Then, click the + icon to add/import variables. It opens the Create Variable modal.

  1. After that, you can either create a variable manually or you can click on the Import option to import already defined variables from an external file (tfvars , tf ).

On the "Create variable" form, you can specify the following information:

  1. Name of the variable: This is the name that you'll use to reference the variable when you use it.

It follows the naming conventions of Terraform; for example, it doesn't support spaces or starting with a number.

Best practice: use clear and explicit names and separate words with an underscore _.

  1. Scope: You can set the level at which you want this variable to be available.

The four levels of scopes are listed in the order of "least shared or restrictive to most shared/available/"

There is an override mechanism if the same variable is defined in multiple scopes.

Scope
Explanation
Variable Override

Architecture

Variables that are defined with this scope are only available within this architecture only.

If the same variable is defined in another level as well, the default or values defined at the architecture level overrides any other level.

Environment

Variables defined at the environment level are available to all architectures within the same environment.

Variables defined in this level override those defined at project and organization level.

Project

Variables defined at the project level are available to all environments and architectures within the same project.

Variables defined in this level override those defined at the organization level.

Organization

Variables defined at the organization level are available to all architectures, environments and project within the organization.

  1. Description: It should concisely explain the purpose of the variable and what kind of value is expected. This description string might be included in documentation about the module, and so it should be written from the perspective of the user of the module rather than its maintainer.

  2. Variable type: This allows you to restrict the type of value that will be accepted.

If no type constraint is set, then a value of any type is accepted.

While type constraints are optional, we recommend specifying them; they can serve as helpful reminders for users of the module, and they allow Terraform to return a helpful error message if the wrong type is used.

  1. Default value: If present, the variable is considered to be optional and the default value will be used if no value is set.

  2. Value: The value that will be used during Terraform execution and if defined, it overrides the default value.

    1. This value will be put in the file terraform.tfvars .

    2. If you convert the architecture into a template or clone the architecture, this value will be removed.

  3. Sensitive: Setting this flag prevents Terraform from showing its value in the plan or apply output and Brainboard will store the variable in a separate vault.

  1. Validation: You can specify custom validation rules for the variable.

Refer to the RBAC (Role Based Access Control) documentation page to understand how you can manage permissions to restrict/allow members and teams to add, update or delete variables.

Last updated