# Variables

Terrakube workspace variables let you customize configurations and store information like static provider credentials. You can also reference this variables inside your Templates.

You can set [variables specifically for each workspace](#workspace-specific-variables) or you can create [global-variables](https://docs.terrakube.io/2.21.0/user-guide/organizations/global-variables "mention") to reuse the same variables across multiple workspaces.

### Workspace-Specific Variables <a href="#workspace-specific-variables" id="workspace-specific-variables"></a>

To view and manage a workspace's variables, go to the workspace and click the **Variables** tab.

The **Variables** page appears, showing all workspace-specific variables. This is where you can add, edit, and delete workspace-specific variables.

There are 2 kinds of Variables:

* [Terraform Variables](#terraform-variables)
* [Environment Variables](#environment-variables)

### Terraform Variables

These Terraform variables are set using a terraform.tfvars file. To use interpolation or set a non-string value for a variable, click its HCL checkbox.

#### Add a Terraform Variable <a href="#add-a-variable" id="add-a-variable"></a>

Go to the workspace **Variables** page and in the *Terraform Variables* section click the **Add variable** button.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-54bb3f991dfaf569c2dd9b22e425c86d4a3e737a%2Fimage%20(273).png?alt=media" alt=""><figcaption></figcaption></figure>

In the popup, provide the required values. Use the below table as reference:

| Field       | Description                                                                                                                               |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Key         | Unique variable name                                                                                                                      |
| Value       | Key value                                                                                                                                 |
| Description | Free text to document the reason for this global variable                                                                                 |
| HCL         | Parse this field as HashiCorp Configuration Language (HCL). This allows you to interpolate values at runtime.                             |
| Sensitive   | Sensitive variables are never shown in the UI or API. They may appear in Terraform logs if your configuration is designed to output them. |

Finally click the **Save variable** button and the variable will be created.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-ef42309f7e541c72397406dd3312e60b55a72ebc%2Fimage%20(248).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Edit a Terraform Variable

Click the **Edit** button next to the variable you want to edit.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-624a83879a89e0f3ef68841bfd5869c3d4d499f5%2Fimage%20(197).png?alt=media" alt=""><figcaption></figcaption></figure>

Make any desired changes and click **Save variable.**

#### Delete a Terraform Variable

Click the **Delete** button next to the variable you want to delete.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-f9925cb8618bbb445b349f4976cd6fa9fe8cdf17%2Fimage%20(196).png?alt=media" alt=""><figcaption></figcaption></figure>

Click **Yes** to confirm your action.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-7e1df0f6ffe4686cbba5a2d12d5c8de6442bede3%2Fimage%20(285).png?alt=media" alt=""><figcaption></figcaption></figure>

### Environment Variables

These variables are set in Terraform's shell environment using export.

#### Add an Environment Variable <a href="#add-a-variable" id="add-a-variable"></a>

Go to the workspace **Variables** page and in the *Environment Variables* section click the **Add variable** button.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-b97a56cc1fdb9529b67c6c3f4159b68db2d028ad%2Fimage%20(194).png?alt=media" alt=""><figcaption></figcaption></figure>

In the popup, provide the required values. Use the below table as reference:

| Field       | Description                                                                                                                               |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Key         | Unique variable name                                                                                                                      |
| Value       | Key value                                                                                                                                 |
| Description | Free text to document the reason for this global variable                                                                                 |
| HCL         | Parse this field as HashiCorp Configuration Language (HCL). This allows you to interpolate values at runtime.                             |
| Sensitive   | Sensitive variables are never shown in the UI or API. They may appear in Terraform logs if your configuration is designed to output them. |

Finally click the **Save variable** button and the variable will be created.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-2c346ad8ae01e319352638aef3bf4734a409ab1d%2Fimage%20(91).png?alt=media" alt=""><figcaption></figcaption></figure>

#### Edit an Environment Variable

Click the **Edit** button next to the variable you want to edit.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-9276a5c2834e999ba4985cd79079049c08fd7745%2Fimage%20(92).png?alt=media" alt=""><figcaption></figcaption></figure>

Make any desired changes and click **Save variable.**

#### Delete an Environment Variable

Click the **Delete** button next to the variable you want to delete.

<figure><img src="https://3421131615-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fx1Ja1Osjf4KfhcMlJJom%2Fuploads%2Fgit-blob-9de7d846625b140bdfc959fd28359cbb2d3ab0cc%2Fimage%20(278).png?alt=media" alt=""><figcaption></figcaption></figure>

Click **Yes** to confirm your action.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.terrakube.io/2.21.0/user-guide/workspaces/variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
