# Global Variables

Global Variables allow you to define and apply variables one time across all workspaces within an organization. For example, you could define a global variable of provider credentials and automatically apply it to all workspaces.

{% hint style="warning" %}
Workspace variables have priority over global variables if the same name is used.
{% endhint %}

### Creating a Global Variable

{% hint style="info" %}
Only users that belongs to Terrakube administrator group can create global variables. This group is defined in the terrakube settings during deployment, for more details see [#administrator-group](../../../getting-started/security#administrator-group "mention")
{% endhint %}

Once you are in the desired organization, click the **Settings** button, then in the left menu select the **Global Variables** option and click the **Add global variable** button

<figure><img src="https://2194998553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FR6VsmuTZWhfdwP7uD6e0%2Fuploads%2Fgit-blob-9537a4aa2db0593298234251edcbc5cbb906a798%2Fimage%20(229).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                                                                                                                                 |
| Category    | Category could be Terraform Variable or Environment Variable                                                                              |
| 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 global variable** button and the variable will be created

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

You will see the new global variable in the list. And now the variable will be injected in all the workspaces within the organization

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

### Edit a Global Variable

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

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

Change the fields you need and click the **Save global variable** button

{% hint style="warning" %}
For security, you can't change the **Sensitive** field. So if you want to change one global variable to sensitive you must delete the existing variable and create a new one
{% endhint %}

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

### Delete a Global Variable

Click the **Delete** button next to the global variable you want to delete, and then click the Yes button to confirm the deletion. Please take in consideration the deletion is irreversible

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