Workspace variables
| Category | Behaves like | Example |
|---|---|---|
| Terraform variable | A value for a variable block |
instance_count = 3 |
| Environment variable | A shell environment variable in the run | AWS_REGION, TF_LOG, provider credentials |
- Tick the HCL checkbox for complex values such as lists, maps, and objects.
- Sensitive variables are write-only: once saved, nobody can read them back in the UI or API. They're still available to runs. Terraform also treats them as sensitive in its output.
Variable sets
Variable sets are reusable groups of variables that you apply to the whole organization, to projects, or to specific workspaces. Use them for shared settings or credentials, so you don't duplicate values per workspace.
Precedence (flagged): workspace-specific variables override variable sets with the same name. A variable set marked priority overrides workspace variables, and overrides values from the configuration's own variable files. Check the current HCP Terraform variable documentation for the full precedence order, including how *.auto.tfvars files in the uploaded configuration interact with workspace variables.
Credentials
- Prefer dynamic provider credentials. HCP Terraform uses OIDC workload identity to obtain short-lived credentials per run from AWS, Azure, GCP, Vault, or Kubernetes. No long-lived keys are stored.
- If you must use static keys, store them as sensitive environment variables in a variable set scoped to the right project.