---
updatedAt: 2026-06-19T10:19:48.000Z
agentTools:
  projectIndex: https://docs.scalr.io/llms.txt
---

# scalr_variable

## Resource: scalr\_variable

Manages the state of variables in Scalr.

## Example Usage

```terraform
resource "scalr_variable" "example1" {
  key          = "my_key_name"
  value        = "my_value_name"
  category     = "terraform"
  description  = "variable description"
  workspace_id = "ws-xxxxxxxxxx"
}

resource "scalr_variable" "example2" {
  key          = "xyz"
  value        = jsonencode(["foo", "bar"])
  hcl          = true
  category     = "terraform"
  workspace_id = "ws-yyyyyyyyyy"
}

# Using write-only value (Terraform 1.11+)
resource "scalr_variable" "example3" {
  key              = "secret_key"
  value_wo         = ephemeral.aws_secretsmanager_secret.my_secret.secret_string
  value_wo_version = 1 # Increment to trigger an update when the secret changes
  category         = "terraform"
  sensitive        = true
  workspace_id     = "ws-zzzzzzzzzz"
}
```

## Schema

### Required

* `category` (String) Indicates if this is a Terraform or shell variable. Allowed values are `terraform` or `shell`.
* `key` (String) Key of the variable.

### Optional

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.

* `account_id` (String) ID of the account, in the format `acc-<RANDOM STRING>`.
* `description` (String) Variable verbose description, defaults to empty string.
* `environment_id` (String) The environment that owns the variable, specified as an ID, in the format `env-<RANDOM STRING>`.
* `final` (Boolean) Set (true/false) to configure as final. Indicates whether the variable can be overridden on a lower scope down the Scalr organizational model. Default `false`.
* `force` (Boolean) Set (true/false) to configure as force. Allows creating final variables on higher scope, even if the same variable exists on lower scope (lower is to be deleted). Default `false`.
* `hcl` (Boolean) Set (true/false) to configure the variable as a string of HCL code. Has no effect for `category = "shell"` variables. Default `false`.
* `sensitive` (Boolean) Set (true/false) to configure as sensitive. Sensitive variable values are not visible after being set. Default `false`.
* `value` (String, Sensitive) Variable value.
* `value_wo` (String, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Write-only variable value. Use instead of `value` when working with ephemeral values. Not stored in state. Requires `value_wo_version` to trigger updates.
* `value_wo_version` (Number) Version number for `value_wo`. Change this number to apply the current `value_wo` during an update.
* `var_set_id` (String) ID of the variable set this variable belongs to, in the format `varset-<RANDOM STRING>`. Cannot be used together with `workspace_id` or `environment_id`
* `workspace_id` (String) The workspace that owns the variable, specified as an ID, in the format `ws-<RANDOM STRING>`.

### Read-Only

* `id` (String) The ID of this resource.
* `readable_value` (String) A non-sensitive read-only copy of a variable value. Will be null if the variable is sensitive.
* `updated_at` (String) Date/time the variable was updated.
* `updated_by` (List of Object) Details of the user that updated the variable last time. (see [below for nested schema](#nestedatt--updated_by))
* `updated_by_email` (String) Email of the user who updated the variable last time.

<a id="nestedatt--updated_by"></a>

### Nested Schema for `updated_by`

Read-Only:

* `email` (String)
* `full_name` (String)
* `username` (String)

## Import

Import is supported using the following syntax:

```shell
terraform import scalr_variable.example var-xxxxxxxxxx
```

# Sibling pages

* [scalr\_endpoint](https://docs.scalr.io/scalr/docs/provider_resource_scalr_endpoint.md)
* [scalr\_access\_policy](https://docs.scalr.io/scalr/docs/provider_resource_scalr_access_policy.md)
* [scalr\_account\_allowed\_ips](https://docs.scalr.io/scalr/docs/provider_resource_scalr_account_allowed_ips.md)
* [scalr\_agent\_pool](https://docs.scalr.io/scalr/docs/provider_resource_scalr_agent_pool.md)
* [scalr\_agent\_pool\_token](https://docs.scalr.io/scalr/docs/provider_resource_scalr_agent_pool_token.md)
* [scalr\_assume\_service\_account\_policy](https://docs.scalr.io/scalr/docs/provider_resource_scalr_assume_service_account_policy.md)
* [scalr\_checkov\_integration](https://docs.scalr.io/scalr/docs/provider_resource_scalr_checkov_integration.md)
* [scalr\_drift\_detection](https://docs.scalr.io/scalr/docs/provider_resource_scalr_drift_detection.md)
* [scalr\_environment](https://docs.scalr.io/scalr/docs/provider_resource_scalr_environment.md)
* [scalr\_environment\_hook](https://docs.scalr.io/scalr/docs/provider_resource_scalr_environment_hook.md)
* [scalr\_event\_bridge\_integration](https://docs.scalr.io/scalr/docs/provider_resource_scalr_event_bridge_integration.md)
* [scalr\_federated\_environments](https://docs.scalr.io/scalr/docs/provider_resource_scalr_federated_environments.md)
* [scalr\_hook](https://docs.scalr.io/scalr/docs/provider_resource_scalr_hook.md)
* [scalr\_iam\_team](https://docs.scalr.io/scalr/docs/provider_resource_scalr_iam_team.md)
* [scalr\_integration\_infracost](https://docs.scalr.io/scalr/docs/provider_resource_scalr_integration_infracost.md)
* [scalr\_module](https://docs.scalr.io/scalr/docs/provider_resource_scalr_module.md)
* [scalr\_module\_namespace](https://docs.scalr.io/scalr/docs/provider_resource_scalr_module_namespace.md)
* [scalr\_policy\_group](https://docs.scalr.io/scalr/docs/provider_resource_scalr_policy_group.md)
* [scalr\_policy\_group\_linkage](https://docs.scalr.io/scalr/docs/provider_resource_scalr_policy_group_linkage.md)
* [scalr\_provider\_configuration](https://docs.scalr.io/scalr/docs/provider_resource_scalr_provider_configuration.md)
* [scalr\_provider\_configuration\_default](https://docs.scalr.io/scalr/docs/provider_resource_scalr_provider_configuration_default.md)
* [scalr\_role](https://docs.scalr.io/scalr/docs/provider_resource_scalr_role.md)
* [scalr\_run\_schedule\_rule](https://docs.scalr.io/scalr/docs/provider_resource_scalr_run_schedule_rule.md)
* [scalr\_run\_trigger](https://docs.scalr.io/scalr/docs/provider_resource_scalr_run_trigger.md)
* [scalr\_service\_account](https://docs.scalr.io/scalr/docs/provider_resource_scalr_service_account.md)
* [scalr\_service\_account\_token](https://docs.scalr.io/scalr/docs/provider_resource_scalr_service_account_token.md)
* [scalr\_slack\_integration](https://docs.scalr.io/scalr/docs/provider_resource_scalr_slack_integration.md)
* [scalr\_ssh\_key](https://docs.scalr.io/scalr/docs/provider_resource_scalr_ssh_key.md)
* [scalr\_storage\_profile](https://docs.scalr.io/scalr/docs/provider_resource_scalr_storage_profile.md)
* [scalr\_tag](https://docs.scalr.io/scalr/docs/provider_resource_scalr_tag.md)
* [scalr\_var\_set](https://docs.scalr.io/scalr/docs/provider_resource_scalr_var_set.md)
* [scalr\_vcs\_provider](https://docs.scalr.io/scalr/docs/provider_resource_scalr_vcs_provider.md)
* [scalr\_webhook](https://docs.scalr.io/scalr/docs/provider_resource_scalr_webhook.md)
* [scalr\_workload\_identity\_provider](https://docs.scalr.io/scalr/docs/provider_resource_scalr_workload_identity_provider.md)
* [scalr\_workspace](https://docs.scalr.io/scalr/docs/provider_resource_scalr_workspace.md)
* [scalr\_workspace\_run\_schedule](https://docs.scalr.io/scalr/docs/provider_resource_scalr_workspace_run_schedule.md)
* [scalr\_workspace\_var\_set](https://docs.scalr.io/scalr/docs/provider_resource_scalr_workspace_var_set.md)